diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h new file mode 100644 index 0000000000000000000000000000000000000000..7665a131a63d10db68a38a97a96dd1e04a482e27 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1992-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ALLOCA_H +#define _ALLOCA_H 1 + +#include + +#define __need_size_t +#include + +__BEGIN_DECLS + +/* Remove any previous definition. */ +#undef alloca + +/* Allocate a block that will be freed when the calling function exits. */ +extern void *alloca (size_t __size) __THROW; + +#ifdef __GNUC__ +# define alloca(size) __builtin_alloca (size) +#endif /* GCC. */ + +__END_DECLS + +#endif /* alloca.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5a9a32eafda790ff7e0bc6e62156dfdd55411a95 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@alloca.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h new file mode 100644 index 0000000000000000000000000000000000000000..67f1cce5e994c013d01d9102ea488f76d66b96ca --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h @@ -0,0 +1,141 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.2 Diagnostics + */ + +#ifdef _ASSERT_H + +# undef _ASSERT_H +# undef assert +# undef __ASSERT_VOID_CAST + +# ifdef __USE_GNU +# undef assert_perror +# endif + +#endif /* assert.h */ + +#define _ASSERT_H 1 +#include + +#if defined __cplusplus && __GNUC_PREREQ (2,95) +# define __ASSERT_VOID_CAST static_cast +#else +# define __ASSERT_VOID_CAST (void) +#endif + +/* void assert (int expression); + + If NDEBUG is defined, do nothing. + If not, and EXPRESSION is zero, print an error message and abort. */ + +#ifdef NDEBUG + +# define assert(expr) (__ASSERT_VOID_CAST (0)) + +/* void assert_perror (int errnum); + + If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an + error message with the error text for ERRNUM and abort. + (This is a GNU extension.) */ + +# ifdef __USE_GNU +# define assert_perror(errnum) (__ASSERT_VOID_CAST (0)) +# endif + +#else /* Not NDEBUG. */ + +__BEGIN_DECLS + +/* This prints an "Assertion failed" message and aborts. */ +extern void __assert_fail (const char *__assertion, const char *__file, + unsigned int __line, const char *__function) + __THROW __attribute__ ((__noreturn__)); + +/* Likewise, but prints the error text for ERRNUM. */ +extern void __assert_perror_fail (int __errnum, const char *__file, + unsigned int __line, const char *__function) + __THROW __attribute__ ((__noreturn__)); + + +/* The following is not at all used here but needed for standard + compliance. */ +extern void __assert (const char *__assertion, const char *__file, int __line) + __THROW __attribute__ ((__noreturn__)); + + +__END_DECLS + +/* When possible, define assert so that it does not add extra + parentheses around EXPR. Otherwise, those added parentheses would + suppress warnings we'd expect to be detected by gcc's -Wparentheses. */ +# if defined __cplusplus +# define assert(expr) \ + (static_cast (expr) \ + ? void (0) \ + : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION)) +# elif !defined __GNUC__ || defined __STRICT_ANSI__ +# define assert(expr) \ + ((expr) \ + ? __ASSERT_VOID_CAST (0) \ + : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION)) +# else +/* The first occurrence of EXPR is not evaluated due to the sizeof, + but will trigger any pedantic warnings masked by the __extension__ + for the second occurrence. The ternary operator is required to + support function pointers and bit fields in this context, and to + suppress the evaluation of variable length arrays. */ +# define assert(expr) \ + ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \ + if (expr) \ + ; /* empty */ \ + else \ + __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \ + })) +# endif + +# ifdef __USE_GNU +# define assert_perror(errnum) \ + (!(errnum) \ + ? __ASSERT_VOID_CAST (0) \ + : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION)) +# endif + +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' + which contains the name of the function currently being defined. + This is broken in G++ before version 2.6. + C9x has a similar variable called __func__, but prefer the GCC one since + it demangles C++ function names. */ +# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4) +# define __ASSERT_FUNCTION __extension__ __PRETTY_FUNCTION__ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __ASSERT_FUNCTION __func__ +# else +# define __ASSERT_FUNCTION ((const char *) 0) +# endif +# endif + +#endif /* NDEBUG. */ + + +#if defined __USE_ISOC11 && !defined __cplusplus +# undef static_assert +# define static_assert _Static_assert +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..2214ef34c79558201cc0a9d7398e7874c0a6bbf9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@assert.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h new file mode 100644 index 0000000000000000000000000000000000000000..e0f80386529e4f5481dd8f357870bf502ab0c15e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h @@ -0,0 +1,35 @@ +/* Monotonically increasing wide counters (at least 62 bits). + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_ATOMIC_WIDE_COUNTER_H +#define _BITS_ATOMIC_WIDE_COUNTER_H + +/* Counter that is monotonically increasing (by less than 2**31 per + increment), with a single writer, and an arbitrary number of + readers. */ +typedef union +{ + __extension__ unsigned long long int __value64; + struct + { + unsigned int __low; + unsigned int __high; + } __value32; +} __atomic_wide_counter; + +#endif /* _BITS_ATOMIC_WIDE_COUNTER_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..afbf7143e22f556d50a032990db7719f6105d56d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@atomic_wide_counter.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h new file mode 100644 index 0000000000000000000000000000000000000000..ca8417d59a80d3db8ac00a866b76cb3cd98a97f0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h @@ -0,0 +1,79 @@ +/* Macros and inline functions to swap the order of bytes in integer values. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#ifndef _BITS_BYTESWAP_H +#define _BITS_BYTESWAP_H 1 + +#include +#include + +/* Swap bytes in 16-bit value. */ +#define __bswap_constant_16(x) \ + ((__uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) + +static __inline __uint16_t +__bswap_16 (__uint16_t __bsx) +{ +#if __GNUC_PREREQ (4, 8) + return __builtin_bswap16 (__bsx); +#else + return __bswap_constant_16 (__bsx); +#endif +} + +/* Swap bytes in 32-bit value. */ +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \ + | (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) + +static __inline __uint32_t +__bswap_32 (__uint32_t __bsx) +{ +#if __GNUC_PREREQ (4, 3) + return __builtin_bswap32 (__bsx); +#else + return __bswap_constant_32 (__bsx); +#endif +} + +/* Swap bytes in 64-bit value. */ +#define __bswap_constant_64(x) \ + ((((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + +__extension__ static __inline __uint64_t +__bswap_64 (__uint64_t __bsx) +{ +#if __GNUC_PREREQ (4, 3) + return __builtin_bswap64 (__bsx); +#else + return __bswap_constant_64 (__bsx); +#endif +} + +#endif /* _BITS_BYTESWAP_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..55491c3c6c5ef1598e30fa6505f6c7141217255f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@byteswap.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h new file mode 100644 index 0000000000000000000000000000000000000000..f8ae1e49bbb237e3df9276968ff605f1ea18a0b0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h @@ -0,0 +1,681 @@ +/* `sysconf', `pathconf', and `confstr' NAME values. Generic version. + Copyright (C) 1993-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _UNISTD_H +# error "Never use directly; include instead." +#endif + +/* Values for the NAME argument to `pathconf' and `fpathconf'. */ +enum + { + _PC_LINK_MAX, +#define _PC_LINK_MAX _PC_LINK_MAX + _PC_MAX_CANON, +#define _PC_MAX_CANON _PC_MAX_CANON + _PC_MAX_INPUT, +#define _PC_MAX_INPUT _PC_MAX_INPUT + _PC_NAME_MAX, +#define _PC_NAME_MAX _PC_NAME_MAX + _PC_PATH_MAX, +#define _PC_PATH_MAX _PC_PATH_MAX + _PC_PIPE_BUF, +#define _PC_PIPE_BUF _PC_PIPE_BUF + _PC_CHOWN_RESTRICTED, +#define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED + _PC_NO_TRUNC, +#define _PC_NO_TRUNC _PC_NO_TRUNC + _PC_VDISABLE, +#define _PC_VDISABLE _PC_VDISABLE + _PC_SYNC_IO, +#define _PC_SYNC_IO _PC_SYNC_IO + _PC_ASYNC_IO, +#define _PC_ASYNC_IO _PC_ASYNC_IO + _PC_PRIO_IO, +#define _PC_PRIO_IO _PC_PRIO_IO + _PC_SOCK_MAXBUF, +#define _PC_SOCK_MAXBUF _PC_SOCK_MAXBUF + _PC_FILESIZEBITS, +#define _PC_FILESIZEBITS _PC_FILESIZEBITS + _PC_REC_INCR_XFER_SIZE, +#define _PC_REC_INCR_XFER_SIZE _PC_REC_INCR_XFER_SIZE + _PC_REC_MAX_XFER_SIZE, +#define _PC_REC_MAX_XFER_SIZE _PC_REC_MAX_XFER_SIZE + _PC_REC_MIN_XFER_SIZE, +#define _PC_REC_MIN_XFER_SIZE _PC_REC_MIN_XFER_SIZE + _PC_REC_XFER_ALIGN, +#define _PC_REC_XFER_ALIGN _PC_REC_XFER_ALIGN + _PC_ALLOC_SIZE_MIN, +#define _PC_ALLOC_SIZE_MIN _PC_ALLOC_SIZE_MIN + _PC_SYMLINK_MAX, +#define _PC_SYMLINK_MAX _PC_SYMLINK_MAX + _PC_2_SYMLINKS +#define _PC_2_SYMLINKS _PC_2_SYMLINKS + }; + +/* Values for the argument to `sysconf'. */ +enum + { + _SC_ARG_MAX, +#define _SC_ARG_MAX _SC_ARG_MAX + _SC_CHILD_MAX, +#define _SC_CHILD_MAX _SC_CHILD_MAX + _SC_CLK_TCK, +#define _SC_CLK_TCK _SC_CLK_TCK + _SC_NGROUPS_MAX, +#define _SC_NGROUPS_MAX _SC_NGROUPS_MAX + _SC_OPEN_MAX, +#define _SC_OPEN_MAX _SC_OPEN_MAX + _SC_STREAM_MAX, +#define _SC_STREAM_MAX _SC_STREAM_MAX + _SC_TZNAME_MAX, +#define _SC_TZNAME_MAX _SC_TZNAME_MAX + _SC_JOB_CONTROL, +#define _SC_JOB_CONTROL _SC_JOB_CONTROL + _SC_SAVED_IDS, +#define _SC_SAVED_IDS _SC_SAVED_IDS + _SC_REALTIME_SIGNALS, +#define _SC_REALTIME_SIGNALS _SC_REALTIME_SIGNALS + _SC_PRIORITY_SCHEDULING, +#define _SC_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING + _SC_TIMERS, +#define _SC_TIMERS _SC_TIMERS + _SC_ASYNCHRONOUS_IO, +#define _SC_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO + _SC_PRIORITIZED_IO, +#define _SC_PRIORITIZED_IO _SC_PRIORITIZED_IO + _SC_SYNCHRONIZED_IO, +#define _SC_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO + _SC_FSYNC, +#define _SC_FSYNC _SC_FSYNC + _SC_MAPPED_FILES, +#define _SC_MAPPED_FILES _SC_MAPPED_FILES + _SC_MEMLOCK, +#define _SC_MEMLOCK _SC_MEMLOCK + _SC_MEMLOCK_RANGE, +#define _SC_MEMLOCK_RANGE _SC_MEMLOCK_RANGE + _SC_MEMORY_PROTECTION, +#define _SC_MEMORY_PROTECTION _SC_MEMORY_PROTECTION + _SC_MESSAGE_PASSING, +#define _SC_MESSAGE_PASSING _SC_MESSAGE_PASSING + _SC_SEMAPHORES, +#define _SC_SEMAPHORES _SC_SEMAPHORES + _SC_SHARED_MEMORY_OBJECTS, +#define _SC_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS + _SC_AIO_LISTIO_MAX, +#define _SC_AIO_LISTIO_MAX _SC_AIO_LISTIO_MAX + _SC_AIO_MAX, +#define _SC_AIO_MAX _SC_AIO_MAX + _SC_AIO_PRIO_DELTA_MAX, +#define _SC_AIO_PRIO_DELTA_MAX _SC_AIO_PRIO_DELTA_MAX + _SC_DELAYTIMER_MAX, +#define _SC_DELAYTIMER_MAX _SC_DELAYTIMER_MAX + _SC_MQ_OPEN_MAX, +#define _SC_MQ_OPEN_MAX _SC_MQ_OPEN_MAX + _SC_MQ_PRIO_MAX, +#define _SC_MQ_PRIO_MAX _SC_MQ_PRIO_MAX + _SC_VERSION, +#define _SC_VERSION _SC_VERSION + _SC_PAGESIZE, +#define _SC_PAGESIZE _SC_PAGESIZE +#define _SC_PAGE_SIZE _SC_PAGESIZE + _SC_RTSIG_MAX, +#define _SC_RTSIG_MAX _SC_RTSIG_MAX + _SC_SEM_NSEMS_MAX, +#define _SC_SEM_NSEMS_MAX _SC_SEM_NSEMS_MAX + _SC_SEM_VALUE_MAX, +#define _SC_SEM_VALUE_MAX _SC_SEM_VALUE_MAX + _SC_SIGQUEUE_MAX, +#define _SC_SIGQUEUE_MAX _SC_SIGQUEUE_MAX + _SC_TIMER_MAX, +#define _SC_TIMER_MAX _SC_TIMER_MAX + + /* Values for the argument to `sysconf' + corresponding to _POSIX2_* symbols. */ + _SC_BC_BASE_MAX, +#define _SC_BC_BASE_MAX _SC_BC_BASE_MAX + _SC_BC_DIM_MAX, +#define _SC_BC_DIM_MAX _SC_BC_DIM_MAX + _SC_BC_SCALE_MAX, +#define _SC_BC_SCALE_MAX _SC_BC_SCALE_MAX + _SC_BC_STRING_MAX, +#define _SC_BC_STRING_MAX _SC_BC_STRING_MAX + _SC_COLL_WEIGHTS_MAX, +#define _SC_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX + _SC_EQUIV_CLASS_MAX, +#define _SC_EQUIV_CLASS_MAX _SC_EQUIV_CLASS_MAX + _SC_EXPR_NEST_MAX, +#define _SC_EXPR_NEST_MAX _SC_EXPR_NEST_MAX + _SC_LINE_MAX, +#define _SC_LINE_MAX _SC_LINE_MAX + _SC_RE_DUP_MAX, +#define _SC_RE_DUP_MAX _SC_RE_DUP_MAX + _SC_CHARCLASS_NAME_MAX, +#define _SC_CHARCLASS_NAME_MAX _SC_CHARCLASS_NAME_MAX + + _SC_2_VERSION, +#define _SC_2_VERSION _SC_2_VERSION + _SC_2_C_BIND, +#define _SC_2_C_BIND _SC_2_C_BIND + _SC_2_C_DEV, +#define _SC_2_C_DEV _SC_2_C_DEV + _SC_2_FORT_DEV, +#define _SC_2_FORT_DEV _SC_2_FORT_DEV + _SC_2_FORT_RUN, +#define _SC_2_FORT_RUN _SC_2_FORT_RUN + _SC_2_SW_DEV, +#define _SC_2_SW_DEV _SC_2_SW_DEV + _SC_2_LOCALEDEF, +#define _SC_2_LOCALEDEF _SC_2_LOCALEDEF + + _SC_PII, +#define _SC_PII _SC_PII + _SC_PII_XTI, +#define _SC_PII_XTI _SC_PII_XTI + _SC_PII_SOCKET, +#define _SC_PII_SOCKET _SC_PII_SOCKET + _SC_PII_INTERNET, +#define _SC_PII_INTERNET _SC_PII_INTERNET + _SC_PII_OSI, +#define _SC_PII_OSI _SC_PII_OSI + _SC_POLL, +#define _SC_POLL _SC_POLL + _SC_SELECT, +#define _SC_SELECT _SC_SELECT + _SC_UIO_MAXIOV, +#define _SC_UIO_MAXIOV _SC_UIO_MAXIOV + _SC_IOV_MAX = _SC_UIO_MAXIOV, +#define _SC_IOV_MAX _SC_IOV_MAX + _SC_PII_INTERNET_STREAM, +#define _SC_PII_INTERNET_STREAM _SC_PII_INTERNET_STREAM + _SC_PII_INTERNET_DGRAM, +#define _SC_PII_INTERNET_DGRAM _SC_PII_INTERNET_DGRAM + _SC_PII_OSI_COTS, +#define _SC_PII_OSI_COTS _SC_PII_OSI_COTS + _SC_PII_OSI_CLTS, +#define _SC_PII_OSI_CLTS _SC_PII_OSI_CLTS + _SC_PII_OSI_M, +#define _SC_PII_OSI_M _SC_PII_OSI_M + _SC_T_IOV_MAX, +#define _SC_T_IOV_MAX _SC_T_IOV_MAX + + /* Values according to POSIX 1003.1c (POSIX threads). */ + _SC_THREADS, +#define _SC_THREADS _SC_THREADS + _SC_THREAD_SAFE_FUNCTIONS, +#define _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS + _SC_GETGR_R_SIZE_MAX, +#define _SC_GETGR_R_SIZE_MAX _SC_GETGR_R_SIZE_MAX + _SC_GETPW_R_SIZE_MAX, +#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX + _SC_LOGIN_NAME_MAX, +#define _SC_LOGIN_NAME_MAX _SC_LOGIN_NAME_MAX + _SC_TTY_NAME_MAX, +#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX + _SC_THREAD_DESTRUCTOR_ITERATIONS, +#define _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS + _SC_THREAD_KEYS_MAX, +#define _SC_THREAD_KEYS_MAX _SC_THREAD_KEYS_MAX + _SC_THREAD_STACK_MIN, +#define _SC_THREAD_STACK_MIN _SC_THREAD_STACK_MIN + _SC_THREAD_THREADS_MAX, +#define _SC_THREAD_THREADS_MAX _SC_THREAD_THREADS_MAX + _SC_THREAD_ATTR_STACKADDR, +#define _SC_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR + _SC_THREAD_ATTR_STACKSIZE, +#define _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE + _SC_THREAD_PRIORITY_SCHEDULING, +#define _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING + _SC_THREAD_PRIO_INHERIT, +#define _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT + _SC_THREAD_PRIO_PROTECT, +#define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT + _SC_THREAD_PROCESS_SHARED, +#define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED + + _SC_NPROCESSORS_CONF, +#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF + _SC_NPROCESSORS_ONLN, +#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN + _SC_PHYS_PAGES, +#define _SC_PHYS_PAGES _SC_PHYS_PAGES + _SC_AVPHYS_PAGES, +#define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES + _SC_ATEXIT_MAX, +#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX + _SC_PASS_MAX, +#define _SC_PASS_MAX _SC_PASS_MAX + + _SC_XOPEN_VERSION, +#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION + _SC_XOPEN_XCU_VERSION, +#define _SC_XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION + _SC_XOPEN_UNIX, +#define _SC_XOPEN_UNIX _SC_XOPEN_UNIX + _SC_XOPEN_CRYPT, +#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT + _SC_XOPEN_ENH_I18N, +#define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N + _SC_XOPEN_SHM, +#define _SC_XOPEN_SHM _SC_XOPEN_SHM + + _SC_2_CHAR_TERM, +#define _SC_2_CHAR_TERM _SC_2_CHAR_TERM + _SC_2_C_VERSION, +#define _SC_2_C_VERSION _SC_2_C_VERSION + _SC_2_UPE, +#define _SC_2_UPE _SC_2_UPE + + _SC_XOPEN_XPG2, +#define _SC_XOPEN_XPG2 _SC_XOPEN_XPG2 + _SC_XOPEN_XPG3, +#define _SC_XOPEN_XPG3 _SC_XOPEN_XPG3 + _SC_XOPEN_XPG4, +#define _SC_XOPEN_XPG4 _SC_XOPEN_XPG4 + + _SC_CHAR_BIT, +#define _SC_CHAR_BIT _SC_CHAR_BIT + _SC_CHAR_MAX, +#define _SC_CHAR_MAX _SC_CHAR_MAX + _SC_CHAR_MIN, +#define _SC_CHAR_MIN _SC_CHAR_MIN + _SC_INT_MAX, +#define _SC_INT_MAX _SC_INT_MAX + _SC_INT_MIN, +#define _SC_INT_MIN _SC_INT_MIN + _SC_LONG_BIT, +#define _SC_LONG_BIT _SC_LONG_BIT + _SC_WORD_BIT, +#define _SC_WORD_BIT _SC_WORD_BIT + _SC_MB_LEN_MAX, +#define _SC_MB_LEN_MAX _SC_MB_LEN_MAX + _SC_NZERO, +#define _SC_NZERO _SC_NZERO + _SC_SSIZE_MAX, +#define _SC_SSIZE_MAX _SC_SSIZE_MAX + _SC_SCHAR_MAX, +#define _SC_SCHAR_MAX _SC_SCHAR_MAX + _SC_SCHAR_MIN, +#define _SC_SCHAR_MIN _SC_SCHAR_MIN + _SC_SHRT_MAX, +#define _SC_SHRT_MAX _SC_SHRT_MAX + _SC_SHRT_MIN, +#define _SC_SHRT_MIN _SC_SHRT_MIN + _SC_UCHAR_MAX, +#define _SC_UCHAR_MAX _SC_UCHAR_MAX + _SC_UINT_MAX, +#define _SC_UINT_MAX _SC_UINT_MAX + _SC_ULONG_MAX, +#define _SC_ULONG_MAX _SC_ULONG_MAX + _SC_USHRT_MAX, +#define _SC_USHRT_MAX _SC_USHRT_MAX + + _SC_NL_ARGMAX, +#define _SC_NL_ARGMAX _SC_NL_ARGMAX + _SC_NL_LANGMAX, +#define _SC_NL_LANGMAX _SC_NL_LANGMAX + _SC_NL_MSGMAX, +#define _SC_NL_MSGMAX _SC_NL_MSGMAX + _SC_NL_NMAX, +#define _SC_NL_NMAX _SC_NL_NMAX + _SC_NL_SETMAX, +#define _SC_NL_SETMAX _SC_NL_SETMAX + _SC_NL_TEXTMAX, +#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX + + _SC_XBS5_ILP32_OFF32, +#define _SC_XBS5_ILP32_OFF32 _SC_XBS5_ILP32_OFF32 + _SC_XBS5_ILP32_OFFBIG, +#define _SC_XBS5_ILP32_OFFBIG _SC_XBS5_ILP32_OFFBIG + _SC_XBS5_LP64_OFF64, +#define _SC_XBS5_LP64_OFF64 _SC_XBS5_LP64_OFF64 + _SC_XBS5_LPBIG_OFFBIG, +#define _SC_XBS5_LPBIG_OFFBIG _SC_XBS5_LPBIG_OFFBIG + + _SC_XOPEN_LEGACY, +#define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY + _SC_XOPEN_REALTIME, +#define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME + _SC_XOPEN_REALTIME_THREADS, +#define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS + + _SC_ADVISORY_INFO, +#define _SC_ADVISORY_INFO _SC_ADVISORY_INFO + _SC_BARRIERS, +#define _SC_BARRIERS _SC_BARRIERS + _SC_BASE, +#define _SC_BASE _SC_BASE + _SC_C_LANG_SUPPORT, +#define _SC_C_LANG_SUPPORT _SC_C_LANG_SUPPORT + _SC_C_LANG_SUPPORT_R, +#define _SC_C_LANG_SUPPORT_R _SC_C_LANG_SUPPORT_R + _SC_CLOCK_SELECTION, +#define _SC_CLOCK_SELECTION _SC_CLOCK_SELECTION + _SC_CPUTIME, +#define _SC_CPUTIME _SC_CPUTIME + _SC_THREAD_CPUTIME, +#define _SC_THREAD_CPUTIME _SC_THREAD_CPUTIME + _SC_DEVICE_IO, +#define _SC_DEVICE_IO _SC_DEVICE_IO + _SC_DEVICE_SPECIFIC, +#define _SC_DEVICE_SPECIFIC _SC_DEVICE_SPECIFIC + _SC_DEVICE_SPECIFIC_R, +#define _SC_DEVICE_SPECIFIC_R _SC_DEVICE_SPECIFIC_R + _SC_FD_MGMT, +#define _SC_FD_MGMT _SC_FD_MGMT + _SC_FIFO, +#define _SC_FIFO _SC_FIFO + _SC_PIPE, +#define _SC_PIPE _SC_PIPE + _SC_FILE_ATTRIBUTES, +#define _SC_FILE_ATTRIBUTES _SC_FILE_ATTRIBUTES + _SC_FILE_LOCKING, +#define _SC_FILE_LOCKING _SC_FILE_LOCKING + _SC_FILE_SYSTEM, +#define _SC_FILE_SYSTEM _SC_FILE_SYSTEM + _SC_MONOTONIC_CLOCK, +#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK + _SC_MULTI_PROCESS, +#define _SC_MULTI_PROCESS _SC_MULTI_PROCESS + _SC_SINGLE_PROCESS, +#define _SC_SINGLE_PROCESS _SC_SINGLE_PROCESS + _SC_NETWORKING, +#define _SC_NETWORKING _SC_NETWORKING + _SC_READER_WRITER_LOCKS, +#define _SC_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS + _SC_SPIN_LOCKS, +#define _SC_SPIN_LOCKS _SC_SPIN_LOCKS + _SC_REGEXP, +#define _SC_REGEXP _SC_REGEXP + _SC_REGEX_VERSION, +#define _SC_REGEX_VERSION _SC_REGEX_VERSION + _SC_SHELL, +#define _SC_SHELL _SC_SHELL + _SC_SIGNALS, +#define _SC_SIGNALS _SC_SIGNALS + _SC_SPAWN, +#define _SC_SPAWN _SC_SPAWN + _SC_SPORADIC_SERVER, +#define _SC_SPORADIC_SERVER _SC_SPORADIC_SERVER + _SC_THREAD_SPORADIC_SERVER, +#define _SC_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER + _SC_SYSTEM_DATABASE, +#define _SC_SYSTEM_DATABASE _SC_SYSTEM_DATABASE + _SC_SYSTEM_DATABASE_R, +#define _SC_SYSTEM_DATABASE_R _SC_SYSTEM_DATABASE_R + _SC_TIMEOUTS, +#define _SC_TIMEOUTS _SC_TIMEOUTS + _SC_TYPED_MEMORY_OBJECTS, +#define _SC_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS + _SC_USER_GROUPS, +#define _SC_USER_GROUPS _SC_USER_GROUPS + _SC_USER_GROUPS_R, +#define _SC_USER_GROUPS_R _SC_USER_GROUPS_R + _SC_2_PBS, +#define _SC_2_PBS _SC_2_PBS + _SC_2_PBS_ACCOUNTING, +#define _SC_2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING + _SC_2_PBS_LOCATE, +#define _SC_2_PBS_LOCATE _SC_2_PBS_LOCATE + _SC_2_PBS_MESSAGE, +#define _SC_2_PBS_MESSAGE _SC_2_PBS_MESSAGE + _SC_2_PBS_TRACK, +#define _SC_2_PBS_TRACK _SC_2_PBS_TRACK + _SC_SYMLOOP_MAX, +#define _SC_SYMLOOP_MAX _SC_SYMLOOP_MAX + _SC_STREAMS, +#define _SC_STREAMS _SC_STREAMS + _SC_2_PBS_CHECKPOINT, +#define _SC_2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT + + _SC_V6_ILP32_OFF32, +#define _SC_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32 + _SC_V6_ILP32_OFFBIG, +#define _SC_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG + _SC_V6_LP64_OFF64, +#define _SC_V6_LP64_OFF64 _SC_V6_LP64_OFF64 + _SC_V6_LPBIG_OFFBIG, +#define _SC_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG + + _SC_HOST_NAME_MAX, +#define _SC_HOST_NAME_MAX _SC_HOST_NAME_MAX + _SC_TRACE, +#define _SC_TRACE _SC_TRACE + _SC_TRACE_EVENT_FILTER, +#define _SC_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER + _SC_TRACE_INHERIT, +#define _SC_TRACE_INHERIT _SC_TRACE_INHERIT + _SC_TRACE_LOG, +#define _SC_TRACE_LOG _SC_TRACE_LOG + + _SC_LEVEL1_ICACHE_SIZE, +#define _SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_SIZE + _SC_LEVEL1_ICACHE_ASSOC, +#define _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_ASSOC + _SC_LEVEL1_ICACHE_LINESIZE, +#define _SC_LEVEL1_ICACHE_LINESIZE _SC_LEVEL1_ICACHE_LINESIZE + _SC_LEVEL1_DCACHE_SIZE, +#define _SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_SIZE + _SC_LEVEL1_DCACHE_ASSOC, +#define _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_ASSOC + _SC_LEVEL1_DCACHE_LINESIZE, +#define _SC_LEVEL1_DCACHE_LINESIZE _SC_LEVEL1_DCACHE_LINESIZE + _SC_LEVEL2_CACHE_SIZE, +#define _SC_LEVEL2_CACHE_SIZE _SC_LEVEL2_CACHE_SIZE + _SC_LEVEL2_CACHE_ASSOC, +#define _SC_LEVEL2_CACHE_ASSOC _SC_LEVEL2_CACHE_ASSOC + _SC_LEVEL2_CACHE_LINESIZE, +#define _SC_LEVEL2_CACHE_LINESIZE _SC_LEVEL2_CACHE_LINESIZE + _SC_LEVEL3_CACHE_SIZE, +#define _SC_LEVEL3_CACHE_SIZE _SC_LEVEL3_CACHE_SIZE + _SC_LEVEL3_CACHE_ASSOC, +#define _SC_LEVEL3_CACHE_ASSOC _SC_LEVEL3_CACHE_ASSOC + _SC_LEVEL3_CACHE_LINESIZE, +#define _SC_LEVEL3_CACHE_LINESIZE _SC_LEVEL3_CACHE_LINESIZE + _SC_LEVEL4_CACHE_SIZE, +#define _SC_LEVEL4_CACHE_SIZE _SC_LEVEL4_CACHE_SIZE + _SC_LEVEL4_CACHE_ASSOC, +#define _SC_LEVEL4_CACHE_ASSOC _SC_LEVEL4_CACHE_ASSOC + _SC_LEVEL4_CACHE_LINESIZE, +#define _SC_LEVEL4_CACHE_LINESIZE _SC_LEVEL4_CACHE_LINESIZE + /* Leave room here, maybe we need a few more cache levels some day. */ + + _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50, +#define _SC_IPV6 _SC_IPV6 + _SC_RAW_SOCKETS, +#define _SC_RAW_SOCKETS _SC_RAW_SOCKETS + + _SC_V7_ILP32_OFF32, +#define _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFF32 + _SC_V7_ILP32_OFFBIG, +#define _SC_V7_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG + _SC_V7_LP64_OFF64, +#define _SC_V7_LP64_OFF64 _SC_V7_LP64_OFF64 + _SC_V7_LPBIG_OFFBIG, +#define _SC_V7_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG + + _SC_SS_REPL_MAX, +#define _SC_SS_REPL_MAX _SC_SS_REPL_MAX + + _SC_TRACE_EVENT_NAME_MAX, +#define _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_EVENT_NAME_MAX + _SC_TRACE_NAME_MAX, +#define _SC_TRACE_NAME_MAX _SC_TRACE_NAME_MAX + _SC_TRACE_SYS_MAX, +#define _SC_TRACE_SYS_MAX _SC_TRACE_SYS_MAX + _SC_TRACE_USER_EVENT_MAX, +#define _SC_TRACE_USER_EVENT_MAX _SC_TRACE_USER_EVENT_MAX + + _SC_XOPEN_STREAMS, +#define _SC_XOPEN_STREAMS _SC_XOPEN_STREAMS + + _SC_THREAD_ROBUST_PRIO_INHERIT, +#define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT + _SC_THREAD_ROBUST_PRIO_PROTECT, +#define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT + + _SC_MINSIGSTKSZ, +#define _SC_MINSIGSTKSZ _SC_MINSIGSTKSZ + + _SC_SIGSTKSZ +#define _SC_SIGSTKSZ _SC_SIGSTKSZ + }; + +/* Values for the NAME argument to `confstr'. */ +enum + { + _CS_PATH, /* The default search path. */ +#define _CS_PATH _CS_PATH + + _CS_V6_WIDTH_RESTRICTED_ENVS, +#define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS +#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS + + _CS_GNU_LIBC_VERSION, +#define _CS_GNU_LIBC_VERSION _CS_GNU_LIBC_VERSION + _CS_GNU_LIBPTHREAD_VERSION, +#define _CS_GNU_LIBPTHREAD_VERSION _CS_GNU_LIBPTHREAD_VERSION + + _CS_V5_WIDTH_RESTRICTED_ENVS, +#define _CS_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS +#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS + + _CS_V7_WIDTH_RESTRICTED_ENVS, +#define _CS_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS +#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS + + _CS_LFS_CFLAGS = 1000, +#define _CS_LFS_CFLAGS _CS_LFS_CFLAGS + _CS_LFS_LDFLAGS, +#define _CS_LFS_LDFLAGS _CS_LFS_LDFLAGS + _CS_LFS_LIBS, +#define _CS_LFS_LIBS _CS_LFS_LIBS + _CS_LFS_LINTFLAGS, +#define _CS_LFS_LINTFLAGS _CS_LFS_LINTFLAGS + _CS_LFS64_CFLAGS, +#define _CS_LFS64_CFLAGS _CS_LFS64_CFLAGS + _CS_LFS64_LDFLAGS, +#define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS + _CS_LFS64_LIBS, +#define _CS_LFS64_LIBS _CS_LFS64_LIBS + _CS_LFS64_LINTFLAGS, +#define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS + + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100, +#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS + _CS_XBS5_ILP32_OFF32_LDFLAGS, +#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS + _CS_XBS5_ILP32_OFF32_LIBS, +#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS + _CS_XBS5_ILP32_OFF32_LINTFLAGS, +#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS + _CS_XBS5_ILP32_OFFBIG_CFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS + _CS_XBS5_ILP32_OFFBIG_LDFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS + _CS_XBS5_ILP32_OFFBIG_LIBS, +#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS + _CS_XBS5_LP64_OFF64_CFLAGS, +#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS + _CS_XBS5_LP64_OFF64_LDFLAGS, +#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS + _CS_XBS5_LP64_OFF64_LIBS, +#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS + _CS_XBS5_LP64_OFF64_LINTFLAGS, +#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS + _CS_XBS5_LPBIG_OFFBIG_CFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS + _CS_XBS5_LPBIG_OFFBIG_LIBS, +#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS + + _CS_POSIX_V6_ILP32_OFF32_CFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS + _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS + _CS_POSIX_V6_ILP32_OFF32_LIBS, +#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS + _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_LIBS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS + _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS + _CS_POSIX_V6_LP64_OFF64_CFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS + _CS_POSIX_V6_LP64_OFF64_LDFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS + _CS_POSIX_V6_LP64_OFF64_LIBS, +#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS + _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS + _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS + + _CS_POSIX_V7_ILP32_OFF32_CFLAGS, +#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS + _CS_POSIX_V7_ILP32_OFF32_LDFLAGS, +#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS + _CS_POSIX_V7_ILP32_OFF32_LIBS, +#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS + _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS, +#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS + _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS, +#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS + _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS, +#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS + _CS_POSIX_V7_ILP32_OFFBIG_LIBS, +#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS + _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS, +#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS + _CS_POSIX_V7_LP64_OFF64_CFLAGS, +#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS + _CS_POSIX_V7_LP64_OFF64_LDFLAGS, +#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS + _CS_POSIX_V7_LP64_OFF64_LIBS, +#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS + _CS_POSIX_V7_LP64_OFF64_LINTFLAGS, +#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS + _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS, +#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS + _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS, +#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS + _CS_POSIX_V7_LPBIG_OFFBIG_LIBS, +#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS + _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS, +#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS + + _CS_V6_ENV, +#define _CS_V6_ENV _CS_V6_ENV + _CS_V7_ENV +#define _CS_V7_ENV _CS_V7_ENV + }; diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f021bcd9fbed8b830f475e00576b3b849c885452 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@confname.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h new file mode 100644 index 0000000000000000000000000000000000000000..afc1622f7ea4063ea1bd84e20d491d72e378376c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h @@ -0,0 +1,124 @@ +/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993 + scheduling interface. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_CPU_SET_H +#define _BITS_CPU_SET_H 1 + +#ifndef _SCHED_H +# error "Never include directly; use instead." +#endif + +/* Size definition for CPU sets. */ +#define __CPU_SETSIZE 1024 +#define __NCPUBITS (8 * sizeof (__cpu_mask)) + +/* Type for array elements in 'cpu_set_t'. */ +typedef __CPU_MASK_TYPE __cpu_mask; + +/* Basic access functions. */ +#define __CPUELT(cpu) ((cpu) / __NCPUBITS) +#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS)) + +/* Data structure to describe CPU mask. */ +typedef struct +{ + __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS]; +} cpu_set_t; + +/* Access functions for CPU masks. */ +#if __GNUC_PREREQ (2, 91) +# define __CPU_ZERO_S(setsize, cpusetp) \ + do __builtin_memset (cpusetp, '\0', setsize); while (0) +#else +# define __CPU_ZERO_S(setsize, cpusetp) \ + do { \ + size_t __i; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ + __cpu_mask *__bits = (cpusetp)->__bits; \ + for (__i = 0; __i < __imax; ++__i) \ + __bits[__i] = 0; \ + } while (0) +#endif +#define __CPU_SET_S(cpu, setsize, cpusetp) \ + (__extension__ \ + ({ size_t __cpu = (cpu); \ + __cpu / 8 < (setsize) \ + ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ + |= __CPUMASK (__cpu)) \ + : 0; })) +#define __CPU_CLR_S(cpu, setsize, cpusetp) \ + (__extension__ \ + ({ size_t __cpu = (cpu); \ + __cpu / 8 < (setsize) \ + ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ + &= ~__CPUMASK (__cpu)) \ + : 0; })) +#define __CPU_ISSET_S(cpu, setsize, cpusetp) \ + (__extension__ \ + ({ size_t __cpu = (cpu); \ + __cpu / 8 < (setsize) \ + ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ + & __CPUMASK (__cpu))) != 0 \ + : 0; })) + +#define __CPU_COUNT_S(setsize, cpusetp) \ + __sched_cpucount (setsize, cpusetp) + +#if __GNUC_PREREQ (2, 91) +# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ + (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0) +#else +# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ + (__extension__ \ + ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \ + const __cpu_mask *__arr2 = (cpusetp2)->__bits; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ + size_t __i; \ + for (__i = 0; __i < __imax; ++__i) \ + if (__arr1[__i] != __arr2[__i]) \ + break; \ + __i == __imax; })) +#endif + +#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \ + (__extension__ \ + ({ cpu_set_t *__dest = (destset); \ + const __cpu_mask *__arr1 = (srcset1)->__bits; \ + const __cpu_mask *__arr2 = (srcset2)->__bits; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ + size_t __i; \ + for (__i = 0; __i < __imax; ++__i) \ + ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \ + __dest; })) + +#define __CPU_ALLOC_SIZE(count) \ + ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask)) +#define __CPU_ALLOC(count) __sched_cpualloc (count) +#define __CPU_FREE(cpuset) __sched_cpufree (cpuset) + +__BEGIN_DECLS + +extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp) + __THROW; +extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur; +extern void __sched_cpufree (cpu_set_t *__set) __THROW; + +__END_DECLS + +#endif /* bits/cpu-set.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b94e6906c1e6546903b133f0e1ca1ea28a2e6cb2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@cpu-set.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h new file mode 100644 index 0000000000000000000000000000000000000000..1160e899d1a9d652635ff114ae3e59f0cdfbf688 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h @@ -0,0 +1,49 @@ +/* Endian macros for string.h functions + Copyright (C) 1992-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_ENDIAN_H +#define _BITS_ENDIAN_H 1 + +/* Definitions for byte order, according to significance of bytes, + from low addresses to high addresses. The value is what you get by + putting '4' in the most significant byte, '3' in the second most + significant byte, '2' in the second least significant byte, and '1' + in the least significant byte, and then writing down one digit for + each byte, starting with the byte at the lowest address at the left, + and proceeding to the byte with the highest address at the right. */ + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 + +/* This file defines `__BYTE_ORDER' for the particular machine. */ +#include + +/* Some machines may need to use a different endianness for floating point + values. */ +#ifndef __FLOAT_WORD_ORDER +# define __FLOAT_WORD_ORDER __BYTE_ORDER +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) LO, HI +#elif __BYTE_ORDER == __BIG_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) HI, LO +#endif + +#endif /* bits/endian.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d1f9f500eed6794aa32f0039c1f3d236b3ad944a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endian.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h new file mode 100644 index 0000000000000000000000000000000000000000..962a9ae4d6e9e012b82ab31fe2f567efb6c4c001 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h @@ -0,0 +1,11 @@ +#ifndef _BITS_ENDIANNESS_H +#define _BITS_ENDIANNESS_H 1 + +#ifndef _BITS_ENDIAN_H +# error "Never use directly; include instead." +#endif + +/* i386/x86_64 are little-endian. */ +#define __BYTE_ORDER __LITTLE_ENDIAN + +#endif /* bits/endianness.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0d9687831b7511ceeb3d48841d778623c9b710a1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@endianness.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h new file mode 100644 index 0000000000000000000000000000000000000000..7b8604353158524b4631d88738c172ad2a180a15 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h @@ -0,0 +1,105 @@ +/* Copyright (C) 1999-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _UNISTD_H +# error "Never include this file directly. Use instead" +#endif + +#include + +/* This header should define the following symbols under the described + situations. A value `1' means that the model is always supported, + `-1' means it is never supported. Undefined means it cannot be + statically decided. + + _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type + _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type + + _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type + _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type + + The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, + _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, + _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were + used in previous versions of the Unix standard and are available + only for compatibility. +*/ + +#if __WORDSIZE == 64 + +/* Environments with 32-bit wide pointers are optionally provided. + Therefore following macros aren't defined: + # undef _POSIX_V7_ILP32_OFF32 + # undef _POSIX_V7_ILP32_OFFBIG + # undef _POSIX_V6_ILP32_OFF32 + # undef _POSIX_V6_ILP32_OFFBIG + # undef _XBS5_ILP32_OFF32 + # undef _XBS5_ILP32_OFFBIG + and users need to check at runtime. */ + +/* We also have no use (for now) for an environment with bigger pointers + and offsets. */ +# define _POSIX_V7_LPBIG_OFFBIG -1 +# define _POSIX_V6_LPBIG_OFFBIG -1 +# define _XBS5_LPBIG_OFFBIG -1 + +/* By default we have 64-bit wide `long int', pointers and `off_t'. */ +# define _POSIX_V7_LP64_OFF64 1 +# define _POSIX_V6_LP64_OFF64 1 +# define _XBS5_LP64_OFF64 1 + +#else /* __WORDSIZE == 32 */ + +/* We have 32-bit wide `int', `long int' and pointers and all platforms + support LFS. -mx32 has 64-bit wide `off_t'. */ +# define _POSIX_V7_ILP32_OFFBIG 1 +# define _POSIX_V6_ILP32_OFFBIG 1 +# define _XBS5_ILP32_OFFBIG 1 + +# ifndef __x86_64__ +/* -m32 has 32-bit wide `off_t'. */ +# define _POSIX_V7_ILP32_OFF32 1 +# define _POSIX_V6_ILP32_OFF32 1 +# define _XBS5_ILP32_OFF32 1 +# endif + +/* We optionally provide an environment with the above size but an 64-bit + side `off_t'. Therefore we don't define _POSIX_V7_ILP32_OFFBIG. */ + +/* Environments with 64-bit wide pointers can be provided, + so these macros aren't defined: + # undef _POSIX_V7_LP64_OFF64 + # undef _POSIX_V7_LPBIG_OFFBIG + # undef _POSIX_V6_LP64_OFF64 + # undef _POSIX_V6_LPBIG_OFFBIG + # undef _XBS5_LP64_OFF64 + # undef _XBS5_LPBIG_OFFBIG + and sysconf tests for it at runtime. */ + +#endif /* __WORDSIZE == 32 */ + +#define __ILP32_OFF32_CFLAGS "-m32" +#define __ILP32_OFF32_LDFLAGS "-m32" +#if defined __x86_64__ && defined __ILP32__ +# define __ILP32_OFFBIG_CFLAGS "-mx32" +# define __ILP32_OFFBIG_LDFLAGS "-mx32" +#else +# define __ILP32_OFFBIG_CFLAGS "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +# define __ILP32_OFFBIG_LDFLAGS "-m32" +#endif +#define __LP64_OFF64_CFLAGS "-m64" +#define __LP64_OFF64_LDFLAGS "-m64" diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..10da840c1779bfb813bce0d092c9ea381d58d193 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@environments.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h new file mode 100644 index 0000000000000000000000000000000000000000..77907123e2ed912b8f1710bfd5906c8b2fd99a47 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h @@ -0,0 +1,53 @@ +/* Error constants. Linux specific version. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_ERRNO_H +#define _BITS_ERRNO_H 1 + +#if !defined _ERRNO_H +# error "Never include directly; use instead." +#endif + +# include + +/* Older Linux headers do not define these constants. */ +# ifndef ENOTSUP +# define ENOTSUP EOPNOTSUPP +# endif + +# ifndef ECANCELED +# define ECANCELED 125 +# endif + +# ifndef EOWNERDEAD +# define EOWNERDEAD 130 +# endif + +#ifndef ENOTRECOVERABLE +# define ENOTRECOVERABLE 131 +# endif + +# ifndef ERFKILL +# define ERFKILL 132 +# endif + +# ifndef EHWPOISON +# define EHWPOISON 133 +# endif + +#endif /* bits/errno.h. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8db998f6ed514123b5adaa06d23f87d202ff61d3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@errno.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h new file mode 100644 index 0000000000000000000000000000000000000000..34eeb14aff6a7a5d4d47cafb2cd9b8eab81c5842 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h @@ -0,0 +1,116 @@ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + +/* Define bits representing the exception. We use the bit positions + of the appropriate bits in the FPU control word. */ +enum + { + FE_INVALID = +#define FE_INVALID 0x01 + FE_INVALID, + __FE_DENORM = 0x02, + FE_DIVBYZERO = +#define FE_DIVBYZERO 0x04 + FE_DIVBYZERO, + FE_OVERFLOW = +#define FE_OVERFLOW 0x08 + FE_OVERFLOW, + FE_UNDERFLOW = +#define FE_UNDERFLOW 0x10 + FE_UNDERFLOW, + FE_INEXACT = +#define FE_INEXACT 0x20 + FE_INEXACT + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The ix87 FPU supports all of the four defined rounding modes. We + use again the bit positions in the FPU control word as the values + for the appropriate macros. */ +enum + { + FE_TONEAREST = +#define FE_TONEAREST 0 + FE_TONEAREST, + FE_DOWNWARD = +#define FE_DOWNWARD 0x400 + FE_DOWNWARD, + FE_UPWARD = +#define FE_UPWARD 0x800 + FE_UPWARD, + FE_TOWARDZERO = +#define FE_TOWARDZERO 0xc00 + FE_TOWARDZERO + }; + + +/* Type representing exception flags. */ +typedef unsigned short int fexcept_t; + + +/* Type representing floating-point environment. This structure + corresponds to the layout of the block written by the `fstenv' + instruction and has additional fields for the contents of the MXCSR + register as written by the `stmxcsr' instruction. */ +typedef struct + { + unsigned short int __control_word; + unsigned short int __glibc_reserved1; + unsigned short int __status_word; + unsigned short int __glibc_reserved2; + unsigned short int __tags; + unsigned short int __glibc_reserved3; + unsigned int __eip; + unsigned short int __cs_selector; + unsigned int __opcode:11; + unsigned int __glibc_reserved4:5; + unsigned int __data_offset; + unsigned short int __data_selector; + unsigned short int __glibc_reserved5; +#ifdef __x86_64__ + unsigned int __mxcsr; +#endif + } +fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((const fenv_t *) -1) + +#ifdef __USE_GNU +/* Floating-point environment where none of the exception is masked. */ +# define FE_NOMASK_ENV ((const fenv_t *) -2) +#endif + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* Type representing floating-point control modes. */ +typedef struct + { + unsigned short int __control_word; + unsigned short int __glibc_reserved; + unsigned int __mxcsr; + } +femode_t; + +/* Default floating-point control modes. */ +# define FE_DFL_MODE ((const femode_t *) -1L) +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..59f953ecc423f239578ab8820e0f10effa3b280b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fenv.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h new file mode 100644 index 0000000000000000000000000000000000000000..92982d64601bc562733ffd64f9e88854407c16c7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h @@ -0,0 +1,329 @@ +/* Macros to control TS 18661-3 glibc features where the same + definitions are appropriate for all platforms. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_FLOATN_COMMON_H +#define _BITS_FLOATN_COMMON_H + +#include +#include + +/* This header should be included at the bottom of each bits/floatn.h. + It defines the following macros for each _FloatN and _FloatNx type, + where the same definitions, or definitions based only on the macros + in bits/floatn.h, are appropriate for all glibc configurations. */ + +/* Defined to 1 if the current compiler invocation provides a + floating-point type with the right format for this type, and this + glibc includes corresponding *fN or *fNx interfaces for it. */ +#define __HAVE_FLOAT16 0 +#define __HAVE_FLOAT32 1 +#define __HAVE_FLOAT64 1 +#define __HAVE_FLOAT32X 1 +#define __HAVE_FLOAT128X 0 + +/* Defined to 1 if the corresponding __HAVE_ macro is 1 and the + type is the first with its format in the sequence of (the default + choices for) float, double, long double, _Float16, _Float32, + _Float64, _Float128, _Float32x, _Float64x, _Float128x for this + glibc; that is, if functions present once per floating-point format + rather than once per type are present for this type. + + All configurations supported by glibc have _Float32 the same format + as float, _Float64 and _Float32x the same format as double, the + _Float64x the same format as either long double or _Float128. No + configurations support _Float128x or, as of GCC 7, have compiler + support for a type meeting the requirements for _Float128x. */ +#define __HAVE_DISTINCT_FLOAT16 __HAVE_FLOAT16 +#define __HAVE_DISTINCT_FLOAT32 0 +#define __HAVE_DISTINCT_FLOAT64 0 +#define __HAVE_DISTINCT_FLOAT32X 0 +#define __HAVE_DISTINCT_FLOAT64X 0 +#define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X + +/* Defined to 1 if the corresponding _FloatN type is not binary compatible + with the corresponding ISO C type in the current compilation unit as + opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built + in glibc. */ +#define __HAVE_FLOAT128_UNLIKE_LDBL (__HAVE_DISTINCT_FLOAT128 \ + && __LDBL_MANT_DIG__ != 113) + +/* Defined to 1 if any _FloatN or _FloatNx types that are not + ABI-distinct are however distinct types at the C language level (so + for the purposes of __builtin_types_compatible_p and _Generic). */ +#if __GNUC_PREREQ (7, 0) && !defined __cplusplus +# define __HAVE_FLOATN_NOT_TYPEDEF 1 +#else +# define __HAVE_FLOATN_NOT_TYPEDEF 0 +#endif + +#ifndef __ASSEMBLER__ + +/* Defined to concatenate the literal suffix to be used with _FloatN + or _FloatNx types, if __HAVE_ is 1. The corresponding + literal suffixes exist since GCC 7, for C only. */ +# if __HAVE_FLOAT16 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +/* No corresponding suffix available for this type. */ +# define __f16(x) ((_Float16) x##f) +# else +# define __f16(x) x##f16 +# endif +# endif + +# if __HAVE_FLOAT32 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# define __f32(x) x##f +# else +# define __f32(x) x##f32 +# endif +# endif + +# if __HAVE_FLOAT64 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# ifdef __NO_LONG_DOUBLE_MATH +# define __f64(x) x##l +# else +# define __f64(x) x +# endif +# else +# define __f64(x) x##f64 +# endif +# endif + +# if __HAVE_FLOAT32X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# define __f32x(x) x +# else +# define __f32x(x) x##f32x +# endif +# endif + +# if __HAVE_FLOAT64X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# if __HAVE_FLOAT64X_LONG_DOUBLE +# define __f64x(x) x##l +# else +# define __f64x(x) __f128 (x) +# endif +# else +# define __f64x(x) x##f64x +# endif +# endif + +# if __HAVE_FLOAT128X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# error "_Float128X supported but no constant suffix" +# else +# define __f128x(x) x##f128x +# endif +# endif + +/* Defined to a complex type if __HAVE_ is 1. */ +# if __HAVE_FLOAT16 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef _Complex float __cfloat16 __attribute__ ((__mode__ (__HC__))); +# define __CFLOAT16 __cfloat16 +# else +# define __CFLOAT16 _Complex _Float16 +# endif +# endif + +# if __HAVE_FLOAT32 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# define __CFLOAT32 _Complex float +# else +# define __CFLOAT32 _Complex _Float32 +# endif +# endif + +# if __HAVE_FLOAT64 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# ifdef __NO_LONG_DOUBLE_MATH +# define __CFLOAT64 _Complex long double +# else +# define __CFLOAT64 _Complex double +# endif +# else +# define __CFLOAT64 _Complex _Float64 +# endif +# endif + +# if __HAVE_FLOAT32X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# define __CFLOAT32X _Complex double +# else +# define __CFLOAT32X _Complex _Float32x +# endif +# endif + +# if __HAVE_FLOAT64X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# if __HAVE_FLOAT64X_LONG_DOUBLE +# define __CFLOAT64X _Complex long double +# else +# define __CFLOAT64X __CFLOAT128 +# endif +# else +# define __CFLOAT64X _Complex _Float64x +# endif +# endif + +# if __HAVE_FLOAT128X +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# error "_Float128X supported but no complex type" +# else +# define __CFLOAT128X _Complex _Float128x +# endif +# endif + +/* The remaining of this file provides support for older compilers. */ +# if __HAVE_FLOAT16 + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef float _Float16 __attribute__ ((__mode__ (__HF__))); +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf16() ((_Float16) __builtin_huge_val ()) +# define __builtin_inff16() ((_Float16) __builtin_inf ()) +# define __builtin_nanf16(x) ((_Float16) __builtin_nan (x)) +# define __builtin_nansf16(x) ((_Float16) __builtin_nans (x)) +# endif + +# endif + +# if __HAVE_FLOAT32 + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef float _Float32; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf32() (__builtin_huge_valf ()) +# define __builtin_inff32() (__builtin_inff ()) +# define __builtin_nanf32(x) (__builtin_nanf (x)) +# define __builtin_nansf32(x) (__builtin_nansf (x)) +# endif + +# endif + +# if __HAVE_FLOAT64 + +/* If double, long double and _Float64 all have the same set of + values, TS 18661-3 requires the usual arithmetic conversions on + long double and _Float64 to produce _Float64. For this to be the + case when building with a compiler without a distinct _Float64 + type, _Float64 must be a typedef for long double, not for + double. */ + +# ifdef __NO_LONG_DOUBLE_MATH + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef long double _Float64; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf64() (__builtin_huge_vall ()) +# define __builtin_inff64() (__builtin_infl ()) +# define __builtin_nanf64(x) (__builtin_nanl (x)) +# define __builtin_nansf64(x) (__builtin_nansl (x)) +# endif + +# else + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef double _Float64; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf64() (__builtin_huge_val ()) +# define __builtin_inff64() (__builtin_inf ()) +# define __builtin_nanf64(x) (__builtin_nan (x)) +# define __builtin_nansf64(x) (__builtin_nans (x)) +# endif + +# endif + +# endif + +# if __HAVE_FLOAT32X + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef double _Float32x; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf32x() (__builtin_huge_val ()) +# define __builtin_inff32x() (__builtin_inf ()) +# define __builtin_nanf32x(x) (__builtin_nan (x)) +# define __builtin_nansf32x(x) (__builtin_nans (x)) +# endif + +# endif + +# if __HAVE_FLOAT64X + +# if __HAVE_FLOAT64X_LONG_DOUBLE + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef long double _Float64x; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf64x() (__builtin_huge_vall ()) +# define __builtin_inff64x() (__builtin_infl ()) +# define __builtin_nanf64x(x) (__builtin_nanl (x)) +# define __builtin_nansf64x(x) (__builtin_nansl (x)) +# endif + +# else + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef _Float128 _Float64x; +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf64x() (__builtin_huge_valf128 ()) +# define __builtin_inff64x() (__builtin_inff128 ()) +# define __builtin_nanf64x(x) (__builtin_nanf128 (x)) +# define __builtin_nansf64x(x) (__builtin_nansf128 (x)) +# endif + +# endif + +# endif + +# if __HAVE_FLOAT128X + +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +# error "_Float128x supported but no type" +# endif + +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ()) +# define __builtin_inff128x() ((_Float128x) __builtin_inf ()) +# define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x)) +# define __builtin_nansf128x(x) ((_Float128x) __builtin_nans (x)) +# endif + +# endif + +#endif /* !__ASSEMBLER__. */ + +#endif /* _BITS_FLOATN_COMMON_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..2d73d6276154998ddc3c9fec8dc9814efca739be Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn-common.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h new file mode 100644 index 0000000000000000000000000000000000000000..34a6fdc86424bb63aab7998d90cd9fe067524d87 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h @@ -0,0 +1,121 @@ +/* Macros to control TS 18661-3 glibc features on x86. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_FLOATN_H +#define _BITS_FLOATN_H + +#include + +/* Defined to 1 if the current compiler invocation provides a + floating-point type with the IEEE 754 binary128 format, and this + glibc includes corresponding *f128 interfaces for it. The required + libgcc support was added some time after the basic compiler + support, for x86_64 and x86. */ +#if (defined __x86_64__ \ + ? __GNUC_PREREQ (4, 3) \ + : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) +# define __HAVE_FLOAT128 1 +#else +# define __HAVE_FLOAT128 0 +#endif + +/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct + from the default float, double and long double types in this glibc. */ +#if __HAVE_FLOAT128 +# define __HAVE_DISTINCT_FLOAT128 1 +#else +# define __HAVE_DISTINCT_FLOAT128 0 +#endif + +/* Defined to 1 if the current compiler invocation provides a + floating-point type with the right format for _Float64x, and this + glibc includes corresponding *f64x interfaces for it. */ +#define __HAVE_FLOAT64X 1 + +/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format + of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has + the format of _Float128, which must be different from that of long + double. */ +#define __HAVE_FLOAT64X_LONG_DOUBLE 1 + +#ifndef __ASSEMBLER__ + +/* Defined to concatenate the literal suffix to be used with _Float128 + types, if __HAVE_FLOAT128 is 1. */ +# if __HAVE_FLOAT128 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +/* The literal suffix f128 exists only since GCC 7.0. */ +# define __f128(x) x##q +# else +# define __f128(x) x##f128 +# endif +# endif + +/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ +# if __HAVE_FLOAT128 +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +/* Add a typedef for older GCC compilers which don't natively support + _Complex _Float128. */ +typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); +# define __CFLOAT128 __cfloat128 +# else +# define __CFLOAT128 _Complex _Float128 +# endif +# endif + +/* The remaining of this file provides support for older compilers. */ +# if __HAVE_FLOAT128 + +/* The type _Float128 exists only since GCC 7.0. */ +# if !__GNUC_PREREQ (7, 0) || defined __cplusplus +typedef __float128 _Float128; +# endif + +/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */ +# if !__GNUC_PREREQ (7, 0) +# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) +# endif + +/* Older GCC has only a subset of built-in functions for _Float128 on + x86, and __builtin_infq is not usable in static initializers. + Converting a narrower sNaN to _Float128 produces a quiet NaN, so + attempts to use _Float128 sNaNs will not work properly with older + compilers. */ +# if !__GNUC_PREREQ (7, 0) +# define __builtin_copysignf128 __builtin_copysignq +# define __builtin_fabsf128 __builtin_fabsq +# define __builtin_inff128() ((_Float128) __builtin_inf ()) +# define __builtin_nanf128(x) ((_Float128) __builtin_nan (x)) +# define __builtin_nansf128(x) ((_Float128) __builtin_nans (x)) +# endif + +/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*, + e.g.: __builtin_signbitf128, before GCC 6. However, there has never + been a __builtin_signbitf128 in GCC and the type-generic builtin is + only available since GCC 6. */ +# if !__GNUC_PREREQ (6, 0) +# define __builtin_signbitf128 __signbitf128 +# endif + +# endif + +#endif /* !__ASSEMBLER__. */ + +#include + +#endif /* _BITS_FLOATN_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c008443041bfd9290555a880dfe8bab0bfcf9e9c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@floatn.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h new file mode 100644 index 0000000000000000000000000000000000000000..36f0f1f2855e5f12053cf84fe29c5cf5025d411f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h @@ -0,0 +1,33 @@ +/* Define __GLIBC_FLT_EVAL_METHOD. x86 version. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#ifdef __FLT_EVAL_METHOD__ +# if __FLT_EVAL_METHOD__ == -1 +# define __GLIBC_FLT_EVAL_METHOD 2 +# else +# define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# endif +#elif defined __x86_64__ +# define __GLIBC_FLT_EVAL_METHOD 0 +#else +# define __GLIBC_FLT_EVAL_METHOD 2 +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e48e0c816f2192052fce0c76bb35d56fbb677db4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@flt-eval-method.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h new file mode 100644 index 0000000000000000000000000000000000000000..34ed7a57bd589c8834395b6c2c5c9ea212398f40 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h @@ -0,0 +1,39 @@ +/* Define FP_FAST_* macros. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#ifdef __USE_ISOC99 + +/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l} + builtins are supported. */ +# ifdef __FP_FAST_FMA +# define FP_FAST_FMA 1 +# endif + +# ifdef __FP_FAST_FMAF +# define FP_FAST_FMAF 1 +# endif + +# ifdef __FP_FAST_FMAL +# define FP_FAST_FMAL 1 +# endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f4b2d6f1bf50825d9134d8f08b3b0cfba89f53e6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-fast.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h new file mode 100644 index 0000000000000000000000000000000000000000..7516b8b19b82bd48f072d30c01f6aaba05344c5c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h @@ -0,0 +1,24 @@ +/* Define __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. x86 version. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#define __FP_LOGB0_IS_MIN 1 +#define __FP_LOGBNAN_IS_MIN 1 diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c6c09e38fd3684acb207915fc5dab8989b9d61d1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@fp-logb.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h new file mode 100644 index 0000000000000000000000000000000000000000..31a2586bd19493284bd314c5d0e256438644d735 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h @@ -0,0 +1,96 @@ +/* Declarations for getopt (basic, portable features only). + Copyright (C) 1989-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_CORE_H +#define _GETOPT_CORE_H 1 + +/* This header should not be used directly; include getopt.h or + unistd.h instead. Unlike most bits headers, it does not have + a protective #error, because the guard macro for getopt.h in + gnulib is not fixed. */ + +__BEGIN_DECLS + +/* For communication from 'getopt' to the caller. + When 'getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when 'ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to 'getopt'. + + On entry to 'getopt', zero means this is the first call; initialize. + + When 'getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, 'optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message 'getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, 'optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in 'optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU 'getopt'. + + The argument '--' causes premature termination of argument + scanning, explicitly telling 'getopt' that there are no more + options. + + If OPTS begins with '-', then non-option arguments are treated as + arguments to the option '\1'. This behavior is specific to the GNU + 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in + the environment, then do not permute arguments. + + For standards compliance, the 'argv' argument has the type + char *const *, but this is inaccurate; if argument permutation is + enabled, the argv array (not the strings it points to) must be + writable. */ + +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW __nonnull ((2, 3)); + +__END_DECLS + +#endif /* getopt_core.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d1728cea86f142e1adda8a0d0c8307857ae43747 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_core.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h new file mode 100644 index 0000000000000000000000000000000000000000..ece117a3197087e6aa4a526c0ef344535abbc7c0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h @@ -0,0 +1,51 @@ +/* Declarations for getopt (POSIX compatibility shim). + Copyright (C) 1989-2022 Free Software Foundation, Inc. + Unlike the bulk of the getopt implementation, this file is NOT part + of gnulib. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_POSIX_H +#define _GETOPT_POSIX_H 1 + +#if !defined _UNISTD_H && !defined _STDIO_H +#error "Never include getopt_posix.h directly; use unistd.h instead." +#endif + +#include + +__BEGIN_DECLS + +#if defined __USE_POSIX2 && !defined __USE_POSIX_IMPLICITLY \ + && !defined __USE_GNU && !defined _GETOPT_H +/* GNU getopt has more functionality than POSIX getopt. When we are + explicitly conforming to POSIX and not GNU, and getopt.h (which is + not part of POSIX) has not been included, the extra functionality + is disabled. */ +# ifdef __REDIRECT +extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv, + const char *__shortopts), + __posix_getopt); +# else +extern int __posix_getopt (int ___argc, char *const *___argv, + const char *__shortopts) + __THROW __nonnull ((2, 3)); +# define getopt __posix_getopt +# endif +#endif + +__END_DECLS + +#endif /* getopt_posix.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ff4473ac59296740327ffd3684680bc0cba6b42b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@getopt_posix.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h new file mode 100644 index 0000000000000000000000000000000000000000..790d6a12e34eb034d9e3b4b13c8f42b95d9c00ee --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h @@ -0,0 +1,54 @@ +/* Define iscanonical macro. ldbl-96 version. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +extern int __iscanonicall (long double __x) + __THROW __attribute__ ((__const__)); +#define __iscanonicalf(x) ((void) (__typeof (x)) (x), 1) +#define __iscanonical(x) ((void) (__typeof (x)) (x), 1) +#if __HAVE_DISTINCT_FLOAT128 +# define __iscanonicalf128(x) ((void) (__typeof (x)) (x), 1) +#endif + +/* Return nonzero value if X is canonical. In IEEE interchange binary + formats, all values are canonical, but the argument must still be + converted to its semantic type for any exceptions arising from the + conversion, before being discarded; in extended precision, there + are encodings that are not consistently handled as corresponding to + any particular value of the type, and we return 0 for those. */ +#ifndef __cplusplus +# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x)) +#else +/* In C++ mode, __MATH_TG cannot be used, because it relies on + __builtin_types_compatible_p, which is a C-only builtin. On the + other hand, overloading provides the means to distinguish between + the floating-point types. The overloading resolution will match + the correct parameter (regardless of type qualifiers (i.e.: const + and volatile)). */ +extern "C++" { +inline int iscanonical (float __val) { return __iscanonicalf (__val); } +inline int iscanonical (double __val) { return __iscanonical (__val); } +inline int iscanonical (long double __val) { return __iscanonicall (__val); } +# if __HAVE_DISTINCT_FLOAT128 +inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } +# endif +} +#endif /* __cplusplus */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..90a24e823565b6bc20f4439762575f670588c917 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@iscanonical.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h new file mode 100644 index 0000000000000000000000000000000000000000..d161ca50fc249e256c107945bda848ba87dde407 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h @@ -0,0 +1,110 @@ +/* Handle feature test macros at the start of a header. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* This header is internal to glibc and should not be included outside + of glibc headers. Headers including it must define + __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header + cannot have multiple include guards because ISO C feature test + macros depend on the definition of the macro when an affected + header is included, not when the first system header is + included. */ + +#ifndef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +# error "Never include directly." +#endif + +#undef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION + +#include + +/* ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__ + macro. */ +#undef __GLIBC_USE_LIB_EXT2 +#if (defined __USE_GNU \ + || (defined __STDC_WANT_LIB_EXT2__ && __STDC_WANT_LIB_EXT2__ > 0)) +# define __GLIBC_USE_LIB_EXT2 1 +#else +# define __GLIBC_USE_LIB_EXT2 0 +#endif + +/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__ + macro. Most but not all symbols enabled by that macro in TS + 18661-1 are enabled unconditionally in C2X. In C2X, the symbols in + Annex F still require a new feature test macro + __STDC_WANT_IEC_60559_EXT__ instead (C2X does not define + __STDC_WANT_IEC_60559_BFP_EXT__), while a few features from TS + 18661-1 are not included in C2X (and thus should depend on + __STDC_WANT_IEC_60559_BFP_EXT__ even when C2X features are + enabled). + + __GLIBC_USE (IEC_60559_BFP_EXT) controls those features from TS + 18661-1 not included in C2X. + + __GLIBC_USE (IEC_60559_BFP_EXT_C2X) controls those features from TS + 18661-1 that are also included in C2X (with no feature test macro + required in C2X). + + __GLIBC_USE (IEC_60559_EXT) controls those features from TS 18661-1 + that are included in C2X but conditional on + __STDC_WANT_IEC_60559_EXT__. (There are currently no features + conditional on __STDC_WANT_IEC_60559_EXT__ that are not in TS + 18661-1.) */ +#undef __GLIBC_USE_IEC_60559_BFP_EXT +#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__ +# define __GLIBC_USE_IEC_60559_BFP_EXT 1 +#else +# define __GLIBC_USE_IEC_60559_BFP_EXT 0 +#endif +#undef __GLIBC_USE_IEC_60559_BFP_EXT_C2X +#if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X) +# define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 1 +#else +# define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0 +#endif +#undef __GLIBC_USE_IEC_60559_EXT +#if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__ +# define __GLIBC_USE_IEC_60559_EXT 1 +#else +# define __GLIBC_USE_IEC_60559_EXT 0 +#endif + +/* ISO/IEC TS 18661-4:2015 defines the + __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction + functions, the symbols from this TS are enabled unconditionally in + C2X. */ +#undef __GLIBC_USE_IEC_60559_FUNCS_EXT +#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__ +# define __GLIBC_USE_IEC_60559_FUNCS_EXT 1 +#else +# define __GLIBC_USE_IEC_60559_FUNCS_EXT 0 +#endif +#undef __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X +#if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC2X) +# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 1 +#else +# define __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X 0 +#endif + +/* ISO/IEC TS 18661-3:2015 defines the + __STDC_WANT_IEC_60559_TYPES_EXT__ macro. */ +#undef __GLIBC_USE_IEC_60559_TYPES_EXT +#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __GLIBC_USE_IEC_60559_TYPES_EXT 1 +#else +# define __GLIBC_USE_IEC_60559_TYPES_EXT 0 +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8cfcb331ccde735d7845bab0bdb998226df36468 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libc-header-start.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h new file mode 100644 index 0000000000000000000000000000000000000000..200d7369b96fbd9a461c0931085ccfcd16266dc4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h @@ -0,0 +1,332 @@ +/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h. + Copyright (C) 2014-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never include directly;\ + include instead." +#endif + +/* Needed definitions could be generated with: + for func in $(grep __MATHCALL_VEC math/bits/mathcalls.h |\ + sed -r "s|__MATHCALL_VEC.?\(||; s|,.*||"); do + echo "#define __DECL_SIMD_${func}"; + echo "#define __DECL_SIMD_${func}f"; + echo "#define __DECL_SIMD_${func}l"; + done + */ + +#ifndef _BITS_LIBM_SIMD_DECL_STUBS_H +#define _BITS_LIBM_SIMD_DECL_STUBS_H 1 + +#define __DECL_SIMD_cos +#define __DECL_SIMD_cosf +#define __DECL_SIMD_cosl +#define __DECL_SIMD_cosf16 +#define __DECL_SIMD_cosf32 +#define __DECL_SIMD_cosf64 +#define __DECL_SIMD_cosf128 +#define __DECL_SIMD_cosf32x +#define __DECL_SIMD_cosf64x +#define __DECL_SIMD_cosf128x + +#define __DECL_SIMD_sin +#define __DECL_SIMD_sinf +#define __DECL_SIMD_sinl +#define __DECL_SIMD_sinf16 +#define __DECL_SIMD_sinf32 +#define __DECL_SIMD_sinf64 +#define __DECL_SIMD_sinf128 +#define __DECL_SIMD_sinf32x +#define __DECL_SIMD_sinf64x +#define __DECL_SIMD_sinf128x + +#define __DECL_SIMD_sincos +#define __DECL_SIMD_sincosf +#define __DECL_SIMD_sincosl +#define __DECL_SIMD_sincosf16 +#define __DECL_SIMD_sincosf32 +#define __DECL_SIMD_sincosf64 +#define __DECL_SIMD_sincosf128 +#define __DECL_SIMD_sincosf32x +#define __DECL_SIMD_sincosf64x +#define __DECL_SIMD_sincosf128x + +#define __DECL_SIMD_log +#define __DECL_SIMD_logf +#define __DECL_SIMD_logl +#define __DECL_SIMD_logf16 +#define __DECL_SIMD_logf32 +#define __DECL_SIMD_logf64 +#define __DECL_SIMD_logf128 +#define __DECL_SIMD_logf32x +#define __DECL_SIMD_logf64x +#define __DECL_SIMD_logf128x + +#define __DECL_SIMD_exp +#define __DECL_SIMD_expf +#define __DECL_SIMD_expl +#define __DECL_SIMD_expf16 +#define __DECL_SIMD_expf32 +#define __DECL_SIMD_expf64 +#define __DECL_SIMD_expf128 +#define __DECL_SIMD_expf32x +#define __DECL_SIMD_expf64x +#define __DECL_SIMD_expf128x + +#define __DECL_SIMD_pow +#define __DECL_SIMD_powf +#define __DECL_SIMD_powl +#define __DECL_SIMD_powf16 +#define __DECL_SIMD_powf32 +#define __DECL_SIMD_powf64 +#define __DECL_SIMD_powf128 +#define __DECL_SIMD_powf32x +#define __DECL_SIMD_powf64x +#define __DECL_SIMD_powf128x + +#define __DECL_SIMD_acos +#define __DECL_SIMD_acosf +#define __DECL_SIMD_acosl +#define __DECL_SIMD_acosf16 +#define __DECL_SIMD_acosf32 +#define __DECL_SIMD_acosf64 +#define __DECL_SIMD_acosf128 +#define __DECL_SIMD_acosf32x +#define __DECL_SIMD_acosf64x +#define __DECL_SIMD_acosf128x + +#define __DECL_SIMD_atan +#define __DECL_SIMD_atanf +#define __DECL_SIMD_atanl +#define __DECL_SIMD_atanf16 +#define __DECL_SIMD_atanf32 +#define __DECL_SIMD_atanf64 +#define __DECL_SIMD_atanf128 +#define __DECL_SIMD_atanf32x +#define __DECL_SIMD_atanf64x +#define __DECL_SIMD_atanf128x + +#define __DECL_SIMD_asin +#define __DECL_SIMD_asinf +#define __DECL_SIMD_asinl +#define __DECL_SIMD_asinf16 +#define __DECL_SIMD_asinf32 +#define __DECL_SIMD_asinf64 +#define __DECL_SIMD_asinf128 +#define __DECL_SIMD_asinf32x +#define __DECL_SIMD_asinf64x +#define __DECL_SIMD_asinf128x + +#define __DECL_SIMD_hypot +#define __DECL_SIMD_hypotf +#define __DECL_SIMD_hypotl +#define __DECL_SIMD_hypotf16 +#define __DECL_SIMD_hypotf32 +#define __DECL_SIMD_hypotf64 +#define __DECL_SIMD_hypotf128 +#define __DECL_SIMD_hypotf32x +#define __DECL_SIMD_hypotf64x +#define __DECL_SIMD_hypotf128x + +#define __DECL_SIMD_exp2 +#define __DECL_SIMD_exp2f +#define __DECL_SIMD_exp2l +#define __DECL_SIMD_exp2f16 +#define __DECL_SIMD_exp2f32 +#define __DECL_SIMD_exp2f64 +#define __DECL_SIMD_exp2f128 +#define __DECL_SIMD_exp2f32x +#define __DECL_SIMD_exp2f64x +#define __DECL_SIMD_exp2f128x + +#define __DECL_SIMD_exp10 +#define __DECL_SIMD_exp10f +#define __DECL_SIMD_exp10l +#define __DECL_SIMD_exp10f16 +#define __DECL_SIMD_exp10f32 +#define __DECL_SIMD_exp10f64 +#define __DECL_SIMD_exp10f128 +#define __DECL_SIMD_exp10f32x +#define __DECL_SIMD_exp10f64x +#define __DECL_SIMD_exp10f128x + +#define __DECL_SIMD_cosh +#define __DECL_SIMD_coshf +#define __DECL_SIMD_coshl +#define __DECL_SIMD_coshf16 +#define __DECL_SIMD_coshf32 +#define __DECL_SIMD_coshf64 +#define __DECL_SIMD_coshf128 +#define __DECL_SIMD_coshf32x +#define __DECL_SIMD_coshf64x +#define __DECL_SIMD_coshf128x + +#define __DECL_SIMD_expm1 +#define __DECL_SIMD_expm1f +#define __DECL_SIMD_expm1l +#define __DECL_SIMD_expm1f16 +#define __DECL_SIMD_expm1f32 +#define __DECL_SIMD_expm1f64 +#define __DECL_SIMD_expm1f128 +#define __DECL_SIMD_expm1f32x +#define __DECL_SIMD_expm1f64x +#define __DECL_SIMD_expm1f128x + +#define __DECL_SIMD_sinh +#define __DECL_SIMD_sinhf +#define __DECL_SIMD_sinhl +#define __DECL_SIMD_sinhf16 +#define __DECL_SIMD_sinhf32 +#define __DECL_SIMD_sinhf64 +#define __DECL_SIMD_sinhf128 +#define __DECL_SIMD_sinhf32x +#define __DECL_SIMD_sinhf64x +#define __DECL_SIMD_sinhf128x + +#define __DECL_SIMD_cbrt +#define __DECL_SIMD_cbrtf +#define __DECL_SIMD_cbrtl +#define __DECL_SIMD_cbrtf16 +#define __DECL_SIMD_cbrtf32 +#define __DECL_SIMD_cbrtf64 +#define __DECL_SIMD_cbrtf128 +#define __DECL_SIMD_cbrtf32x +#define __DECL_SIMD_cbrtf64x +#define __DECL_SIMD_cbrtf128x + +#define __DECL_SIMD_atan2 +#define __DECL_SIMD_atan2f +#define __DECL_SIMD_atan2l +#define __DECL_SIMD_atan2f16 +#define __DECL_SIMD_atan2f32 +#define __DECL_SIMD_atan2f64 +#define __DECL_SIMD_atan2f128 +#define __DECL_SIMD_atan2f32x +#define __DECL_SIMD_atan2f64x +#define __DECL_SIMD_atan2f128x + +#define __DECL_SIMD_log10 +#define __DECL_SIMD_log10f +#define __DECL_SIMD_log10l +#define __DECL_SIMD_log10f16 +#define __DECL_SIMD_log10f32 +#define __DECL_SIMD_log10f64 +#define __DECL_SIMD_log10f128 +#define __DECL_SIMD_log10f32x +#define __DECL_SIMD_log10f64x +#define __DECL_SIMD_log10f128x + +#define __DECL_SIMD_log2 +#define __DECL_SIMD_log2f +#define __DECL_SIMD_log2l +#define __DECL_SIMD_log2f16 +#define __DECL_SIMD_log2f32 +#define __DECL_SIMD_log2f64 +#define __DECL_SIMD_log2f128 +#define __DECL_SIMD_log2f32x +#define __DECL_SIMD_log2f64x +#define __DECL_SIMD_log2f128x + +#define __DECL_SIMD_log1p +#define __DECL_SIMD_log1pf +#define __DECL_SIMD_log1pl +#define __DECL_SIMD_log1pf16 +#define __DECL_SIMD_log1pf32 +#define __DECL_SIMD_log1pf64 +#define __DECL_SIMD_log1pf128 +#define __DECL_SIMD_log1pf32x +#define __DECL_SIMD_log1pf64x +#define __DECL_SIMD_log1pf128x + +#define __DECL_SIMD_atanh +#define __DECL_SIMD_atanhf +#define __DECL_SIMD_atanhl +#define __DECL_SIMD_atanhf16 +#define __DECL_SIMD_atanhf32 +#define __DECL_SIMD_atanhf64 +#define __DECL_SIMD_atanhf128 +#define __DECL_SIMD_atanhf32x +#define __DECL_SIMD_atanhf64x +#define __DECL_SIMD_atanhf128x + +#define __DECL_SIMD_acosh +#define __DECL_SIMD_acoshf +#define __DECL_SIMD_acoshl +#define __DECL_SIMD_acoshf16 +#define __DECL_SIMD_acoshf32 +#define __DECL_SIMD_acoshf64 +#define __DECL_SIMD_acoshf128 +#define __DECL_SIMD_acoshf32x +#define __DECL_SIMD_acoshf64x +#define __DECL_SIMD_acoshf128x + +#define __DECL_SIMD_erf +#define __DECL_SIMD_erff +#define __DECL_SIMD_erfl +#define __DECL_SIMD_erff16 +#define __DECL_SIMD_erff32 +#define __DECL_SIMD_erff64 +#define __DECL_SIMD_erff128 +#define __DECL_SIMD_erff32x +#define __DECL_SIMD_erff64x +#define __DECL_SIMD_erff128x + +#define __DECL_SIMD_tanh +#define __DECL_SIMD_tanhf +#define __DECL_SIMD_tanhl +#define __DECL_SIMD_tanhf16 +#define __DECL_SIMD_tanhf32 +#define __DECL_SIMD_tanhf64 +#define __DECL_SIMD_tanhf128 +#define __DECL_SIMD_tanhf32x +#define __DECL_SIMD_tanhf64x +#define __DECL_SIMD_tanhf128x + +#define __DECL_SIMD_asinh +#define __DECL_SIMD_asinhf +#define __DECL_SIMD_asinhl +#define __DECL_SIMD_asinhf16 +#define __DECL_SIMD_asinhf32 +#define __DECL_SIMD_asinhf64 +#define __DECL_SIMD_asinhf128 +#define __DECL_SIMD_asinhf32x +#define __DECL_SIMD_asinhf64x +#define __DECL_SIMD_asinhf128x + +#define __DECL_SIMD_erfc +#define __DECL_SIMD_erfcf +#define __DECL_SIMD_erfcl +#define __DECL_SIMD_erfcf16 +#define __DECL_SIMD_erfcf32 +#define __DECL_SIMD_erfcf64 +#define __DECL_SIMD_erfcf128 +#define __DECL_SIMD_erfcf32x +#define __DECL_SIMD_erfcf64x +#define __DECL_SIMD_erfcf128x + +#define __DECL_SIMD_tan +#define __DECL_SIMD_tanf +#define __DECL_SIMD_tanl +#define __DECL_SIMD_tanf16 +#define __DECL_SIMD_tanf32 +#define __DECL_SIMD_tanf64 +#define __DECL_SIMD_tanf128 +#define __DECL_SIMD_tanf32x +#define __DECL_SIMD_tanf64x +#define __DECL_SIMD_tanf128x +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9d7a9def46094595aa2fdb5aedf87689cb13479b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@libm-simd-decl-stubs.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..39e2cb95401db58a3cfc856e44ff2f05279f6aa0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h @@ -0,0 +1,99 @@ +/* Minimum guaranteed maximum values for system limits. Linux version. + Copyright (C) 1993-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +/* The kernel header pollutes the namespace with the NR_OPEN symbol + and defines LINK_MAX although filesystems have different maxima. A + similar thing is true for OPEN_MAX: the limit can be changed at + runtime and therefore the macro must not be defined. Remove this + after including the header if necessary. */ +#ifndef NR_OPEN +# define __undef_NR_OPEN +#endif +#ifndef LINK_MAX +# define __undef_LINK_MAX +#endif +#ifndef OPEN_MAX +# define __undef_OPEN_MAX +#endif +#ifndef ARG_MAX +# define __undef_ARG_MAX +#endif + +/* The kernel sources contain a file with all the needed information. */ +#include + +/* Have to remove NR_OPEN? */ +#ifdef __undef_NR_OPEN +# undef NR_OPEN +# undef __undef_NR_OPEN +#endif +/* Have to remove LINK_MAX? */ +#ifdef __undef_LINK_MAX +# undef LINK_MAX +# undef __undef_LINK_MAX +#endif +/* Have to remove OPEN_MAX? */ +#ifdef __undef_OPEN_MAX +# undef OPEN_MAX +# undef __undef_OPEN_MAX +#endif +/* Have to remove ARG_MAX? */ +#ifdef __undef_ARG_MAX +# undef ARG_MAX +# undef __undef_ARG_MAX +#endif + +/* The number of data keys per process. */ +#define _POSIX_THREAD_KEYS_MAX 128 +/* This is the value this implementation supports. */ +#define PTHREAD_KEYS_MAX 1024 + +/* Controlling the iterations of destructors for thread-specific data. */ +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +/* Number of iterations this implementation does. */ +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +/* The number of threads per process. */ +#define _POSIX_THREAD_THREADS_MAX 64 +/* We have no predefined limit on the number of threads. */ +#undef PTHREAD_THREADS_MAX + +/* Maximum amount by which a process can descrease its asynchronous I/O + priority level. */ +#define AIO_PRIO_DELTA_MAX 20 + +/* Arrange for the definition of PTHREAD_STACK_MIN. */ +#include + +/* Maximum number of timer expiration overruns. */ +#define DELAYTIMER_MAX 2147483647 + +/* Maximum tty name length. */ +#define TTY_NAME_MAX 32 + +/* Maximum login name length. This is arbitrary. */ +#define LOGIN_NAME_MAX 256 + +/* Maximum host name length. */ +#define HOST_NAME_MAX 64 + +/* Maximum message queue priority level. */ +#define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..98217de930eff5371b2d4296f986c3514eb165e3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@local_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h new file mode 100644 index 0000000000000000000000000000000000000000..ef17a581ca06b12edb943fa49b5320ab100f5331 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h @@ -0,0 +1,40 @@ +/* Definition of locale category symbol values. + Copyright (C) 2001-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined _LOCALE_H && !defined _LANGINFO_H +# error "Never use directly; include instead." +#endif + +#ifndef _BITS_LOCALE_H +#define _BITS_LOCALE_H 1 + +#define __LC_CTYPE 0 +#define __LC_NUMERIC 1 +#define __LC_TIME 2 +#define __LC_COLLATE 3 +#define __LC_MONETARY 4 +#define __LC_MESSAGES 5 +#define __LC_ALL 6 +#define __LC_PAPER 7 +#define __LC_NAME 8 +#define __LC_ADDRESS 9 +#define __LC_TELEPHONE 10 +#define __LC_MEASUREMENT 11 +#define __LC_IDENTIFICATION 12 + +#endif /* bits/locale.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..daf32c467c0338d2272d49b1e3c329e5213c70d7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@locale.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h new file mode 100644 index 0000000000000000000000000000000000000000..350df845d2fad2273e6dfeca382978df6d1968df --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h @@ -0,0 +1,21 @@ +/* Properties of long double type. ldbl-96 version. + Copyright (C) 2016-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* long double is distinct from double, so there is nothing to + define here. */ +#define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0 diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..872d1c2b1ca78b8b56cb930dc9441cf904d6db8d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@long-double.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h new file mode 100644 index 0000000000000000000000000000000000000000..dc7d84a70766b9f4fcd94be1221cc91747f2907b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h @@ -0,0 +1,147 @@ +/* Platform-specific SIMD declarations of math functions. + Copyright (C) 2014-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never include directly;\ + include instead." +#endif + +/* Get default empty definitions for simd declarations. */ +#include + +#if defined __x86_64__ && defined __FAST_MATH__ +# if defined _OPENMP && _OPENMP >= 201307 +/* OpenMP case. */ +# define __DECL_SIMD_x86_64 _Pragma ("omp declare simd notinbranch") +# elif __GNUC_PREREQ (6,0) +/* W/o OpenMP use GCC 6.* __attribute__ ((__simd__)). */ +# define __DECL_SIMD_x86_64 __attribute__ ((__simd__ ("notinbranch"))) +# endif + +# ifdef __DECL_SIMD_x86_64 +# undef __DECL_SIMD_cos +# define __DECL_SIMD_cos __DECL_SIMD_x86_64 +# undef __DECL_SIMD_cosf +# define __DECL_SIMD_cosf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sin +# define __DECL_SIMD_sin __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sinf +# define __DECL_SIMD_sinf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sincos +# define __DECL_SIMD_sincos __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sincosf +# define __DECL_SIMD_sincosf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log +# define __DECL_SIMD_log __DECL_SIMD_x86_64 +# undef __DECL_SIMD_logf +# define __DECL_SIMD_logf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_exp +# define __DECL_SIMD_exp __DECL_SIMD_x86_64 +# undef __DECL_SIMD_expf +# define __DECL_SIMD_expf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_pow +# define __DECL_SIMD_pow __DECL_SIMD_x86_64 +# undef __DECL_SIMD_powf +# define __DECL_SIMD_powf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_acos +# define __DECL_SIMD_acos __DECL_SIMD_x86_64 +# undef __DECL_SIMD_acosf +# define __DECL_SIMD_acosf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atan +# define __DECL_SIMD_atan __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atanf +# define __DECL_SIMD_atanf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_asin +# define __DECL_SIMD_asin __DECL_SIMD_x86_64 +# undef __DECL_SIMD_asinf +# define __DECL_SIMD_asinf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_hypot +# define __DECL_SIMD_hypot __DECL_SIMD_x86_64 +# undef __DECL_SIMD_hypotf +# define __DECL_SIMD_hypotf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_exp2 +# define __DECL_SIMD_exp2 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_exp2f +# define __DECL_SIMD_exp2f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_exp10 +# define __DECL_SIMD_exp10 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_exp10f +# define __DECL_SIMD_exp10f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_cosh +# define __DECL_SIMD_cosh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_coshf +# define __DECL_SIMD_coshf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_expm1 +# define __DECL_SIMD_expm1 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_expm1f +# define __DECL_SIMD_expm1f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sinh +# define __DECL_SIMD_sinh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_sinhf +# define __DECL_SIMD_sinhf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_cbrt +# define __DECL_SIMD_cbrt __DECL_SIMD_x86_64 +# undef __DECL_SIMD_cbrtf +# define __DECL_SIMD_cbrtf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atan2 +# define __DECL_SIMD_atan2 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atan2f +# define __DECL_SIMD_atan2f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log10 +# define __DECL_SIMD_log10 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log10f +# define __DECL_SIMD_log10f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log2 +# define __DECL_SIMD_log2 __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log2f +# define __DECL_SIMD_log2f __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log1p +# define __DECL_SIMD_log1p __DECL_SIMD_x86_64 +# undef __DECL_SIMD_log1pf +# define __DECL_SIMD_log1pf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atanh +# define __DECL_SIMD_atanh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_atanhf +# define __DECL_SIMD_atanhf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_acosh +# define __DECL_SIMD_acosh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_acoshf +# define __DECL_SIMD_acoshf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_erf +# define __DECL_SIMD_erf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_erff +# define __DECL_SIMD_erff __DECL_SIMD_x86_64 +# undef __DECL_SIMD_tanh +# define __DECL_SIMD_tanh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_tanhf +# define __DECL_SIMD_tanhf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_asinh +# define __DECL_SIMD_asinh __DECL_SIMD_x86_64 +# undef __DECL_SIMD_asinhf +# define __DECL_SIMD_asinhf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_erfc +# define __DECL_SIMD_erfc __DECL_SIMD_x86_64 +# undef __DECL_SIMD_erfcf +# define __DECL_SIMD_erfcf __DECL_SIMD_x86_64 +# undef __DECL_SIMD_tan +# define __DECL_SIMD_tan __DECL_SIMD_x86_64 +# undef __DECL_SIMD_tanf +# define __DECL_SIMD_tanf __DECL_SIMD_x86_64 + +# endif +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..dc7d8591d26ca399ba8c45f39d05f76e9a14d3dd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@math-vector.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h new file mode 100644 index 0000000000000000000000000000000000000000..932fd117ba49cc2422fa375fa29eab72f348724a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h @@ -0,0 +1,45 @@ +/* Prototype declarations for math classification macros helpers. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Classify given number. */ +__MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify) + __attribute__ ((__const__)); + +/* Test for negative number. */ +__MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit) + __attribute__ ((__const__)); + +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_ALIAS (int, __isinf,, (_Mdouble_ __value), isinf) + __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. Used by isfinite macro. */ +__MATHDECL_ALIAS (int, __finite,, (_Mdouble_ __value), finite) + __attribute__ ((__const__)); + +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_ALIAS (int, __isnan,, (_Mdouble_ __value), isnan) + __attribute__ ((__const__)); + +/* Test equality. */ +__MATHDECL_ALIAS (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y), iseqsig); + +/* Test for signaling NaN. */ +__MATHDECL_ALIAS (int, __issignaling,, (_Mdouble_ __value), issignaling) + __attribute__ ((__const__)); diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ea48efc9c9ef315cb9d9892b42e4e7129a504a62 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-helper-functions.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h new file mode 100644 index 0000000000000000000000000000000000000000..1b192435b9b18bd7a7e470564d019e02007e2b55 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h @@ -0,0 +1,39 @@ +/* Declare functions returning a narrower type. + Copyright (C) 2018-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never include directly; include instead." +#endif + +/* Add. */ +__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2); + +/* Divide. */ +__MATHCALL_NARROW (__MATHCALL_NAME (div), __MATHCALL_REDIR_NAME (div), 2); + +/* Fused multiply-add. */ +__MATHCALL_NARROW (__MATHCALL_NAME (fma), __MATHCALL_REDIR_NAME2 (fma), 3); + +/* Multiply. */ +__MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2); + +/* Square root. */ +__MATHCALL_NARROW (__MATHCALL_NAME (sqrt), __MATHCALL_REDIR_NAME2 (sqrt), 1); + +/* Subtract. */ +__MATHCALL_NARROW (__MATHCALL_NAME (sub), __MATHCALL_REDIR_NAME (sub), 2); diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4b0463c22994ea98600822d7fc49767358954172 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls-narrow.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h new file mode 100644 index 0000000000000000000000000000000000000000..63912ec2762c3359b47662eb87b844ad1daaeb8e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h @@ -0,0 +1,436 @@ +/* Prototype declarations for math functions; helper file for . + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME,[_r], (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME,[_r], (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. + + Note that there must be no whitespace before the argument passed for + NAME, to make token pasting work with -traditional. */ + +#ifndef _MATH_H +# error "Never include directly; include instead." +#endif + + +/* Trigonometric functions. */ + +/* Arc cosine of X. */ +__MATHCALL_VEC (acos,, (_Mdouble_ __x)); +/* Arc sine of X. */ +__MATHCALL_VEC (asin,, (_Mdouble_ __x)); +/* Arc tangent of X. */ +__MATHCALL_VEC (atan,, (_Mdouble_ __x)); +/* Arc tangent of Y/X. */ +__MATHCALL_VEC (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); + +/* Cosine of X. */ +__MATHCALL_VEC (cos,, (_Mdouble_ __x)); +/* Sine of X. */ +__MATHCALL_VEC (sin,, (_Mdouble_ __x)); +/* Tangent of X. */ +__MATHCALL_VEC (tan,, (_Mdouble_ __x)); + +/* Hyperbolic functions. */ + +/* Hyperbolic cosine of X. */ +__MATHCALL_VEC (cosh,, (_Mdouble_ __x)); +/* Hyperbolic sine of X. */ +__MATHCALL_VEC (sinh,, (_Mdouble_ __x)); +/* Hyperbolic tangent of X. */ +__MATHCALL_VEC (tanh,, (_Mdouble_ __x)); + +#ifdef __USE_GNU +/* Cosine and sine of X. */ +__MATHDECL_VEC (void,sincos,, + (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Hyperbolic arc cosine of X. */ +__MATHCALL_VEC (acosh,, (_Mdouble_ __x)); +/* Hyperbolic arc sine of X. */ +__MATHCALL_VEC (asinh,, (_Mdouble_ __x)); +/* Hyperbolic arc tangent of X. */ +__MATHCALL_VEC (atanh,, (_Mdouble_ __x)); +#endif + +/* Exponential and logarithmic functions. */ + +/* Exponential function of X. */ +__MATHCALL_VEC (exp,, (_Mdouble_ __x)); + +/* Break VALUE into a normalized fraction and an integral power of 2. */ +__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent)); + +/* X times (two to the EXP power). */ +__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent)); + +/* Natural logarithm of X. */ +__MATHCALL_VEC (log,, (_Mdouble_ __x)); + +/* Base-ten logarithm of X. */ +__MATHCALL_VEC (log10,, (_Mdouble_ __x)); + +/* Break VALUE into integral and fractional parts. */ +__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2)); + +#if __GLIBC_USE (IEC_60559_FUNCS_EXT_C2X) +/* Compute exponent to base ten. */ +__MATHCALL_VEC (exp10,, (_Mdouble_ __x)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Return exp(X) - 1. */ +__MATHCALL_VEC (expm1,, (_Mdouble_ __x)); + +/* Return log(1 + X). */ +__MATHCALL_VEC (log1p,, (_Mdouble_ __x)); + +/* Return the base 2 signed integral exponent of X. */ +__MATHCALL (logb,, (_Mdouble_ __x)); +#endif + +#ifdef __USE_ISOC99 +/* Compute base-2 exponential of X. */ +__MATHCALL_VEC (exp2,, (_Mdouble_ __x)); + +/* Compute base-2 logarithm of X. */ +__MATHCALL_VEC (log2,, (_Mdouble_ __x)); +#endif + + +/* Power functions. */ + +/* Return X to the Y power. */ +__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return the square root of X. */ +__MATHCALL (sqrt,, (_Mdouble_ __x)); + +#if defined __USE_XOPEN || defined __USE_ISOC99 +/* Return `sqrt(X*X + Y*Y)'. */ +__MATHCALL_VEC (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Return the cube root of X. */ +__MATHCALL_VEC (cbrt,, (_Mdouble_ __x)); +#endif + + +/* Nearest integer, absolute value, and remainder functions. */ + +/* Smallest integral value not less than X. */ +__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__)); + +/* Absolute value of X. */ +__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); + +/* Largest integer not greater than X. */ +__MATHCALLX (floor,, (_Mdouble_ __x), (__const__)); + +/* Floating-point modulo remainder of X/Y. */ +__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); + +#ifdef __USE_MISC +# if ((!defined __cplusplus \ + || __cplusplus < 201103L /* isinf conflicts with C++11. */ \ + || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \ + && !__MATH_DECLARING_FLOATN +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf) + __attribute__ ((__const__)); +# endif + +# if !__MATH_DECLARING_FLOATN +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite) + __attribute__ ((__const__)); + +/* Return the remainder of X/Y. */ +__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Return the fractional part of X after dividing out `ilogb (X)'. */ +__MATHCALL (significand,, (_Mdouble_ __x)); +# endif + +#endif /* Use misc. */ + +#ifdef __USE_ISOC99 +/* Return X with its signed changed to Y's. */ +__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +#endif + +#ifdef __USE_ISOC99 +/* Return representation of qNaN for double type. */ +__MATHCALL (nan,, (const char *__tagb)); +#endif + + +#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +# if ((!defined __cplusplus \ + || __cplusplus < 201103L /* isnan conflicts with C++11. */ \ + || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \ + && !__MATH_DECLARING_FLOATN +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan) + __attribute__ ((__const__)); +# endif +#endif + +#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE) +/* Bessel functions. */ +__MATHCALL (j0,, (_Mdouble_)); +__MATHCALL (j1,, (_Mdouble_)); +__MATHCALL (jn,, (int, _Mdouble_)); +__MATHCALL (y0,, (_Mdouble_)); +__MATHCALL (y1,, (_Mdouble_)); +__MATHCALL (yn,, (int, _Mdouble_)); +#endif + + +#if defined __USE_XOPEN || defined __USE_ISOC99 +/* Error and gamma functions. */ +__MATHCALL_VEC (erf,, (_Mdouble_)); +__MATHCALL_VEC (erfc,, (_Mdouble_)); +__MATHCALL (lgamma,, (_Mdouble_)); +#endif + +#ifdef __USE_ISOC99 +/* True gamma function. */ +__MATHCALL (tgamma,, (_Mdouble_)); +#endif + +#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +# if !__MATH_DECLARING_FLOATN +/* Obsolete alias for `lgamma'. */ +__MATHCALL (gamma,, (_Mdouble_)); +# endif +#endif + +#ifdef __USE_MISC +/* Reentrant version of lgamma. This function uses the global variable + `signgam'. The reentrant version instead takes a pointer and stores + the value through it. */ +__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp)); +#endif + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Return the integer nearest X in the direction of the + prevailing rounding mode. */ +__MATHCALL (rint,, (_Mdouble_ __x)); + +/* Return X + epsilon if X < Y, X - epsilon if X > Y. */ +__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y)); +# if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN +__MATHCALL (nexttoward,, (_Mdouble_ __x, long double __y)); +# endif + +# if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) || __MATH_DECLARING_FLOATN +/* Return X - epsilon. */ +__MATHCALL (nextdown,, (_Mdouble_ __x)); +/* Return X + epsilon. */ +__MATHCALL (nextup,, (_Mdouble_ __x)); +# endif + +/* Return the remainder of integer divison X / Y with infinite precision. */ +__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y)); + +# ifdef __USE_ISOC99 +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); +# endif + +/* Return the binary exponent of X, which must be nonzero. */ +__MATHDECL (int,ilogb,, (_Mdouble_ __x)); +#endif + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) || __MATH_DECLARING_FLOATN +/* Like ilogb, but returning long int. */ +__MATHDECL (long int, llogb,, (_Mdouble_ __x)); +#endif + +#ifdef __USE_ISOC99 +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n)); + +/* Round X to integral value in floating-point format using current + rounding direction, but do not raise inexact exception. */ +__MATHCALL (nearbyint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHCALLX (round,, (_Mdouble_ __x), (__const__)); + +/* Round X to the integral value in floating-point format nearest but + not larger in magnitude. */ +__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__)); + +/* Compute remainder of X and Y and put in *QUO a value with sign of x/y + and magnitude congruent `mod 2^n' to the magnitude of the integral + quotient x/y, with n >= 3. */ +__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); + + +/* Conversion functions. */ + +/* Round X to nearest integral value according to current rounding + direction. */ +__MATHDECL (long int,lrint,, (_Mdouble_ __x)); +__extension__ +__MATHDECL (long long int,llrint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHDECL (long int,lround,, (_Mdouble_ __x)); +__extension__ +__MATHDECL (long long int,llround,, (_Mdouble_ __x)); + + +/* Return positive difference between X and Y. */ +__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); + +# if !__MATH_DECLARING_FLOATN || defined __USE_GNU || !__GLIBC_USE (ISOC2X) +/* Return maximum numeric value from X and Y. */ +__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return minimum numeric value from X and Y. */ +__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +# endif + +/* Multiply-add function computed as a ternary operation. */ +__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); +#endif /* Use ISO C99. */ + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) || __MATH_DECLARING_FLOATN +/* Round X to nearest integer value, rounding halfway cases to even. */ +__MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__)); + +/* Round X to nearest signed integer value, not raising inexact, with + control of rounding direction and width of result. */ +__MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round, + unsigned int __width)); + +/* Round X to nearest unsigned integer value, not raising inexact, + with control of rounding direction and width of result. */ +__MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round, + unsigned int __width)); + +/* Round X to nearest signed integer value, raising inexact for + non-integers, with control of rounding direction and width of + result. */ +__MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round, + unsigned int __width)); + +/* Round X to nearest unsigned integer value, raising inexact for + non-integers, with control of rounding direction and width of + result. */ +__MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round, + unsigned int __width)); + +/* Canonicalize floating-point representation. */ +__MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x)); +#endif + +#if (__GLIBC_USE (IEC_60559_BFP_EXT) \ + || (__MATH_DECLARING_FLOATN \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))) +/* Return value with maximum magnitude. */ +__MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return value with minimum magnitude. */ +__MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +#endif + +#if __GLIBC_USE (ISOC2X) +/* Return maximum value from X and Y. */ +__MATHCALLX (fmaximum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return minimum value from X and Y. */ +__MATHCALLX (fminimum,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return maximum numeric value from X and Y. */ +__MATHCALLX (fmaximum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return minimum numeric value from X and Y. */ +__MATHCALLX (fminimum_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return value with maximum magnitude. */ +__MATHCALLX (fmaximum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return value with minimum magnitude. */ +__MATHCALLX (fminimum_mag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return numeric value with maximum magnitude. */ +__MATHCALLX (fmaximum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return numeric value with minimum magnitude. */ +__MATHCALLX (fminimum_mag_num,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +#endif + +#if __GLIBC_USE (IEC_60559_EXT) || __MATH_DECLARING_FLOATN +/* Total order operation. */ +__MATHDECL_1 (int, totalorder,, (const _Mdouble_ *__x, + const _Mdouble_ *__y)) + __attribute_pure__; + +/* Total order operation on absolute values. */ +__MATHDECL_1 (int, totalordermag,, (const _Mdouble_ *__x, + const _Mdouble_ *__y)) + __attribute_pure__; + +/* Get NaN payload. */ +__MATHCALL (getpayload,, (const _Mdouble_ *__x)); + +/* Set quiet NaN payload. */ +__MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload)); + +/* Set signaling NaN payload. */ +__MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload)); +#endif + +#if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \ + && __MATH_DECLARING_DOUBLE \ + && !defined __USE_XOPEN2K8)) \ + && !__MATH_DECLARING_FLOATN +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a284838215241f2dc814b0e851fd5ffd1870c8bf Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@mathcalls.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..153d5d366bca0a530de404ef064c2e193bd44330 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h @@ -0,0 +1,183 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * POSIX Standard: 2.9.2 Minimum Values Added to + * + * Never include this file directly; use instead. + */ + +#ifndef _BITS_POSIX1_LIM_H +#define _BITS_POSIX1_LIM_H 1 + +#include + +/* These are the standard-mandated minimum values. */ + +/* Minimum number of operations in one list I/O call. */ +#define _POSIX_AIO_LISTIO_MAX 2 + +/* Minimal number of outstanding asynchronous I/O operations. */ +#define _POSIX_AIO_MAX 1 + +/* Maximum length of arguments to `execve', including environment. */ +#define _POSIX_ARG_MAX 4096 + +/* Maximum simultaneous processes per real user ID. */ +#ifdef __USE_XOPEN2K +# define _POSIX_CHILD_MAX 25 +#else +# define _POSIX_CHILD_MAX 6 +#endif + +/* Minimal number of timer expiration overruns. */ +#define _POSIX_DELAYTIMER_MAX 32 + +/* Maximum length of a host name (not including the terminating null) + as returned from the GETHOSTNAME function. */ +#define _POSIX_HOST_NAME_MAX 255 + +/* Maximum link count of a file. */ +#define _POSIX_LINK_MAX 8 + +/* Maximum length of login name. */ +#define _POSIX_LOGIN_NAME_MAX 9 + +/* Number of bytes in a terminal canonical input queue. */ +#define _POSIX_MAX_CANON 255 + +/* Number of bytes for which space will be + available in a terminal input queue. */ +#define _POSIX_MAX_INPUT 255 + +/* Maximum number of message queues open for a process. */ +#define _POSIX_MQ_OPEN_MAX 8 + +/* Maximum number of supported message priorities. */ +#define _POSIX_MQ_PRIO_MAX 32 + +/* Number of bytes in a filename. */ +#define _POSIX_NAME_MAX 14 + +/* Number of simultaneous supplementary group IDs per process. */ +#ifdef __USE_XOPEN2K +# define _POSIX_NGROUPS_MAX 8 +#else +# define _POSIX_NGROUPS_MAX 0 +#endif + +/* Number of files one process can have open at once. */ +#ifdef __USE_XOPEN2K +# define _POSIX_OPEN_MAX 20 +#else +# define _POSIX_OPEN_MAX 16 +#endif + +#if !defined __USE_XOPEN2K || defined __USE_GNU +/* Number of descriptors that a process may examine with `pselect' or + `select'. */ +# define _POSIX_FD_SETSIZE _POSIX_OPEN_MAX +#endif + +/* Number of bytes in a pathname. */ +#define _POSIX_PATH_MAX 256 + +/* Number of bytes than can be written atomically to a pipe. */ +#define _POSIX_PIPE_BUF 512 + +/* The number of repeated occurrences of a BRE permitted by the + REGEXEC and REGCOMP functions when using the interval notation. */ +#define _POSIX_RE_DUP_MAX 255 + +/* Minimal number of realtime signals reserved for the application. */ +#define _POSIX_RTSIG_MAX 8 + +/* Number of semaphores a process can have. */ +#define _POSIX_SEM_NSEMS_MAX 256 + +/* Maximal value of a semaphore. */ +#define _POSIX_SEM_VALUE_MAX 32767 + +/* Number of pending realtime signals. */ +#define _POSIX_SIGQUEUE_MAX 32 + +/* Largest value of a `ssize_t'. */ +#define _POSIX_SSIZE_MAX 32767 + +/* Number of streams a process can have open at once. */ +#define _POSIX_STREAM_MAX 8 + +/* The number of bytes in a symbolic link. */ +#define _POSIX_SYMLINK_MAX 255 + +/* The number of symbolic links that can be traversed in the + resolution of a pathname in the absence of a loop. */ +#define _POSIX_SYMLOOP_MAX 8 + +/* Number of timer for a process. */ +#define _POSIX_TIMER_MAX 32 + +/* Maximum number of characters in a tty name. */ +#define _POSIX_TTY_NAME_MAX 9 + +/* Maximum length of a timezone name (element of `tzname'). */ +#ifdef __USE_XOPEN2K +# define _POSIX_TZNAME_MAX 6 +#else +# define _POSIX_TZNAME_MAX 3 +#endif + +#if !defined __USE_XOPEN2K || defined __USE_GNU +/* Maximum number of connections that can be queued on a socket. */ +# define _POSIX_QLIMIT 1 + +/* Maximum number of bytes that can be buffered on a socket for send + or receive. */ +# define _POSIX_HIWAT _POSIX_PIPE_BUF + +/* Maximum number of elements in an `iovec' array. */ +# define _POSIX_UIO_MAXIOV 16 +#endif + +/* Maximum clock resolution in nanoseconds. */ +#define _POSIX_CLOCKRES_MIN 20000000 + + +/* Get the implementation-specific values for the above. */ +#include + + +#ifndef SSIZE_MAX +/* ssize_t is not formally required to be the signed type + corresponding to size_t, but it is for all configurations supported + by glibc. */ +# if __WORDSIZE == 64 || __WORDSIZE32_SIZE_ULONG +# define SSIZE_MAX LONG_MAX +# else +# define SSIZE_MAX INT_MAX +# endif +#endif + + +/* This value is a guaranteed minimum maximum. + The current maximum can be got from `sysconf'. */ + +#ifndef NGROUPS_MAX +# define NGROUPS_MAX 8 +#endif + +#endif /* bits/posix1_lim.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..059d87362349bbba1354c029419e9a8723f900a4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix1_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..0dd5230e5f2045aa20e294d6086de21d2e89e1a4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h @@ -0,0 +1,90 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * Never include this file directly; include instead. + */ + +#ifndef _BITS_POSIX2_LIM_H +#define _BITS_POSIX2_LIM_H 1 + + +/* The maximum `ibase' and `obase' values allowed by the `bc' utility. */ +#define _POSIX2_BC_BASE_MAX 99 + +/* The maximum number of elements allowed in an array by the `bc' utility. */ +#define _POSIX2_BC_DIM_MAX 2048 + +/* The maximum `scale' value allowed by the `bc' utility. */ +#define _POSIX2_BC_SCALE_MAX 99 + +/* The maximum length of a string constant accepted by the `bc' utility. */ +#define _POSIX2_BC_STRING_MAX 1000 + +/* The maximum number of weights that can be assigned to an entry of + the LC_COLLATE `order' keyword in the locale definition file. */ +#define _POSIX2_COLL_WEIGHTS_MAX 2 + +/* The maximum number of expressions that can be nested + within parentheses by the `expr' utility. */ +#define _POSIX2_EXPR_NEST_MAX 32 + +/* The maximum length, in bytes, of an input line. */ +#define _POSIX2_LINE_MAX 2048 + +/* The maximum number of repeated occurrences of a regular expression + permitted when using the interval notation `\{M,N\}'. */ +#define _POSIX2_RE_DUP_MAX 255 + +/* The maximum number of bytes in a character class name. We have no + fixed limit, 2048 is a high number. */ +#define _POSIX2_CHARCLASS_NAME_MAX 14 + + +/* These values are implementation-specific, + and may vary within the implementation. + Their precise values can be obtained from sysconf. */ + +#ifndef BC_BASE_MAX +#define BC_BASE_MAX _POSIX2_BC_BASE_MAX +#endif +#ifndef BC_DIM_MAX +#define BC_DIM_MAX _POSIX2_BC_DIM_MAX +#endif +#ifndef BC_SCALE_MAX +#define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX +#endif +#ifndef BC_STRING_MAX +#define BC_STRING_MAX _POSIX2_BC_STRING_MAX +#endif +#ifndef COLL_WEIGHTS_MAX +#define COLL_WEIGHTS_MAX 255 +#endif +#ifndef EXPR_NEST_MAX +#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX +#endif +#ifndef LINE_MAX +#define LINE_MAX _POSIX2_LINE_MAX +#endif +#ifndef CHARCLASS_NAME_MAX +#define CHARCLASS_NAME_MAX 2048 +#endif + +/* This value is defined like this in regex.h. */ +#define RE_DUP_MAX (0x7fff) + +#endif /* bits/posix2_lim.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..781650b50bdcffa01b03ba3db9d39816ff64a282 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix2_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h new file mode 100644 index 0000000000000000000000000000000000000000..de7f3548a05ddae3719a47ebc480d85c46e2a133 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h @@ -0,0 +1,194 @@ +/* Define POSIX options for Linux. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#ifndef _BITS_POSIX_OPT_H +#define _BITS_POSIX_OPT_H 1 + +/* Job control is supported. */ +#define _POSIX_JOB_CONTROL 1 + +/* Processes have a saved set-user-ID and a saved set-group-ID. */ +#define _POSIX_SAVED_IDS 1 + +/* Priority scheduling is not supported with the correct semantics, + but GNU/Linux applications expect that the corresponding interfaces + are available, even though the semantics do not meet the POSIX + requirements. See glibc bug 14829. */ +#define _POSIX_PRIORITY_SCHEDULING 200809L + +/* Synchronizing file data is supported. */ +#define _POSIX_SYNCHRONIZED_IO 200809L + +/* The fsync function is present. */ +#define _POSIX_FSYNC 200809L + +/* Mapping of files to memory is supported. */ +#define _POSIX_MAPPED_FILES 200809L + +/* Locking of all memory is supported. */ +#define _POSIX_MEMLOCK 200809L + +/* Locking of ranges of memory is supported. */ +#define _POSIX_MEMLOCK_RANGE 200809L + +/* Setting of memory protections is supported. */ +#define _POSIX_MEMORY_PROTECTION 200809L + +/* Some filesystems allow all users to change file ownership. */ +#define _POSIX_CHOWN_RESTRICTED 0 + +/* `c_cc' member of 'struct termios' structure can be disabled by + using the value _POSIX_VDISABLE. */ +#define _POSIX_VDISABLE '\0' + +/* Filenames are not silently truncated. */ +#define _POSIX_NO_TRUNC 1 + +/* X/Open realtime support is available. */ +#define _XOPEN_REALTIME 1 + +/* X/Open thread realtime support is available. */ +#define _XOPEN_REALTIME_THREADS 1 + +/* XPG4.2 shared memory is supported. */ +#define _XOPEN_SHM 1 + +/* Tell we have POSIX threads. */ +#define _POSIX_THREADS 200809L + +/* We have the reentrant functions described in POSIX. */ +#define _POSIX_REENTRANT_FUNCTIONS 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L + +/* We provide priority scheduling for threads. */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L + +/* We support user-defined stack sizes. */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200809L + +/* We support user-defined stacks. */ +#define _POSIX_THREAD_ATTR_STACKADDR 200809L + +/* We support priority inheritence. */ +#define _POSIX_THREAD_PRIO_INHERIT 200809L + +/* We support priority protection, though only for non-robust + mutexes. */ +#define _POSIX_THREAD_PRIO_PROTECT 200809L + +#ifdef __USE_XOPEN2K8 +/* We support priority inheritence for robust mutexes. */ +# define _POSIX_THREAD_ROBUST_PRIO_INHERIT 200809L + +/* We do not support priority protection for robust mutexes. */ +# define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1 +#endif + +/* We support POSIX.1b semaphores. */ +#define _POSIX_SEMAPHORES 200809L + +/* Real-time signals are supported. */ +#define _POSIX_REALTIME_SIGNALS 200809L + +/* We support asynchronous I/O. */ +#define _POSIX_ASYNCHRONOUS_IO 200809L +#define _POSIX_ASYNC_IO 1 +/* Alternative name for Unix98. */ +#define _LFS_ASYNCHRONOUS_IO 1 +/* Support for prioritization is also available. */ +#define _POSIX_PRIORITIZED_IO 200809L + +/* The LFS support in asynchronous I/O is also available. */ +#define _LFS64_ASYNCHRONOUS_IO 1 + +/* The rest of the LFS is also available. */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 + +/* POSIX shared memory objects are implemented. */ +#define _POSIX_SHARED_MEMORY_OBJECTS 200809L + +/* CPU-time clocks support needs to be checked at runtime. */ +#define _POSIX_CPUTIME 0 + +/* Clock support in threads must be also checked at runtime. */ +#define _POSIX_THREAD_CPUTIME 0 + +/* GNU libc provides regular expression handling. */ +#define _POSIX_REGEXP 1 + +/* Reader/Writer locks are available. */ +#define _POSIX_READER_WRITER_LOCKS 200809L + +/* We have a POSIX shell. */ +#define _POSIX_SHELL 1 + +/* We support the Timeouts option. */ +#define _POSIX_TIMEOUTS 200809L + +/* We support spinlocks. */ +#define _POSIX_SPIN_LOCKS 200809L + +/* The `spawn' function family is supported. */ +#define _POSIX_SPAWN 200809L + +/* We have POSIX timers. */ +#define _POSIX_TIMERS 200809L + +/* The barrier functions are available. */ +#define _POSIX_BARRIERS 200809L + +/* POSIX message queues are available. */ +#define _POSIX_MESSAGE_PASSING 200809L + +/* Thread process-shared synchronization is supported. */ +#define _POSIX_THREAD_PROCESS_SHARED 200809L + +/* The monotonic clock might be available. */ +#define _POSIX_MONOTONIC_CLOCK 0 + +/* The clock selection interfaces are available. */ +#define _POSIX_CLOCK_SELECTION 200809L + +/* Advisory information interfaces are available. */ +#define _POSIX_ADVISORY_INFO 200809L + +/* IPv6 support is available. */ +#define _POSIX_IPV6 200809L + +/* Raw socket support is available. */ +#define _POSIX_RAW_SOCKETS 200809L + +/* We have at least one terminal. */ +#define _POSIX2_CHAR_TERM 200809L + +/* Neither process nor thread sporadic server interfaces is available. */ +#define _POSIX_SPORADIC_SERVER -1 +#define _POSIX_THREAD_SPORADIC_SERVER -1 + +/* trace.h is not available. */ +#define _POSIX_TRACE -1 +#define _POSIX_TRACE_EVENT_FILTER -1 +#define _POSIX_TRACE_INHERIT -1 +#define _POSIX_TRACE_LOG -1 + +/* Typed memory objects are not available. */ +#define _POSIX_TYPED_MEMORY_OBJECTS -1 + +#endif /* bits/posix_opt.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bea7f464f341641fcf889137ba5fd17609e56529 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@posix_opt.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h new file mode 100644 index 0000000000000000000000000000000000000000..12c4ae22391e140873d4cc3c6104226bb2807c27 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h @@ -0,0 +1,31 @@ +/* Definition of PTHREAD_STACK_MIN, possibly dynamic. + Copyright (C) 2021-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef PTHREAD_STACK_MIN +# if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE +# ifndef __ASSEMBLER__ +# define __SC_THREAD_STACK_MIN_VALUE 75 +__BEGIN_DECLS +extern long int __sysconf (int __name) __THROW; +__END_DECLS +# define PTHREAD_STACK_MIN __sysconf (__SC_THREAD_STACK_MIN_VALUE) +# endif +# else +# include +# endif +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..062a77729bbc585e7c69047a2101337b32d1bc0e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthread_stack_min-dynamic.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h new file mode 100644 index 0000000000000000000000000000000000000000..dd06d6753ebc80d94ede6c3c18227a3ad3104570 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2002-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_PTHREADTYPES_ARCH_H +#define _BITS_PTHREADTYPES_ARCH_H 1 + +#include + +#ifdef __x86_64__ +# if __WORDSIZE == 64 +# define __SIZEOF_PTHREAD_MUTEX_T 40 +# define __SIZEOF_PTHREAD_ATTR_T 56 +# define __SIZEOF_PTHREAD_RWLOCK_T 56 +# define __SIZEOF_PTHREAD_BARRIER_T 32 +# else +# define __SIZEOF_PTHREAD_MUTEX_T 32 +# define __SIZEOF_PTHREAD_ATTR_T 32 +# define __SIZEOF_PTHREAD_RWLOCK_T 44 +# define __SIZEOF_PTHREAD_BARRIER_T 20 +# endif +#else +# define __SIZEOF_PTHREAD_MUTEX_T 24 +# define __SIZEOF_PTHREAD_ATTR_T 36 +# define __SIZEOF_PTHREAD_RWLOCK_T 32 +# define __SIZEOF_PTHREAD_BARRIER_T 20 +#endif +#define __SIZEOF_PTHREAD_MUTEXATTR_T 4 +#define __SIZEOF_PTHREAD_COND_T 48 +#define __SIZEOF_PTHREAD_CONDATTR_T 4 +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4 + +#define __LOCK_ALIGNMENT +#define __ONCE_ALIGNMENT + +#ifndef __x86_64__ +/* Extra attributes for the cleanup functions. */ +# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1))) +#endif + +#endif /* bits/pthreadtypes.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..10a015f2935785ee5c86bfcc88a0e4985c529234 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes-arch.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h new file mode 100644 index 0000000000000000000000000000000000000000..6f8907fe5427d7376bc6488d512ceda7b11317c7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h @@ -0,0 +1,121 @@ +/* Declaration of common pthread types for all architectures. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_PTHREADTYPES_COMMON_H +# define _BITS_PTHREADTYPES_COMMON_H 1 + +/* For internal mutex and condition variable definitions. */ +#include + +/* Thread identifiers. The structure of the attribute type is not + exposed on purpose. */ +typedef unsigned long int pthread_t; + + +/* Data structures for mutex handling. The structure of the attribute + type is not exposed on purpose. */ +typedef union +{ + char __size[__SIZEOF_PTHREAD_MUTEXATTR_T]; + int __align; +} pthread_mutexattr_t; + + +/* Data structure for condition variable handling. The structure of + the attribute type is not exposed on purpose. */ +typedef union +{ + char __size[__SIZEOF_PTHREAD_CONDATTR_T]; + int __align; +} pthread_condattr_t; + + +/* Keys for thread-specific data */ +typedef unsigned int pthread_key_t; + + +/* Once-only execution */ +typedef int __ONCE_ALIGNMENT pthread_once_t; + + +union pthread_attr_t +{ + char __size[__SIZEOF_PTHREAD_ATTR_T]; + long int __align; +}; +#ifndef __have_pthread_attr_t +typedef union pthread_attr_t pthread_attr_t; +# define __have_pthread_attr_t 1 +#endif + + +typedef union +{ + struct __pthread_mutex_s __data; + char __size[__SIZEOF_PTHREAD_MUTEX_T]; + long int __align; +} pthread_mutex_t; + + +typedef union +{ + struct __pthread_cond_s __data; + char __size[__SIZEOF_PTHREAD_COND_T]; + __extension__ long long int __align; +} pthread_cond_t; + + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +/* Data structure for reader-writer lock variable handling. The + structure of the attribute type is deliberately not exposed. */ +typedef union +{ + struct __pthread_rwlock_arch_t __data; + char __size[__SIZEOF_PTHREAD_RWLOCK_T]; + long int __align; +} pthread_rwlock_t; + +typedef union +{ + char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T]; + long int __align; +} pthread_rwlockattr_t; +#endif + + +#ifdef __USE_XOPEN2K +/* POSIX spinlock data type. */ +typedef volatile int pthread_spinlock_t; + + +/* POSIX barriers data type. The structure of the type is + deliberately not exposed. */ +typedef union +{ + char __size[__SIZEOF_PTHREAD_BARRIER_T]; + long int __align; +} pthread_barrier_t; + +typedef union +{ + char __size[__SIZEOF_PTHREAD_BARRIERATTR_T]; + int __align; +} pthread_barrierattr_t; +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..25f68e249931e217ecf1ebc2edbe19f39c450846 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@pthreadtypes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h new file mode 100644 index 0000000000000000000000000000000000000000..f13c569863a60006096fac7eb6eb487283132255 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h @@ -0,0 +1,100 @@ +/* Definitions of constants and data structure for POSIX 1003.1b-1993 + scheduling interface. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SCHED_H +#define _BITS_SCHED_H 1 + +#ifndef _SCHED_H +# error "Never include directly; use instead." +#endif + +/* Scheduling algorithms. */ +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 +#ifdef __USE_GNU +# define SCHED_BATCH 3 +# define SCHED_ISO 4 +# define SCHED_IDLE 5 +# define SCHED_DEADLINE 6 + +# define SCHED_RESET_ON_FORK 0x40000000 +#endif + +#ifdef __USE_GNU +/* Cloning flags. */ +# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */ +# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */ +# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */ +# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */ +# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */ +# define CLONE_PIDFD 0x00001000 /* Set if a pidfd should be placed + in parent. */ +# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */ +# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to + wake it up on mm_release. */ +# define CLONE_PARENT 0x00008000 /* Set if we want to have the same + parent as the cloner. */ +# define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */ +# define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */ +# define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */ +# define CLONE_SETTLS 0x00080000 /* Set TLS info. */ +# define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer + before MM copy. */ +# define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory + location to clear. */ +# define CLONE_DETACHED 0x00400000 /* Create clone detached. */ +# define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't + force CLONE_PTRACE on this clone. */ +# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in + the child. */ +# define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace. */ +# define CLONE_NEWUTS 0x04000000 /* New utsname group. */ +# define CLONE_NEWIPC 0x08000000 /* New ipcs. */ +# define CLONE_NEWUSER 0x10000000 /* New user namespace. */ +# define CLONE_NEWPID 0x20000000 /* New pid namespace. */ +# define CLONE_NEWNET 0x40000000 /* New network namespace. */ +# define CLONE_IO 0x80000000 /* Clone I/O context. */ +#endif + +#include + +__BEGIN_DECLS + +#ifdef __USE_GNU +/* Clone current process. */ +extern int clone (int (*__fn) (void *__arg), void *__child_stack, + int __flags, void *__arg, ...) __THROW; + +/* Unshare the specified resources. */ +extern int unshare (int __flags) __THROW; + +/* Get index of currently used CPU. */ +extern int sched_getcpu (void) __THROW; + +/* Get currently used CPU and NUMA node. */ +extern int getcpu (unsigned int *, unsigned int *) __THROW; + +/* Switch process to namespace of type NSTYPE indicated by FD. */ +extern int setns (int __fd, int __nstype) __THROW; +#endif + +__END_DECLS + +#endif /* bits/sched.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ec9dc9faadf618e8c19252cdd5c6084465f335dc Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sched.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h new file mode 100644 index 0000000000000000000000000000000000000000..9afd878eb6f93b99b49f9dab5667291e35c11455 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h @@ -0,0 +1,37 @@ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_SELECT_H +# error "Never use directly; include instead." +#endif + + +/* We don't use `memset' because this would require a prototype and + the array isn't too big. */ +#define __FD_ZERO(s) \ + do { \ + unsigned int __i; \ + fd_set *__arr = (s); \ + for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \ + __FDS_BITS (__arr)[__i] = 0; \ + } while (0) +#define __FD_SET(d, s) \ + ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d))) +#define __FD_CLR(d, s) \ + ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d))) +#define __FD_ISSET(d, s) \ + ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0) diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1dbf493b82c0e79b94be1a40a83c62a974bc20d6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@select.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h new file mode 100644 index 0000000000000000000000000000000000000000..dab8771bdbdf8eb77eca086eaa1847c0b31e49e5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2001-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Define the machine-dependent type `jmp_buf'. x86-64 version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H +# error "Never include directly; use instead." +#endif + +#include + +#ifndef _ASM + +# if __WORDSIZE == 64 +typedef long int __jmp_buf[8]; +# elif defined __x86_64__ +__extension__ typedef long long int __jmp_buf[8]; +# else +typedef int __jmp_buf[6]; +# endif + +#endif + +#endif /* bits/setjmp.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c686197d497893a7c79df9282a85909ded76a10e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@setjmp.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h new file mode 100644 index 0000000000000000000000000000000000000000..3f19d6a1a18e54f60b0c608d36574fe6b66a6e10 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h @@ -0,0 +1,83 @@ +/* The proper definitions for Linux's sigaction. + Copyright (C) 1993-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGACTION_H +#define _BITS_SIGACTION_H 1 + +#ifndef _SIGNAL_H +# error "Never include directly; use instead." +#endif + +/* Structure describing the action to be taken when a signal arrives. */ +struct sigaction + { + /* Signal handler. */ +#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED + union + { + /* Used if SA_SIGINFO is not set. */ + __sighandler_t sa_handler; + /* Used if SA_SIGINFO is set. */ + void (*sa_sigaction) (int, siginfo_t *, void *); + } + __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction +#else + __sighandler_t sa_handler; +#endif + + /* Additional set of signals to be blocked. */ + __sigset_t sa_mask; + + /* Special flags. */ + int sa_flags; + + /* Restore handler. */ + void (*sa_restorer) (void); + }; + +/* Bits in `sa_flags'. */ +#define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */ +#define SA_NOCLDWAIT 2 /* Don't create zombie on child death. */ +#define SA_SIGINFO 4 /* Invoke signal-catching function with + three arguments instead of one. */ +#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC +# define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */ +#endif +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +# define SA_RESTART 0x10000000 /* Restart syscall on signal return. */ +# define SA_NODEFER 0x40000000 /* Don't automatically block the signal when + its handler is being executed. */ +# define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */ +#endif +#ifdef __USE_MISC +# define SA_INTERRUPT 0x20000000 /* Historical no-op. */ + +/* Some aliases for the SA_ constants. */ +# define SA_NOMASK SA_NODEFER +# define SA_ONESHOT SA_RESETHAND +# define SA_STACK SA_ONSTACK +#endif + +/* Values for the HOW argument to `sigprocmask'. */ +#define SIG_BLOCK 0 /* Block signals. */ +#define SIG_UNBLOCK 1 /* Unblock signals. */ +#define SIG_SETMASK 2 /* Set the set of blocked signals. */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a3c172b20c71c011c933c5d644ecabe34b766846 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigaction.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h new file mode 100644 index 0000000000000000000000000000000000000000..d410e134645b3b16a30cf494e4d71fced0d3ee2d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h @@ -0,0 +1,196 @@ +/* Copyright (C) 2002-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGCONTEXT_H +#define _BITS_SIGCONTEXT_H 1 + +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H +# error "Never use directly; include instead." +#endif + +#include + +#define FP_XSTATE_MAGIC1 0x46505853U +#define FP_XSTATE_MAGIC2 0x46505845U +#define FP_XSTATE_MAGIC2_SIZE sizeof (FP_XSTATE_MAGIC2) + +struct _fpx_sw_bytes +{ + __uint32_t magic1; + __uint32_t extended_size; + __uint64_t xstate_bv; + __uint32_t xstate_size; + __uint32_t __glibc_reserved1[7]; +}; + +struct _fpreg +{ + unsigned short significand[4]; + unsigned short exponent; +}; + +struct _fpxreg +{ + unsigned short significand[4]; + unsigned short exponent; + unsigned short __glibc_reserved1[3]; +}; + +struct _xmmreg +{ + __uint32_t element[4]; +}; + + + +#ifndef __x86_64__ + +struct _fpstate +{ + /* Regular FPU environment. */ + __uint32_t cw; + __uint32_t sw; + __uint32_t tag; + __uint32_t ipoff; + __uint32_t cssel; + __uint32_t dataoff; + __uint32_t datasel; + struct _fpreg _st[8]; + unsigned short status; + unsigned short magic; + + /* FXSR FPU environment. */ + __uint32_t _fxsr_env[6]; + __uint32_t mxcsr; + __uint32_t __glibc_reserved1; + struct _fpxreg _fxsr_st[8]; + struct _xmmreg _xmm[8]; + __uint32_t __glibc_reserved2[56]; +}; + +#ifndef sigcontext_struct +/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but + we need sigcontext. Some packages have come to rely on + sigcontext_struct being defined on 32-bit x86, so define this for + their benefit. */ +# define sigcontext_struct sigcontext +#endif + +#define X86_FXSR_MAGIC 0x0000 + +struct sigcontext +{ + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + struct _fpstate * fpstate; + unsigned long oldmask; + unsigned long cr2; +}; + +#else /* __x86_64__ */ + +struct _fpstate +{ + /* FPU environment matching the 64-bit FXSAVE layout. */ + __uint16_t cwd; + __uint16_t swd; + __uint16_t ftw; + __uint16_t fop; + __uint64_t rip; + __uint64_t rdp; + __uint32_t mxcsr; + __uint32_t mxcr_mask; + struct _fpxreg _st[8]; + struct _xmmreg _xmm[16]; + __uint32_t __glibc_reserved1[24]; +}; + +struct sigcontext +{ + __uint64_t r8; + __uint64_t r9; + __uint64_t r10; + __uint64_t r11; + __uint64_t r12; + __uint64_t r13; + __uint64_t r14; + __uint64_t r15; + __uint64_t rdi; + __uint64_t rsi; + __uint64_t rbp; + __uint64_t rbx; + __uint64_t rdx; + __uint64_t rax; + __uint64_t rcx; + __uint64_t rsp; + __uint64_t rip; + __uint64_t eflags; + unsigned short cs; + unsigned short gs; + unsigned short fs; + unsigned short __pad0; + __uint64_t err; + __uint64_t trapno; + __uint64_t oldmask; + __uint64_t cr2; + __extension__ union + { + struct _fpstate * fpstate; + __uint64_t __fpstate_word; + }; + __uint64_t __reserved1 [8]; +}; + +#endif /* __x86_64__ */ + +struct _xsave_hdr +{ + __uint64_t xstate_bv; + __uint64_t __glibc_reserved1[2]; + __uint64_t __glibc_reserved2[5]; +}; + +struct _ymmh_state +{ + __uint32_t ymmh_space[64]; +}; + +struct _xstate +{ + struct _fpstate fpstate; + struct _xsave_hdr xstate_hdr; + struct _ymmh_state ymmh; +}; + +#endif /* _BITS_SIGCONTEXT_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b5df11046fa6dc503a6befb9cfc60502d0f5b0a9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigcontext.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h new file mode 100644 index 0000000000000000000000000000000000000000..78f4f10b3fb46280dde7a3b2edff7184fe45782a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h @@ -0,0 +1,41 @@ +/* sigevent constants. Linux version. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGEVENT_CONSTS_H +#define _BITS_SIGEVENT_CONSTS_H 1 + +#if !defined _SIGNAL_H && !defined _AIO_H +#error "Don't include directly; use instead." +#endif + +/* `sigev_notify' values. */ +enum +{ + SIGEV_SIGNAL = 0, /* Notify via signal. */ +# define SIGEV_SIGNAL SIGEV_SIGNAL + SIGEV_NONE, /* Other notification: meaningless. */ +# define SIGEV_NONE SIGEV_NONE + SIGEV_THREAD, /* Deliver via thread creation. */ +# define SIGEV_THREAD SIGEV_THREAD + + SIGEV_THREAD_ID = 4 /* Send signal to specific thread. + This is a Linux extension. */ +#define SIGEV_THREAD_ID SIGEV_THREAD_ID +}; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..66653d6188786c20e7d9c1e1161ca33bf32af5d9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigevent-consts.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h new file mode 100644 index 0000000000000000000000000000000000000000..7688a8d66d6e6ea790a54414500774664fa28e0a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h @@ -0,0 +1,17 @@ +/* Architecture-specific adjustments to siginfo_t. x86 version. */ +#ifndef _BITS_SIGINFO_ARCH_H +#define _BITS_SIGINFO_ARCH_H 1 + +#if defined __x86_64__ && __WORDSIZE == 32 +/* si_utime and si_stime must be 4 byte aligned for x32 to match the + kernel. We align siginfo_t to 8 bytes so that si_utime and + si_stime are actually aligned to 8 bytes since their offsets are + multiple of 8 bytes. Note: with some compilers, the alignment + attribute would be ignored if it were put in __SI_CLOCK_T instead + of encapsulated in a typedef. */ +typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t; +# define __SI_ALIGNMENT __attribute__ ((__aligned__ (8))) +# define __SI_CLOCK_T __sigchld_clock_t +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3116ab28d8063649e702c2f44725570637f98e38 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-arch.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h new file mode 100644 index 0000000000000000000000000000000000000000..96b4edbccde65554c1164d7d5d7019ad503f4683 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h @@ -0,0 +1,7 @@ +/* Architecture-specific additional siginfo constants. */ +#ifndef _BITS_SIGINFO_CONSTS_ARCH_H +#define _BITS_SIGINFO_CONSTS_ARCH_H 1 + +/* This architecture has no additional siginfo constants. */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c8756a772bc123f9f485fb61a5879f92e2cc17d3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts-arch.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h new file mode 100644 index 0000000000000000000000000000000000000000..b114eb3015aa85eed6cbe735d113a5468f7e7368 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h @@ -0,0 +1,216 @@ +/* siginfo constants. Linux version. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGINFO_CONSTS_H +#define _BITS_SIGINFO_CONSTS_H 1 + +#ifndef _SIGNAL_H +#error "Don't include directly; use instead." +#endif + +/* Most of these constants are uniform across all architectures, but there + is one exception. */ +#include +#ifndef __SI_ASYNCIO_AFTER_SIGIO +# define __SI_ASYNCIO_AFTER_SIGIO 1 +#endif + +/* Values for `si_code'. Positive values are reserved for kernel-generated + signals. */ +enum +{ + SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */ + SI_DETHREAD = -7, /* Sent by execve killing subsidiary + threads. */ + SI_TKILL, /* Sent by tkill. */ + SI_SIGIO, /* Sent by queued SIGIO. */ +#if __SI_ASYNCIO_AFTER_SIGIO + SI_ASYNCIO, /* Sent by AIO completion. */ + SI_MESGQ, /* Sent by real time mesq state change. */ + SI_TIMER, /* Sent by timer expiration. */ +#else + SI_MESGQ, + SI_TIMER, + SI_ASYNCIO, +#endif + SI_QUEUE, /* Sent by sigqueue. */ + SI_USER, /* Sent by kill, sigsend. */ + SI_KERNEL = 0x80 /* Send by kernel. */ + +#define SI_ASYNCNL SI_ASYNCNL +#define SI_DETHREAD SI_DETHREAD +#define SI_TKILL SI_TKILL +#define SI_SIGIO SI_SIGIO +#define SI_ASYNCIO SI_ASYNCIO +#define SI_MESGQ SI_MESGQ +#define SI_TIMER SI_TIMER +#define SI_ASYNCIO SI_ASYNCIO +#define SI_QUEUE SI_QUEUE +#define SI_USER SI_USER +#define SI_KERNEL SI_KERNEL +}; + + +# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* `si_code' values for SIGILL signal. */ +enum +{ + ILL_ILLOPC = 1, /* Illegal opcode. */ +# define ILL_ILLOPC ILL_ILLOPC + ILL_ILLOPN, /* Illegal operand. */ +# define ILL_ILLOPN ILL_ILLOPN + ILL_ILLADR, /* Illegal addressing mode. */ +# define ILL_ILLADR ILL_ILLADR + ILL_ILLTRP, /* Illegal trap. */ +# define ILL_ILLTRP ILL_ILLTRP + ILL_PRVOPC, /* Privileged opcode. */ +# define ILL_PRVOPC ILL_PRVOPC + ILL_PRVREG, /* Privileged register. */ +# define ILL_PRVREG ILL_PRVREG + ILL_COPROC, /* Coprocessor error. */ +# define ILL_COPROC ILL_COPROC + ILL_BADSTK, /* Internal stack error. */ +# define ILL_BADSTK ILL_BADSTK + ILL_BADIADDR /* Unimplemented instruction address. */ +# define ILL_BADIADDR ILL_BADIADDR +}; + +/* `si_code' values for SIGFPE signal. */ +enum +{ + FPE_INTDIV = 1, /* Integer divide by zero. */ +# define FPE_INTDIV FPE_INTDIV + FPE_INTOVF, /* Integer overflow. */ +# define FPE_INTOVF FPE_INTOVF + FPE_FLTDIV, /* Floating point divide by zero. */ +# define FPE_FLTDIV FPE_FLTDIV + FPE_FLTOVF, /* Floating point overflow. */ +# define FPE_FLTOVF FPE_FLTOVF + FPE_FLTUND, /* Floating point underflow. */ +# define FPE_FLTUND FPE_FLTUND + FPE_FLTRES, /* Floating point inexact result. */ +# define FPE_FLTRES FPE_FLTRES + FPE_FLTINV, /* Floating point invalid operation. */ +# define FPE_FLTINV FPE_FLTINV + FPE_FLTSUB, /* Subscript out of range. */ +# define FPE_FLTSUB FPE_FLTSUB + FPE_FLTUNK = 14, /* Undiagnosed floating-point exception. */ +# define FPE_FLTUNK FPE_FLTUNK + FPE_CONDTRAP /* Trap on condition. */ +# define FPE_CONDTRAP FPE_CONDTRAP +}; + +/* `si_code' values for SIGSEGV signal. */ +enum +{ + SEGV_MAPERR = 1, /* Address not mapped to object. */ +# define SEGV_MAPERR SEGV_MAPERR + SEGV_ACCERR, /* Invalid permissions for mapped object. */ +# define SEGV_ACCERR SEGV_ACCERR + SEGV_BNDERR, /* Bounds checking failure. */ +# define SEGV_BNDERR SEGV_BNDERR + SEGV_PKUERR, /* Protection key checking failure. */ +# define SEGV_PKUERR SEGV_PKUERR + SEGV_ACCADI, /* ADI not enabled for mapped object. */ +# define SEGV_ACCADI SEGV_ACCADI + SEGV_ADIDERR, /* Disrupting MCD error. */ +# define SEGV_ADIDERR SEGV_ADIDERR + SEGV_ADIPERR, /* Precise MCD exception. */ +# define SEGV_ADIPERR SEGV_ADIPERR + SEGV_MTEAERR, /* Asynchronous ARM MTE error. */ +# define SEGV_MTEAERR SEGV_MTEAERR + SEGV_MTESERR /* Synchronous ARM MTE exception. */ +# define SEGV_MTESERR SEGV_MTESERR +}; + +/* `si_code' values for SIGBUS signal. */ +enum +{ + BUS_ADRALN = 1, /* Invalid address alignment. */ +# define BUS_ADRALN BUS_ADRALN + BUS_ADRERR, /* Non-existant physical address. */ +# define BUS_ADRERR BUS_ADRERR + BUS_OBJERR, /* Object specific hardware error. */ +# define BUS_OBJERR BUS_OBJERR + BUS_MCEERR_AR, /* Hardware memory error: action required. */ +# define BUS_MCEERR_AR BUS_MCEERR_AR + BUS_MCEERR_AO /* Hardware memory error: action optional. */ +# define BUS_MCEERR_AO BUS_MCEERR_AO +}; +# endif + +# ifdef __USE_XOPEN_EXTENDED +/* `si_code' values for SIGTRAP signal. */ +enum +{ + TRAP_BRKPT = 1, /* Process breakpoint. */ +# define TRAP_BRKPT TRAP_BRKPT + TRAP_TRACE, /* Process trace trap. */ +# define TRAP_TRACE TRAP_TRACE + TRAP_BRANCH, /* Process taken branch trap. */ +# define TRAP_BRANCH TRAP_BRANCH + TRAP_HWBKPT, /* Hardware breakpoint/watchpoint. */ +# define TRAP_HWBKPT TRAP_HWBKPT + TRAP_UNK /* Undiagnosed trap. */ +# define TRAP_UNK TRAP_UNK +}; +# endif + +# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* `si_code' values for SIGCHLD signal. */ +enum +{ + CLD_EXITED = 1, /* Child has exited. */ +# define CLD_EXITED CLD_EXITED + CLD_KILLED, /* Child was killed. */ +# define CLD_KILLED CLD_KILLED + CLD_DUMPED, /* Child terminated abnormally. */ +# define CLD_DUMPED CLD_DUMPED + CLD_TRAPPED, /* Traced child has trapped. */ +# define CLD_TRAPPED CLD_TRAPPED + CLD_STOPPED, /* Child has stopped. */ +# define CLD_STOPPED CLD_STOPPED + CLD_CONTINUED /* Stopped child has continued. */ +# define CLD_CONTINUED CLD_CONTINUED +}; + +/* `si_code' values for SIGPOLL signal. */ +enum +{ + POLL_IN = 1, /* Data input available. */ +# define POLL_IN POLL_IN + POLL_OUT, /* Output buffers available. */ +# define POLL_OUT POLL_OUT + POLL_MSG, /* Input message available. */ +# define POLL_MSG POLL_MSG + POLL_ERR, /* I/O error. */ +# define POLL_ERR POLL_ERR + POLL_PRI, /* High priority input available. */ +# define POLL_PRI POLL_PRI + POLL_HUP /* Device disconnected. */ +# define POLL_HUP POLL_HUP +}; +# endif + +/* Architectures might also add architecture-specific constants. + These are all considered GNU extensions. */ +#ifdef __USE_GNU +# include +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..15905f4e4894a22123a8bc4e78eb077d6c6a87e1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@siginfo-consts.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h new file mode 100644 index 0000000000000000000000000000000000000000..4356455e5819c0d7af8bf82f9d71887bdf680ea9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h @@ -0,0 +1,31 @@ +/* System-specific extensions of , Linux version. + Copyright (C) 2019-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SIGNAL_H +# error "Never include directly; use instead." +#endif + +#ifdef __USE_GNU + +/* Send SIGNAL to the thread TID in the thread group (process) + identified by TGID. This function behaves like kill, but also + fails with ESRCH if the specified TID does not belong to the + specified thread group. */ +extern int tgkill (__pid_t __tgid, __pid_t __tid, int __signal); + +#endif /* __USE_GNU */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8045836d57d9918012b3ec022ec48f45d200394d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signal_ext.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h new file mode 100644 index 0000000000000000000000000000000000000000..097e35c6bf8ddb0c5e8d9fe07ebcd680b2dcf89c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h @@ -0,0 +1,64 @@ +/* Signal number definitions. Linux version. + Copyright (C) 1995-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGNUM_ARCH_H +#define _BITS_SIGNUM_ARCH_H 1 + +#ifndef _SIGNAL_H +#error "Never include directly; use instead." +#endif + +/* Adjustments and additions to the signal number constants for + most Linux systems. */ + +#define SIGSTKFLT 16 /* Stack fault (obsolete). */ +#define SIGPWR 30 /* Power failure imminent. */ + +/* Historical signals specified by POSIX. */ +#define SIGBUS 7 /* Bus error. */ +#define SIGSYS 31 /* Bad system call. */ + +/* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */ +#define SIGURG 23 /* Urgent data is available at a socket. */ +#define SIGSTOP 19 /* Stop, unblockable. */ +#define SIGTSTP 20 /* Keyboard stop. */ +#define SIGCONT 18 /* Continue. */ +#define SIGCHLD 17 /* Child terminated or stopped. */ +#define SIGTTIN 21 /* Background read from control terminal. */ +#define SIGTTOU 22 /* Background write to control terminal. */ +#define SIGPOLL 29 /* Pollable event occurred (System V). */ +#define SIGXFSZ 25 /* File size limit exceeded. */ +#define SIGXCPU 24 /* CPU time limit exceeded. */ +#define SIGVTALRM 26 /* Virtual timer expired. */ +#define SIGPROF 27 /* Profiling timer expired. */ +#define SIGUSR1 10 /* User-defined signal 1. */ +#define SIGUSR2 12 /* User-defined signal 2. */ + +/* Nonstandard signals found in all modern POSIX systems + (including both BSD and Linux). */ +#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ + +/* Archaic names for compatibility. */ +#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */ +#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */ +#define SIGCLD SIGCHLD /* Old System V name */ + +#define __SIGRTMIN 32 +#define __SIGRTMAX 64 + +#endif /* included. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bcca4da9c62d4b4981d935ad4ffe69b0f58d266b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-arch.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h new file mode 100644 index 0000000000000000000000000000000000000000..4628536d583c15ad5d420a1bc8308c7efdbdab85 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h @@ -0,0 +1,81 @@ +/* Signal number constants. Generic template. + Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGNUM_GENERIC_H +#define _BITS_SIGNUM_GENERIC_H 1 + +#ifndef _SIGNAL_H +#error "Never include directly; use instead." +#endif + +/* Fake signal functions. */ + +#define SIG_ERR ((__sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((__sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ + +#ifdef __USE_XOPEN +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + +/* We define here all the signal names listed in POSIX (1003.1-2008); + as of 1003.1-2013, no additional signals have been added by POSIX. + We also define here signal names that historically exist in every + real-world POSIX variant (e.g. SIGWINCH). + + Signals in the 1-15 range are defined with their historical numbers. + For other signals, we use the BSD numbers. + There are two unallocated signal numbers in the 1-31 range: 7 and 29. + Signal number 0 is reserved for use as kill(pid, 0), to test whether + a process exists without sending it a signal. */ + +/* ISO C99 signals. */ +#define SIGINT 2 /* Interactive attention signal. */ +#define SIGILL 4 /* Illegal instruction. */ +#define SIGABRT 6 /* Abnormal termination. */ +#define SIGFPE 8 /* Erroneous arithmetic operation. */ +#define SIGSEGV 11 /* Invalid access to storage. */ +#define SIGTERM 15 /* Termination request. */ + +/* Historical signals specified by POSIX. */ +#define SIGHUP 1 /* Hangup. */ +#define SIGQUIT 3 /* Quit. */ +#define SIGTRAP 5 /* Trace/breakpoint trap. */ +#define SIGKILL 9 /* Killed. */ +#define SIGPIPE 13 /* Broken pipe. */ +#define SIGALRM 14 /* Alarm clock. */ + +/* Archaic names for compatibility. */ +#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */ +#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */ +#define SIGCLD SIGCHLD /* Old System V name */ + +/* Not all systems support real-time signals. bits/signum.h indicates + that they are supported by overriding __SIGRTMAX to a value greater + than __SIGRTMIN. These constants give the kernel-level hard limits, + but some real-time signals may be used internally by glibc. Do not + use these constants in application code; use SIGRTMIN and SIGRTMAX + (defined in signal.h) instead. */ + +/* Include system specific bits. */ +#include + +/* Biggest signal number + 1 (including real-time signals). */ +#define _NSIG (__SIGRTMAX + 1) + +#endif /* bits/signum-generic.h. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c20d8c6b8e319a9f62f7cfd81f9b1b62e5924436 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@signum-generic.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h new file mode 100644 index 0000000000000000000000000000000000000000..16c630b9a67e17588972ba72d2f7acf912ad446d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h @@ -0,0 +1,32 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 1998-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SIGSTACK_H +#define _BITS_SIGSTACK_H 1 + +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H +# error "Never include this file directly. Use instead" +#endif + +/* Minimum stack size for a signal handler. */ +#define MINSIGSTKSZ 2048 + +/* System default stack size. */ +#define SIGSTKSZ 8192 + +#endif /* bits/sigstack.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ff8b0957e84bba819cf3ccf88e16ae8d8149fe25 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstack.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h new file mode 100644 index 0000000000000000000000000000000000000000..a19b51c008fea0fcc6af6c5ac9fe9cc57329a626 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h @@ -0,0 +1,33 @@ +/* Definition of MINSIGSTKSZ and SIGSTKSZ. Linux version. + Copyright (C) 2020-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SIGNAL_H +# error "Never include directly; use instead." +#endif + +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE +# include + +/* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */ +# undef SIGSTKSZ +# define SIGSTKSZ sysconf (_SC_SIGSTKSZ) + +/* Minimum stack size for a signal handler: SIGSTKSZ. */ +# undef MINSIGSTKSZ +# define MINSIGSTKSZ SIGSTKSZ +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6a600e63ee91058fb33860a94a2d92a165ee369e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigstksz.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h new file mode 100644 index 0000000000000000000000000000000000000000..cf51f928d002059b1b85d7a4fc493638dbf657fd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h @@ -0,0 +1,44 @@ +/* Signal handling function for threaded programs. + Copyright (C) 1998-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#ifndef _BITS_SIGTHREAD_H +#define _BITS_SIGTHREAD_H 1 + +#if !defined _SIGNAL_H && !defined _PTHREAD_H +# error "Never include this file directly. Use instead" +#endif + +/* Functions for handling signals. */ +#include + +/* Modify the signal mask for the calling thread. The arguments have + the same meaning as for sigprocmask(2). */ +extern int pthread_sigmask (int __how, + const __sigset_t *__restrict __newmask, + __sigset_t *__restrict __oldmask)__THROW; + +/* Send signal SIGNO to the given thread. */ +extern int pthread_kill (pthread_t __threadid, int __signo) __THROW; + +#ifdef __USE_GNU +/* Queue signal and data to a thread. */ +extern int pthread_sigqueue (pthread_t __threadid, int __signo, + const union sigval __value) __THROW; +#endif + +#endif /* bits/sigthread.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..81f4789d7c38d846272e9553c2f7aba348d61898 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@sigthread.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h new file mode 100644 index 0000000000000000000000000000000000000000..0a2b427e5fae127a0ba2811bca760bc46a542fec --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h @@ -0,0 +1,35 @@ +/* ss_flags values for stack_t. Linux version. + Copyright (C) 1998-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_SS_FLAGS_H +#define _BITS_SS_FLAGS_H 1 + +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H +# error "Never include this file directly. Use instead" +#endif + +/* Possible values for `ss_flags'. */ +enum +{ + SS_ONSTACK = 1, +#define SS_ONSTACK SS_ONSTACK + SS_DISABLE +#define SS_DISABLE SS_DISABLE +}; + +#endif /* bits/ss_flags.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4538b2d37aa78fa09aea586815011f8b5e256007 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@ss_flags.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h new file mode 100644 index 0000000000000000000000000000000000000000..599e2806f8b042bef5956a52c7a1e7e0dbb2cfb3 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h @@ -0,0 +1,29 @@ +/* Define intN_t types. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_STDINT_INTN_H +#define _BITS_STDINT_INTN_H 1 + +#include + +typedef __int8_t int8_t; +typedef __int16_t int16_t; +typedef __int32_t int32_t; +typedef __int64_t int64_t; + +#endif /* bits/stdint-intn.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..76fa070535ef915a021d16bc94c84eb6ab0ca2ca Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-intn.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h new file mode 100644 index 0000000000000000000000000000000000000000..c2846aac3550571c1f1ced63b6c2961d27f20993 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h @@ -0,0 +1,29 @@ +/* Define uintN_t types. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_STDINT_UINTN_H +#define _BITS_STDINT_UINTN_H 1 + +#include + +typedef __uint8_t uint8_t; +typedef __uint16_t uint16_t; +typedef __uint32_t uint32_t; +typedef __uint64_t uint64_t; + +#endif /* bits/stdint-uintn.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..093034a973d48dab303474845ed7a1a78e8e009f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdint-uintn.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..4ef3ebb568d77c863b72aa4b1fda1e111bfe77d0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h @@ -0,0 +1,39 @@ +/* Copyright (C) 1994-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_STDIO_LIM_H +#define _BITS_STDIO_LIM_H 1 + +#ifndef _STDIO_H +# error "Never include directly; use instead." +#endif + +#define L_tmpnam 20 +#define TMP_MAX 238328 +#define FILENAME_MAX 4096 + +#ifdef __USE_POSIX +# define L_ctermid 9 +# if !defined __USE_XOPEN2K || defined __USE_GNU +# define L_cuserid 9 +# endif +#endif + +#undef FOPEN_MAX +#define FOPEN_MAX 16 + +#endif /* bits/stdio_lim.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f2724fb6cd5a2d51577c3bf1c85b0e13709901a2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdio_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h new file mode 100644 index 0000000000000000000000000000000000000000..b4645dc96cfa6c6c28fe9922de06c4af00bdd2dc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h @@ -0,0 +1,29 @@ +/* Floating-point inline functions for stdlib.h. + Copyright (C) 2012-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STDLIB_H +# error "Never use directly; include instead." +#endif + +#ifdef __USE_EXTERN_INLINES +__extern_inline double +__NTH (atof (const char *__nptr)) +{ + return strtod (__nptr, (char **) NULL); +} +#endif /* Optimizing and Inlining. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b5d770999e4a4e60cc2705dc15696b6607839587 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@stdlib-float.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h new file mode 100644 index 0000000000000000000000000000000000000000..216127858a30b18f7485f06a727c9226399f40c4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h @@ -0,0 +1,63 @@ +/* x86 internal mutex struct definitions. + Copyright (C) 2019-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#ifdef __x86_64__ + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#ifdef __x86_64__ + short __spins; + short __elision; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + struct + { + short __espins; + short __eelision; +# define __spins __elision_data.__espins +# define __elision __elision_data.__eelision + } __elision_data; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; + +#ifdef __x86_64__ +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { { 0, 0 } } +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..158f4b2461eef775ef110d9064683d41ed153d87 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_mutex.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h new file mode 100644 index 0000000000000000000000000000000000000000..a665d0a3e532a744f84481ca2035f942646f6a68 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h @@ -0,0 +1,65 @@ +/* x86 internal rwlock struct definitions. + Copyright (C) 2019-2022 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _RWLOCK_INTERNAL_H +#define _RWLOCK_INTERNAL_H + +struct __pthread_rwlock_arch_t +{ + unsigned int __readers; + unsigned int __writers; + unsigned int __wrphase_futex; + unsigned int __writers_futex; + unsigned int __pad3; + unsigned int __pad4; +#ifdef __x86_64__ + int __cur_writer; + int __shared; + signed char __rwelision; +# ifdef __ILP32__ + unsigned char __pad1[3]; +# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 } +# else + unsigned char __pad1[7]; +# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 } +# endif + unsigned long int __pad2; + /* FLAGS must stay at this position in the structure to maintain + binary compatibility. */ + unsigned int __flags; +#else /* __x86_64__ */ + /* FLAGS must stay at this position in the structure to maintain + binary compatibility. */ + unsigned char __flags; + unsigned char __shared; + signed char __rwelision; + unsigned char __pad2; + int __cur_writer; +#endif +}; + +#ifdef __x86_64__ +# define __PTHREAD_RWLOCK_INITIALIZER(__flags) \ + 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, __flags +#else +# define __PTHREAD_RWLOCK_INITIALIZER(__flags) \ + 0, 0, 0, 0, 0, 0, __flags, 0, 0, 0, 0 +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..80caddd47de9a456f2da0c298abb8baf5a15a682 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@struct_rwlock.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h new file mode 100644 index 0000000000000000000000000000000000000000..5653507e55a832ccc3251067b5e2b55ff2e62508 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h @@ -0,0 +1,115 @@ +/* Common threading primitives definitions for both POSIX and C11. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_SHARED_TYPES_H +#define _THREAD_SHARED_TYPES_H 1 + +/* Arch-specific definitions. Each architecture must define the following + macros to define the expected sizes of pthread data types: + + __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. + __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. + __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. + __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. + __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. + __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. + __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. + __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. + __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. + + The additional macro defines any constraint for the lock alignment + inside the thread structures: + + __LOCK_ALIGNMENT - for internal lock/futex usage. + + Same idea but for the once locking primitive: + + __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. */ + +#include + +#include + + +/* Common definition of pthread_mutex_t. */ + +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; + +typedef struct __pthread_internal_slist +{ + struct __pthread_internal_slist *__next; +} __pthread_slist_t; + +/* Arch-specific mutex definitions. A generic implementation is provided + by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture + can override it by defining: + + 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t + definition). It should contains at least the internal members + defined in the generic version. + + 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with + atomic operations. + + 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. + It should initialize the mutex internal flag. */ + +#include + +/* Arch-sepecific read-write lock definitions. A generic implementation is + provided by struct_rwlock.h. If required, an architecture can override it + by defining: + + 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). + It should contain at least the internal members defined in the + generic version. + + 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. + It should initialize the rwlock internal type. */ + +#include + + +/* Common definition of pthread_cond_t. */ + +struct __pthread_cond_s +{ + __atomic_wide_counter __wseq; + __atomic_wide_counter __g1_start; + unsigned int __g_refs[2] __LOCK_ALIGNMENT; + unsigned int __g_size[2]; + unsigned int __g1_orig_size; + unsigned int __wrefs; + unsigned int __g_signals[2]; +}; + +typedef unsigned int __tss_t; +typedef unsigned long int __thrd_t; + +typedef struct +{ + int __data __ONCE_ALIGNMENT; +} __once_flag; + +#define __ONCE_FLAG_INIT { 0 } + +#endif /* _THREAD_SHARED_TYPES_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e2fdbcf3599eb4caebc06ac4b25f48ebac78e981 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@thread-shared-types.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h new file mode 100644 index 0000000000000000000000000000000000000000..efb4a014dff041503d29e399b192665612527ff9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h @@ -0,0 +1,93 @@ +/* System-dependent timing definitions. Linux version. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * Never include this file directly; use instead. + */ + +#ifndef _BITS_TIME_H +#define _BITS_TIME_H 1 + +#include + +/* ISO/IEC 9899:1999 7.23.1: Components of time + The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is + the number per second of the value returned by the `clock' function. */ +/* CAE XSH, Issue 4, Version 2: + The value of CLOCKS_PER_SEC is required to be 1 million on all + XSI-conformant systems. */ +#define CLOCKS_PER_SEC ((__clock_t) 1000000) + +#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \ + && !defined __USE_XOPEN2K +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +extern long int __sysconf (int); +# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */ +#endif + +#ifdef __USE_POSIX199309 +/* Identifier for system-wide realtime clock. */ +# define CLOCK_REALTIME 0 +/* Monotonic system-wide clock. */ +# define CLOCK_MONOTONIC 1 +/* High-resolution timer from the CPU. */ +# define CLOCK_PROCESS_CPUTIME_ID 2 +/* Thread-specific CPU-time clock. */ +# define CLOCK_THREAD_CPUTIME_ID 3 +/* Monotonic system-wide clock, not adjusted for frequency scaling. */ +# define CLOCK_MONOTONIC_RAW 4 +/* Identifier for system-wide realtime clock, updated only on ticks. */ +# define CLOCK_REALTIME_COARSE 5 +/* Monotonic system-wide clock, updated only on ticks. */ +# define CLOCK_MONOTONIC_COARSE 6 +/* Monotonic system-wide clock that includes time spent in suspension. */ +# define CLOCK_BOOTTIME 7 +/* Like CLOCK_REALTIME but also wakes suspended system. */ +# define CLOCK_REALTIME_ALARM 8 +/* Like CLOCK_BOOTTIME but also wakes suspended system. */ +# define CLOCK_BOOTTIME_ALARM 9 +/* Like CLOCK_REALTIME but in International Atomic Time. */ +# define CLOCK_TAI 11 + +/* Flag to indicate time is absolute. */ +# define TIMER_ABSTIME 1 +#endif + +#ifdef __USE_GNU +# include + +__BEGIN_DECLS + +/* Tune a POSIX clock. */ +extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW; + +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT_NTH) +extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id, + struct timex *__utx), + __clock_adjtime64); +# else +# define clock_adjtime __clock_adjtime64 +# endif +#endif + +__END_DECLS +#endif /* use GNU */ + +#endif /* bits/time.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3dd4e0920952a5b813fde3eb694a2e21290d3bbb Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h new file mode 100644 index 0000000000000000000000000000000000000000..e5f3f7dbf1b0dc618ef16cbf51c04a9e72ef3b55 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h @@ -0,0 +1,36 @@ +/* bits/time64.h -- underlying types for __time64_t. Generic version. + Copyright (C) 2018-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TIME64_H +#define _BITS_TIME64_H 1 + +/* Define __TIME64_T_TYPE so that it is always a 64-bit type. */ + +#if __TIMESIZE == 64 +/* If we already have 64-bit time type then use it. */ +# define __TIME64_T_TYPE __TIME_T_TYPE +#else +/* Define a 64-bit time type alongsize the 32-bit one. */ +# define __TIME64_T_TYPE __SQUAD_TYPE +#endif + +#endif /* bits/time64.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..dac51a69f96020c7dbfa3b20170b6f36d9c956a1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@time64.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h new file mode 100644 index 0000000000000000000000000000000000000000..c3a5255408c0f90a1f96c0c8eb2dd00002c1cecd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h @@ -0,0 +1,27 @@ +/* Bit size of the time_t type at glibc build time, x86-64 and x32 case. + Copyright (C) 2018-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if defined __x86_64__ && defined __ILP32__ +/* For x32, time is 64-bit even though word size is 32-bit. */ +# define __TIMESIZE 64 +#else +/* For others, time size is word size. */ +# define __TIMESIZE __WORDSIZE +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a762a596c4662f93e2ed7b351f21a29b5f07ef80 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timesize.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h new file mode 100644 index 0000000000000000000000000000000000000000..ce1ac9dead606b821bf596b80cb641c67eb2083b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h @@ -0,0 +1,141 @@ +/* Copyright (C) 1995-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TIMEX_H +#define _BITS_TIMEX_H 1 + +#include +#include + +/* These definitions from linux/timex.h as of 3.18. */ + +struct timex +{ +# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32) + unsigned int modes; /* mode selector */ + int :32; /* pad */ + long long offset; /* time offset (usec) */ + long long freq; /* frequency offset (scaled ppm) */ + long long maxerror; /* maximum error (usec) */ + long long esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + int :32; /* pad */ + long long constant; /* pll time constant */ + long long precision; /* clock precision (usec) (read only) */ + long long tolerance; /* clock frequency tolerance (ppm) (ro) */ + struct timeval time; /* (read only, except for ADJ_SETOFFSET) */ + long long tick; /* (modified) usecs between clock ticks */ + long long ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long long jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + int :32; /* pad */ + long long stabil; /* pps stability (scaled ppm) (ro) */ + long long jitcnt; /* jitter limit exceeded (ro) */ + long long calcnt; /* calibration intervals (ro) */ + long long errcnt; /* calibration errors (ro) */ + long long stbcnt; /* stability limit exceeded (ro) */ + + int tai; /* TAI offset (ro) */ + + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; +# else + unsigned int modes; /* mode selector */ + __syscall_slong_t offset; /* time offset (usec) */ + __syscall_slong_t freq; /* frequency offset (scaled ppm) */ + __syscall_slong_t maxerror; /* maximum error (usec) */ + __syscall_slong_t esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + __syscall_slong_t constant; /* pll time constant */ + __syscall_slong_t precision; /* clock precision (usec) (ro) */ + __syscall_slong_t tolerance; /* clock frequency tolerance (ppm) (ro) */ + struct timeval time; /* (read only, except for ADJ_SETOFFSET) */ + __syscall_slong_t tick; /* (modified) usecs between clock ticks */ + __syscall_slong_t ppsfreq; /* pps frequency (scaled ppm) (ro) */ + __syscall_slong_t jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */ + __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */ + __syscall_slong_t calcnt; /* calibration intervals (ro) */ + __syscall_slong_t errcnt; /* calibration errors (ro) */ + __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */ + + int tai; /* TAI offset (ro) */ + + /* ??? */ + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; +# endif +}; + +/* Mode codes (timex.mode) */ +#define ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TAI 0x0080 /* set TAI offset */ +#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */ +#define ADJ_MICRO 0x1000 /* select microsecond resolution */ +#define ADJ_NANO 0x2000 /* select nanosecond resolution */ +#define ADJ_TICK 0x4000 /* tick value */ +#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ +#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ + +/* xntp 3.4 compatibility names */ +#define MOD_OFFSET ADJ_OFFSET +#define MOD_FREQUENCY ADJ_FREQUENCY +#define MOD_MAXERROR ADJ_MAXERROR +#define MOD_ESTERROR ADJ_ESTERROR +#define MOD_STATUS ADJ_STATUS +#define MOD_TIMECONST ADJ_TIMECONST +#define MOD_CLKB ADJ_TICK +#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ +#define MOD_TAI ADJ_TAI +#define MOD_MICRO ADJ_MICRO +#define MOD_NANO ADJ_NANO + + +/* Status codes (timex.status) */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ + +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ + +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ + +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ +#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ +#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ +#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ + +/* Read-only bits */ +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER \ + | STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) + +#endif /* bits/timex.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..578ac86c1f11486284598c7e519a9dd9d7fa5aff Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@timex.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h new file mode 100644 index 0000000000000000000000000000000000000000..f912e77a021763044e922f36ebcc801f2fd47fd7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h @@ -0,0 +1,228 @@ +/* bits/types.h -- definitions of __*_t types underlying *_t types. + Copyright (C) 2002-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * Never include this file directly; use instead. + */ + +#ifndef _BITS_TYPES_H +#define _BITS_TYPES_H 1 + +#include +#include +#include + +/* Convenience types. */ +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; + +/* Fixed-size types, underlying types depend on word size and compiler. */ +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; +#if __WORDSIZE == 64 +typedef signed long int __int64_t; +typedef unsigned long int __uint64_t; +#else +__extension__ typedef signed long long int __int64_t; +__extension__ typedef unsigned long long int __uint64_t; +#endif + +/* Smallest types with at least a given width. */ +typedef __int8_t __int_least8_t; +typedef __uint8_t __uint_least8_t; +typedef __int16_t __int_least16_t; +typedef __uint16_t __uint_least16_t; +typedef __int32_t __int_least32_t; +typedef __uint32_t __uint_least32_t; +typedef __int64_t __int_least64_t; +typedef __uint64_t __uint_least64_t; + +/* quad_t is also 64 bits. */ +#if __WORDSIZE == 64 +typedef long int __quad_t; +typedef unsigned long int __u_quad_t; +#else +__extension__ typedef long long int __quad_t; +__extension__ typedef unsigned long long int __u_quad_t; +#endif + +/* Largest integral types. */ +#if __WORDSIZE == 64 +typedef long int __intmax_t; +typedef unsigned long int __uintmax_t; +#else +__extension__ typedef long long int __intmax_t; +__extension__ typedef unsigned long long int __uintmax_t; +#endif + + +/* The machine-dependent file defines __*_T_TYPE + macros for each of the OS types we define below. The definitions + of those macros must use the following macros for underlying types. + We define __S_TYPE and __U_TYPE for the signed and unsigned + variants of each of the following integer types on this machine. + + 16 -- "natural" 16-bit type (always short) + 32 -- "natural" 32-bit type (always int) + 64 -- "natural" 64-bit type (long or long long) + LONG32 -- 32-bit type, traditionally long + QUAD -- 64-bit type, traditionally long long + WORD -- natural type of __WORDSIZE bits (int or long) + LONGWORD -- type of __WORDSIZE bits, traditionally long + + We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the + conventional uses of `long' or `long long' type modifiers match the + types we define, even when a less-adorned type would be the same size. + This matters for (somewhat) portably writing printf/scanf formats for + these types, where using the appropriate l or ll format modifiers can + make the typedefs and the formats match up across all GNU platforms. If + we used `long' when it's 64 bits where `long long' is expected, then the + compiler would warn about the formats not matching the argument types, + and the programmer changing them to shut up the compiler would break the + program's portability. + + Here we assume what is presently the case in all the GCC configurations + we support: long long is always 64 bits, long is always word/address size, + and int is always 32 bits. */ + +#define __S16_TYPE short int +#define __U16_TYPE unsigned short int +#define __S32_TYPE int +#define __U32_TYPE unsigned int +#define __SLONGWORD_TYPE long int +#define __ULONGWORD_TYPE unsigned long int +#if __WORDSIZE == 32 +# define __SQUAD_TYPE __int64_t +# define __UQUAD_TYPE __uint64_t +# define __SWORD_TYPE int +# define __UWORD_TYPE unsigned int +# define __SLONG32_TYPE long int +# define __ULONG32_TYPE unsigned long int +# define __S64_TYPE __int64_t +# define __U64_TYPE __uint64_t +/* We want __extension__ before typedef's that use nonstandard base types + such as `long long' in C89 mode. */ +# define __STD_TYPE __extension__ typedef +#elif __WORDSIZE == 64 +# define __SQUAD_TYPE long int +# define __UQUAD_TYPE unsigned long int +# define __SWORD_TYPE long int +# define __UWORD_TYPE unsigned long int +# define __SLONG32_TYPE int +# define __ULONG32_TYPE unsigned int +# define __S64_TYPE long int +# define __U64_TYPE unsigned long int +/* No need to mark the typedef with __extension__. */ +# define __STD_TYPE typedef +#else +# error +#endif +#include /* Defines __*_T_TYPE macros. */ +#include /* Defines __TIME*_T_TYPE macros. */ + + +__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */ +__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */ +__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */ +__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */ +__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/ +__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */ +__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */ +__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */ +__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */ +__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */ +__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */ +__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */ +__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */ +__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */ +__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */ +__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ +__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */ +__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */ +__STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t; + +__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */ +__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */ + +/* Clock ID used in clock and timer functions. */ +__STD_TYPE __CLOCKID_T_TYPE __clockid_t; + +/* Timer ID returned by `timer_create'. */ +__STD_TYPE __TIMER_T_TYPE __timer_t; + +/* Type to represent block size. */ +__STD_TYPE __BLKSIZE_T_TYPE __blksize_t; + +/* Types from the Large File Support interface. */ + +/* Type to count number of disk blocks. */ +__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t; +__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t; + +/* Type to count file system blocks. */ +__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t; +__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t; + +/* Type to count file system nodes. */ +__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t; +__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t; + +/* Type of miscellaneous file system fields. */ +__STD_TYPE __FSWORD_T_TYPE __fsword_t; + +__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */ + +/* Signed long type used in system calls. */ +__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t; +/* Unsigned long type used in system calls. */ +__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t; + +/* These few don't really vary by system, they always correspond + to one of the other defined types. */ +typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */ +typedef char *__caddr_t; + +/* Duplicates info from stdint.h but this is used in unistd.h. */ +__STD_TYPE __SWORD_TYPE __intptr_t; + +/* Duplicate info from sys/socket.h. */ +__STD_TYPE __U32_TYPE __socklen_t; + +/* C99: An integer type that can be accessed as an atomic entity, + even in the presence of asynchronous interrupts. + It is not currently necessary for this to be machine-specific. */ +typedef int __sig_atomic_t; + +/* Seconds since the Epoch, visible to user code when time_t is too + narrow only for consistency with the old way of widening too-narrow + types. User code should never use __time64_t. */ +#if __TIMESIZE == 64 && defined __LIBC +# define __time64_t __time_t +#elif __TIMESIZE != 64 +__STD_TYPE __TIME64_T_TYPE __time64_t; +#endif + +#undef __STD_TYPE + +#endif /* bits/types.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0fe403b4a98f61a5691873d89e847a00ab0820ff Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h new file mode 100644 index 0000000000000000000000000000000000000000..f2682632090ba3e7f2caa1736394cbb235ceab0c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h @@ -0,0 +1,9 @@ +#ifndef __FILE_defined +#define __FILE_defined 1 + +struct _IO_FILE; + +/* The opaque type of streams. This is the definition used elsewhere. */ +typedef struct _IO_FILE FILE; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1b482e6f0e938fa11f3316ed4005c004f93282b4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@FILE.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h new file mode 100644 index 0000000000000000000000000000000000000000..06dd79bc831bb06a6267a36ad2d62beccd7900b2 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h @@ -0,0 +1,7 @@ +#ifndef ____FILE_defined +#define ____FILE_defined 1 + +struct _IO_FILE; +typedef struct _IO_FILE __FILE; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ba67fd5709702680e19d9700755a2752621500f8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__FILE.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h new file mode 100644 index 0000000000000000000000000000000000000000..06a6891154fff74e1ddb6245f4a0467b09c617c5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h @@ -0,0 +1,16 @@ +#ifndef _____fpos64_t_defined +#define _____fpos64_t_defined 1 + +#include +#include + +/* The tag name of this struct is _G_fpos64_t to preserve historic + C++ mangled names for functions taking fpos_t and/or fpos64_t + arguments. That name should not be used in new code. */ +typedef struct _G_fpos64_t +{ + __off64_t __pos; + __mbstate_t __state; +} __fpos64_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..285fefc943393cc895d05589bda892de6883c693 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos64_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h new file mode 100644 index 0000000000000000000000000000000000000000..bb04576651b9097b3027e4299cc30c88f334535f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h @@ -0,0 +1,16 @@ +#ifndef _____fpos_t_defined +#define _____fpos_t_defined 1 + +#include +#include + +/* The tag name of this struct is _G_fpos_t to preserve historic + C++ mangled names for functions taking fpos_t arguments. + That name should not be used in new code. */ +typedef struct _G_fpos_t +{ + __off_t __pos; + __mbstate_t __state; +} __fpos_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..244a7af628e1cce642610f86c5208b6053448f08 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__fpos_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h new file mode 100644 index 0000000000000000000000000000000000000000..a578eaea53672170a1dfb8a373ef4d2468856568 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h @@ -0,0 +1,43 @@ +/* Definition of struct __locale_struct and __locale_t. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES___LOCALE_T_H +#define _BITS_TYPES___LOCALE_T_H 1 + +/* POSIX.1-2008: the locale_t type, representing a locale context + (implementation-namespace version). This type should be treated + as opaque by applications; some details are exposed for the sake of + efficiency in e.g. ctype functions. */ + +struct __locale_struct +{ + /* Note: LC_ALL is not a valid index into this array. */ + struct __locale_data *__locales[13]; /* 13 = __LC_LAST. */ + + /* To increase the speed of this solution we add some special members. */ + const unsigned short int *__ctype_b; + const int *__ctype_tolower; + const int *__ctype_toupper; + + /* Note: LC_ALL is not a valid index into this array. */ + const char *__names[13]; +}; + +typedef struct __locale_struct *__locale_t; + +#endif /* bits/types/__locale_t.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..602f06a2ccea97eec06eee4727d0c088f83c5215 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__locale_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h new file mode 100644 index 0000000000000000000000000000000000000000..1d8a4e28d1b62a2bfeba837fe18422cd106e6ddf --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h @@ -0,0 +1,23 @@ +#ifndef ____mbstate_t_defined +#define ____mbstate_t_defined 1 + +/* Integral type unchanged by default argument promotions that can + hold any value corresponding to members of the extended character + set, as well as at least one value that does not correspond to any + member of the extended character set. */ +#ifndef __WINT_TYPE__ +# define __WINT_TYPE__ unsigned int +#endif + +/* Conversion state information. */ +typedef struct +{ + int __count; + union + { + __WINT_TYPE__ __wch; + char __wchb[4]; + } __value; /* Value so far. */ +} __mbstate_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bd45017875059361fed22a4227d63c7b83d0785b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__mbstate_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h new file mode 100644 index 0000000000000000000000000000000000000000..e2f18acf30f43496567b1511456089dcd1798425 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h @@ -0,0 +1,10 @@ +#ifndef ____sigset_t_defined +#define ____sigset_t_defined + +#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) +typedef struct +{ + unsigned long int __val[_SIGSET_NWORDS]; +} __sigset_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..009833b43392c5d987be3c9cc176cff8b022436b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigset_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h new file mode 100644 index 0000000000000000000000000000000000000000..5746ab97da47c42aca19e911ca98c4627aba9111 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h @@ -0,0 +1,41 @@ +/* Define __sigval_t. + Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef ____sigval_t_defined +#define ____sigval_t_defined + +/* Type for data associated with a signal. */ +#ifdef __USE_POSIX199309 +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +typedef union sigval __sigval_t; +#else +union __sigval +{ + int __sival_int; + void *__sival_ptr; +}; + +typedef union __sigval __sigval_t; +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3a1c87335ed8b560f1bb753a1b8c0fd58f265776 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@__sigval_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h new file mode 100644 index 0000000000000000000000000000000000000000..ce97248f8856164bef6a2949ef88a289c9046e96 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h @@ -0,0 +1,9 @@ +#ifndef __clock_t_defined +#define __clock_t_defined 1 + +#include + +/* Returned by `clock'. */ +typedef __clock_t clock_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..eefdc014c7818d23c46bd19dfae3592c8b2ee7f3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clock_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h new file mode 100644 index 0000000000000000000000000000000000000000..b17c7da85315c67196341cad4afd8a253115f149 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h @@ -0,0 +1,9 @@ +#ifndef __clockid_t_defined +#define __clockid_t_defined 1 + +#include + +/* Clock ID used in clock and timer functions. */ +typedef __clockid_t clockid_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a49a19b4bc568f21ba1d02285109c09b7cefb683 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@clockid_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h new file mode 100644 index 0000000000000000000000000000000000000000..dc59536bdcfbca98f7e21194e464641675b6de8e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h @@ -0,0 +1,63 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __cookie_io_functions_t_defined +#define __cookie_io_functions_t_defined 1 + +#include + +/* Functions to do I/O and file management for a stream. */ + +/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF. + Return number of bytes read. */ +typedef __ssize_t cookie_read_function_t (void *__cookie, char *__buf, + size_t __nbytes); + +/* Write NBYTES bytes pointed to by BUF to COOKIE. Write all NBYTES bytes + unless there is an error. Return number of bytes written. If + there is an error, return 0 and do not write anything. If the file + has been opened for append (__mode.__append set), then set the file + pointer to the end of the file and then do the write; if not, just + write at the current file pointer. */ +typedef __ssize_t cookie_write_function_t (void *__cookie, const char *__buf, + size_t __nbytes); + +/* Move COOKIE's file position to *POS bytes from the + beginning of the file (if W is SEEK_SET), + the current position (if W is SEEK_CUR), + or the end of the file (if W is SEEK_END). + Set *POS to the new file position. + Returns zero if successful, nonzero if not. */ +typedef int cookie_seek_function_t (void *__cookie, __off64_t *__pos, int __w); + +/* Close COOKIE. */ +typedef int cookie_close_function_t (void *__cookie); + +/* The structure with the cookie function pointers. + The tag name of this struct is _IO_cookie_io_functions_t to + preserve historic C++ mangled names for functions taking + cookie_io_functions_t arguments. That name should not be used in + new code. */ +typedef struct _IO_cookie_io_functions_t +{ + cookie_read_function_t *read; /* Read bytes. */ + cookie_write_function_t *write; /* Write bytes. */ + cookie_seek_function_t *seek; /* Seek/tell file position. */ + cookie_close_function_t *close; /* Close file. */ +} cookie_io_functions_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..16065b8a0a923a7a8e17d562279692e1e98b7fc5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@cookie_io_functions_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h new file mode 100644 index 0000000000000000000000000000000000000000..5c31746a0d085e7281f3f584c9480a0fe8c58f9f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h @@ -0,0 +1,24 @@ +/* Define error_t. + Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __error_t_defined +# define __error_t_defined 1 + +typedef int error_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0c39e725b25958b3dbc6b240aea3c60b1907b5dc Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@error_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h new file mode 100644 index 0000000000000000000000000000000000000000..0ebc9f08b7abda1c15b5342dc5a8e0ea0ec972dc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h @@ -0,0 +1,26 @@ +/* Definition of locale_t. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_LOCALE_T_H +#define _BITS_TYPES_LOCALE_T_H 1 + +#include + +typedef __locale_t locale_t; + +#endif /* bits/types/locale_t.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..88d8bcf87ed1d569d743984facfb08b8cc95936c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@locale_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h new file mode 100644 index 0000000000000000000000000000000000000000..8d1baa5c3b22d779e5c696d7153e33b9161b5081 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h @@ -0,0 +1,8 @@ +#ifndef __mbstate_t_defined +#define __mbstate_t_defined 1 + +#include + +typedef __mbstate_t mbstate_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9086e33e6cedc74134a0a9686ab34ffb7a8a3794 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@mbstate_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h new file mode 100644 index 0000000000000000000000000000000000000000..47eaa28311e16965b3ef1bccac724e48b18c3cb5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h @@ -0,0 +1,10 @@ +#ifndef __sig_atomic_t_defined +#define __sig_atomic_t_defined 1 + +#include + +/* An integral type that can be modified atomically, without the + possibility of a signal arriving in the middle of the operation. */ +typedef __sig_atomic_t sig_atomic_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..98fc1bc69e02fa7930a45519ed230cee73e48d47 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sig_atomic_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h new file mode 100644 index 0000000000000000000000000000000000000000..e8b28de7e3ff6b8bf47661235edbebed511534d8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h @@ -0,0 +1,48 @@ +#ifndef __sigevent_t_defined +#define __sigevent_t_defined 1 + +#include +#include +#include + +#define __SIGEV_MAX_SIZE 64 +#if __WORDSIZE == 64 +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) +#else +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) +#endif + +/* Forward declaration. */ +#ifndef __have_pthread_attr_t +typedef union pthread_attr_t pthread_attr_t; +# define __have_pthread_attr_t 1 +#endif + +/* Structure to transport application-defined values with signals. */ +typedef struct sigevent + { + __sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + + union + { + int _pad[__SIGEV_PAD_SIZE]; + + /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the + thread to receive the signal. */ + __pid_t _tid; + + struct + { + void (*_function) (__sigval_t); /* Function to start. */ + pthread_attr_t *_attribute; /* Thread attributes. */ + } _sigev_thread; + } _sigev_un; + } sigevent_t; + +/* POSIX names to access some of the members. */ +#define sigev_notify_function _sigev_un._sigev_thread._function +#define sigev_notify_attributes _sigev_un._sigev_thread._attribute + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..53de061b3a93aeadb93d6d8fb574f864a184154d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigevent_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h new file mode 100644 index 0000000000000000000000000000000000000000..43c4e009a44faef57558093d248a715f75759f89 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h @@ -0,0 +1,151 @@ +#ifndef __siginfo_t_defined +#define __siginfo_t_defined 1 + +#include +#include +#include + +#define __SI_MAX_SIZE 128 +#if __WORDSIZE == 64 +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4) +#else +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) +#endif + +/* Some fields of siginfo_t have architecture-specific variations. */ +#include +#ifndef __SI_ALIGNMENT +# define __SI_ALIGNMENT /* nothing */ +#endif +#ifndef __SI_BAND_TYPE +# define __SI_BAND_TYPE long int +#endif +#ifndef __SI_CLOCK_T +# define __SI_CLOCK_T __clock_t +#endif +#ifndef __SI_ERRNO_THEN_CODE +# define __SI_ERRNO_THEN_CODE 1 +#endif +#ifndef __SI_HAVE_SIGSYS +# define __SI_HAVE_SIGSYS 1 +#endif +#ifndef __SI_SIGFAULT_ADDL +# define __SI_SIGFAULT_ADDL /* nothing */ +#endif + +typedef struct + { + int si_signo; /* Signal number. */ +#if __SI_ERRNO_THEN_CODE + int si_errno; /* If non-zero, an errno value associated with + this signal, as defined in . */ + int si_code; /* Signal code. */ +#else + int si_code; + int si_errno; +#endif +#if __WORDSIZE == 64 + int __pad0; /* Explicit padding. */ +#endif + + union + { + int _pad[__SI_PAD_SIZE]; + + /* kill(). */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + } _kill; + + /* POSIX.1b timers. */ + struct + { + int si_tid; /* Timer ID. */ + int si_overrun; /* Overrun count. */ + __sigval_t si_sigval; /* Signal value. */ + } _timer; + + /* POSIX.1b signals. */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + __sigval_t si_sigval; /* Signal value. */ + } _rt; + + /* SIGCHLD. */ + struct + { + __pid_t si_pid; /* Which child. */ + __uid_t si_uid; /* Real user ID of sending process. */ + int si_status; /* Exit value or signal. */ + __SI_CLOCK_T si_utime; + __SI_CLOCK_T si_stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ + struct + { + void *si_addr; /* Faulting insn/memory ref. */ + __SI_SIGFAULT_ADDL + short int si_addr_lsb; /* Valid LSB of the reported address. */ + union + { + /* used when si_code=SEGV_BNDERR */ + struct + { + void *_lower; + void *_upper; + } _addr_bnd; + /* used when si_code=SEGV_PKUERR */ + __uint32_t _pkey; + } _bounds; + } _sigfault; + + /* SIGPOLL. */ + struct + { + __SI_BAND_TYPE si_band; /* Band event for SIGPOLL. */ + int si_fd; + } _sigpoll; + + /* SIGSYS. */ +#if __SI_HAVE_SIGSYS + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; +#endif + } _sifields; + } siginfo_t __SI_ALIGNMENT; + + +/* X/Open requires some more fields with fixed names. */ +#define si_pid _sifields._kill.si_pid +#define si_uid _sifields._kill.si_uid +#define si_timerid _sifields._timer.si_tid +#define si_overrun _sifields._timer.si_overrun +#define si_status _sifields._sigchld.si_status +#define si_utime _sifields._sigchld.si_utime +#define si_stime _sifields._sigchld.si_stime +#define si_value _sifields._rt.si_sigval +#define si_int _sifields._rt.si_sigval.sival_int +#define si_ptr _sifields._rt.si_sigval.sival_ptr +#define si_addr _sifields._sigfault.si_addr +#define si_addr_lsb _sifields._sigfault.si_addr_lsb +#define si_lower _sifields._sigfault._bounds._addr_bnd._lower +#define si_upper _sifields._sigfault._bounds._addr_bnd._upper +#define si_pkey _sifields._sigfault._bounds._pkey +#define si_band _sifields._sigpoll.si_band +#define si_fd _sifields._sigpoll.si_fd +#if __SI_HAVE_SIGSYS +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bc096fc859870a67fc6f5667c2af69eabfdbb917 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@siginfo_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h new file mode 100644 index 0000000000000000000000000000000000000000..8b27e9112d637f74f7ec880dd9d95cb3c9874b7f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h @@ -0,0 +1,9 @@ +#ifndef __sigset_t_defined +#define __sigset_t_defined 1 + +#include + +/* A set of signals to be blocked, unblocked, or waited for. */ +typedef __sigset_t sigset_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..61dbbaefe8144fd70a8bd168ba85c986c6f47a93 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigset_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h new file mode 100644 index 0000000000000000000000000000000000000000..a05d7f469fe9a9bd2142f545b3cca4a95206f090 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h @@ -0,0 +1,18 @@ +#ifndef __sigval_t_defined +#define __sigval_t_defined + +#include + +/* To avoid sigval_t (not a standard type name) having C++ name + mangling depending on whether the selected standard includes union + sigval, it should not be defined at all when using a standard for + which the sigval name is not reserved; in that case, headers should + not include and should use only the + internal __sigval_t name. */ +#ifndef __USE_POSIX199309 +# error "sigval_t defined for standard not including union sigval" +#endif + +typedef __sigval_t sigval_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b61ee632bdb7280c0afa031618d1aa42db2d7d6f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@sigval_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h new file mode 100644 index 0000000000000000000000000000000000000000..f690aa2a21ccdb3bfed54ebe2be346a89101a4d1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h @@ -0,0 +1,33 @@ +/* Define stack_t. Linux version. + Copyright (C) 1998-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __stack_t_defined +#define __stack_t_defined 1 + +#define __need_size_t +#include + +/* Structure describing a signal stack. */ +typedef struct + { + void *ss_sp; + int ss_flags; + size_t ss_size; + } stack_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..99684a5d72eb1b8373dacb61455f4b7a6ecb3120 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@stack_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h new file mode 100644 index 0000000000000000000000000000000000000000..1eb429888c459fcd443d78fdea4f3c95a026e269 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h @@ -0,0 +1,120 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __struct_FILE_defined +#define __struct_FILE_defined 1 + +/* Caution: The contents of this file are not part of the official + stdio.h API. However, much of it is part of the official *binary* + interface, and therefore cannot be changed. */ + +#if defined _IO_USE_OLD_IO_FILE && !defined _LIBC +# error "_IO_USE_OLD_IO_FILE should only be defined when building libc itself" +#endif + +#if defined _IO_lock_t_defined && !defined _LIBC +# error "_IO_lock_t_defined should only be defined when building libc itself" +#endif + +#include + +struct _IO_FILE; +struct _IO_marker; +struct _IO_codecvt; +struct _IO_wide_data; + +/* During the build of glibc itself, _IO_lock_t will already have been + defined by internal headers. */ +#ifndef _IO_lock_t_defined +typedef void _IO_lock_t; +#endif + +/* The tag name of this struct is _IO_FILE to preserve historic + C++ mangled names for functions taking FILE* arguments. + That name should not be used in new code. */ +struct _IO_FILE +{ + int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ + + /* The following pointers correspond to the C++ streambuf protocol. */ + char *_IO_read_ptr; /* Current read pointer */ + char *_IO_read_end; /* End of get area. */ + char *_IO_read_base; /* Start of putback+get area. */ + char *_IO_write_base; /* Start of put area. */ + char *_IO_write_ptr; /* Current put pointer. */ + char *_IO_write_end; /* End of put area. */ + char *_IO_buf_base; /* Start of reserve area. */ + char *_IO_buf_end; /* End of reserve area. */ + + /* The following fields are used to support backing up and undo. */ + char *_IO_save_base; /* Pointer to start of non-current get area. */ + char *_IO_backup_base; /* Pointer to first valid character of backup area */ + char *_IO_save_end; /* Pointer to end of non-current get area. */ + + struct _IO_marker *_markers; + + struct _IO_FILE *_chain; + + int _fileno; + int _flags2; + __off_t _old_offset; /* This used to be _offset but it's too small. */ + + /* 1+column number of pbase(); 0 is unknown. */ + unsigned short _cur_column; + signed char _vtable_offset; + char _shortbuf[1]; + + _IO_lock_t *_lock; +#ifdef _IO_USE_OLD_IO_FILE +}; + +struct _IO_FILE_complete +{ + struct _IO_FILE _file; +#endif + __off64_t _offset; + /* Wide character stream stuff. */ + struct _IO_codecvt *_codecvt; + struct _IO_wide_data *_wide_data; + struct _IO_FILE *_freeres_list; + void *_freeres_buf; + size_t __pad5; + int _mode; + /* Make sure we don't get into trouble again. */ + char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; +}; + +/* These macros are used by bits/stdio.h and internal headers. */ +#define __getc_unlocked_body(_fp) \ + (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \ + ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) + +#define __putc_unlocked_body(_ch, _fp) \ + (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ + ? __overflow (_fp, (unsigned char) (_ch)) \ + : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) + +#define _IO_EOF_SEEN 0x0010 +#define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0) + +#define _IO_ERR_SEEN 0x0020 +#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) + +#define _IO_USER_LOCK 0x8000 +/* Many more flag bits are defined internally. */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f0310affe7595a4ba900ae5c3aab7319e695fdd3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_FILE.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h new file mode 100644 index 0000000000000000000000000000000000000000..613d7ea117a75ea07abcab6f66e81f0f78d0ed7a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h @@ -0,0 +1,37 @@ +/* Define struct __jmp_buf_tag. + Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __jmp_buf_tag_defined +#define __jmp_buf_tag_defined 1 + +#include /* Get `__jmp_buf'. */ +#include + +/* Calling environment, plus possibly a saved signal mask. */ +struct __jmp_buf_tag + { + /* NOTE: The machine-dependent definitions of `__sigsetjmp' + assume that a `jmp_buf' begins with a `__jmp_buf' and that + `__mask_was_saved' follows it. Do not move these members + or add others before it. */ + __jmp_buf __jmpbuf; /* Calling environment. */ + int __mask_was_saved; /* Saved the signal mask? */ + __sigset_t __saved_mask; /* Saved signal mask. */ + }; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a70b8261a60818fcd435ed5ff679cd500461fa8f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct___jmp_buf_tag.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h new file mode 100644 index 0000000000000000000000000000000000000000..17cc1ac86d09eeb1799e4dfbd9b75a54f03a850f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h @@ -0,0 +1,14 @@ +#ifndef __itimerspec_defined +#define __itimerspec_defined 1 + +#include +#include + +/* POSIX.1b structure for timer start values and intervals. */ +struct itimerspec + { + struct timespec it_interval; + struct timespec it_value; + }; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..74d5d207c7286cd4b0511357bf7ef9ac4f8448ea Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_itimerspec.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h new file mode 100644 index 0000000000000000000000000000000000000000..14089513445897e573e3e55979d6eb8b3dc70647 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h @@ -0,0 +1,28 @@ +/* Sched parameter structure. Generic version. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_STRUCT_SCHED_PARAM +#define _BITS_TYPES_STRUCT_SCHED_PARAM 1 + +/* Data structure to describe a process' schedulability. */ +struct sched_param +{ + int sched_priority; +}; + +#endif /* bits/types/struct_sched_param.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ff55a4f152e9580a8c52806c098f9299e2f6d6e0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sched_param.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h new file mode 100644 index 0000000000000000000000000000000000000000..4190c779e6e33e01891afc2523d9a7e9e24c75f1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h @@ -0,0 +1,29 @@ +/* Define struct sigstack. + Copyright (C) 1998-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __sigstack_defined +#define __sigstack_defined 1 + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + void *ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..77abc7ce1b05a5afa06ac3e0fead5b35893f6e44 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_sigstack.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h new file mode 100644 index 0000000000000000000000000000000000000000..489e81136d7f4ad587a97f4894242c17d1814b50 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h @@ -0,0 +1,33 @@ +/* NB: Include guard matches what uses. */ +#ifndef _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC 1 + +#include +#include +#include + +/* POSIX.1b structure for a time value. This is like a `struct timeval' but + has nanoseconds instead of microseconds. */ +struct timespec +{ +#ifdef __USE_TIME_BITS64 + __time64_t tv_sec; /* Seconds. */ +#else + __time_t tv_sec; /* Seconds. */ +#endif +#if __WORDSIZE == 64 \ + || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \ + || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64) + __syscall_slong_t tv_nsec; /* Nanoseconds. */ +#else +# if __BYTE_ORDER == __BIG_ENDIAN + int: 32; /* Padding. */ + long int tv_nsec; /* Nanoseconds. */ +# else + long int tv_nsec; /* Nanoseconds. */ + int: 32; /* Padding. */ +# endif +#endif +}; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a952de072ea87392bc4193a21810655b64a685c6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timespec.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h new file mode 100644 index 0000000000000000000000000000000000000000..3466137c35fb5d0e44dad8cc1ef7041832e27d97 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h @@ -0,0 +1,18 @@ +#ifndef __timeval_defined +#define __timeval_defined 1 + +#include + +/* A time value that is accurate to the nearest + microsecond but also has a range of years. */ +struct timeval +{ +#ifdef __USE_TIME_BITS64 + __time64_t tv_sec; /* Seconds. */ + __suseconds64_t tv_usec; /* Microseconds. */ +#else + __time_t tv_sec; /* Seconds. */ + __suseconds_t tv_usec; /* Microseconds. */ +#endif +}; +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..31d6cd770649e264bd7ecfffeee8c5d24f37a6e5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_timeval.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h new file mode 100644 index 0000000000000000000000000000000000000000..b13b631228d0ec36691b25db2e1f9b1d66b54bb0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h @@ -0,0 +1,28 @@ +#ifndef __struct_tm_defined +#define __struct_tm_defined 1 + +#include + +/* ISO C `broken-down time' structure. */ +struct tm +{ + int tm_sec; /* Seconds. [0-60] (1 leap second) */ + int tm_min; /* Minutes. [0-59] */ + int tm_hour; /* Hours. [0-23] */ + int tm_mday; /* Day. [1-31] */ + int tm_mon; /* Month. [0-11] */ + int tm_year; /* Year - 1900. */ + int tm_wday; /* Day of week. [0-6] */ + int tm_yday; /* Days in year.[0-365] */ + int tm_isdst; /* DST. [-1/0/1]*/ + +# ifdef __USE_MISC + long int tm_gmtoff; /* Seconds east of UTC. */ + const char *tm_zone; /* Timezone abbreviation. */ +# else + long int __tm_gmtoff; /* Seconds east of UTC. */ + const char *__tm_zone; /* Timezone abbreviation. */ +# endif +}; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..02d8d4194b90ea0733ba3cd775c67e85967f80e2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@struct_tm.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h new file mode 100644 index 0000000000000000000000000000000000000000..84d67f6ac346e249bd419868e89aa1bacd5a8f93 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h @@ -0,0 +1,13 @@ +#ifndef __time_t_defined +#define __time_t_defined 1 + +#include + +/* Returned by `time'. */ +#ifdef __USE_TIME_BITS64 +typedef __time64_t time_t; +#else +typedef __time_t time_t; +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7d4b9f6fc13968920342b913bd4c9e63eafbbb9f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@time_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h new file mode 100644 index 0000000000000000000000000000000000000000..d71a4130e213131dd58dc1e3c7c53fbe59db47a8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h @@ -0,0 +1,9 @@ +#ifndef __timer_t_defined +#define __timer_t_defined 1 + +#include + +/* Timer ID returned by `timer_create'. */ +typedef __timer_t timer_t; + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ccb98cd13f6979d8f0766cfbfefa06656bea9011 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@timer_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h new file mode 100644 index 0000000000000000000000000000000000000000..fbd63dbc84959491013cb6213022f8874083e29a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h @@ -0,0 +1,23 @@ +#ifndef __wint_t_defined +#define __wint_t_defined 1 + +/* Some versions of stddef.h provide wint_t, even though neither the + C nor C++ standards, nor POSIX, specifies this. We assume that + stddef.h will define the macro _WINT_T if and only if it provides + wint_t, and conversely, that it will avoid providing wint_t if + _WINT_T is already defined. */ +#ifndef _WINT_T +#define _WINT_T 1 + +/* Integral type unchanged by default argument promotions that can + hold any value corresponding to members of the extended character + set, as well as at least one value that does not correspond to any + member of the extended character set. */ +#ifndef __WINT_TYPE__ +# define __WINT_TYPE__ unsigned int +#endif + +typedef __WINT_TYPE__ wint_t; + +#endif /* _WINT_T */ +#endif /* bits/types/wint_t.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..153cde0ce4e2bc292c525a44def62d26f5666ad1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@types@wint_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h new file mode 100644 index 0000000000000000000000000000000000000000..20e70232784068fd15c9d470c3404de8ecdea403 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h @@ -0,0 +1,106 @@ +/* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. + Copyright (C) 2012-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ + +/* X32 kernel interface is 64-bit. */ +#if defined __x86_64__ && defined __ILP32__ +# define __SYSCALL_SLONG_TYPE __SQUAD_TYPE +# define __SYSCALL_ULONG_TYPE __UQUAD_TYPE +#else +# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE +# define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#endif + +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __SYSCALL_ULONG_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#ifdef __x86_64__ +# define __NLINK_T_TYPE __SYSCALL_ULONG_TYPE +# define __FSWORD_T_TYPE __SYSCALL_SLONG_TYPE +#else +# define __NLINK_T_TYPE __UWORD_TYPE +# define __FSWORD_T_TYPE __SWORD_TYPE +#endif +#define __OFF_T_TYPE __SYSCALL_SLONG_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __SYSCALL_ULONG_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SYSCALL_SLONG_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __SYSCALL_ULONG_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __SYSCALL_ULONG_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SYSCALL_SLONG_TYPE +#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE void * +#define __BLKSIZE_T_TYPE __SYSCALL_SLONG_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#define __SSIZE_T_TYPE __SWORD_TYPE +#define __CPU_MASK_TYPE __SYSCALL_ULONG_TYPE + +#ifdef __x86_64__ +/* Tell the libc code that off_t and off64_t are actually the same type + for all ABI purposes, even if possibly expressed as different base types + for C type-checking purposes. */ +# define __OFF_T_MATCHES_OFF64_T 1 + +/* Same for ino_t and ino64_t. */ +# define __INO_T_MATCHES_INO64_T 1 + +/* And for __rlim_t and __rlim64_t. */ +# define __RLIM_T_MATCHES_RLIM64_T 1 + +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ +# define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 +#else +# define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 0 + +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 +#endif + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..df1202f1dd5180565ad9073fdd6d3dd3dad32480 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@typesizes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h new file mode 100644 index 0000000000000000000000000000000000000000..145a6d5acd4c4e4036e6980792d94916cdf1c530 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h @@ -0,0 +1,50 @@ +/* Inline functions to return unsigned integer values unchanged. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined _NETINET_IN_H && !defined _ENDIAN_H +# error "Never use directly; include or instead." +#endif + +#ifndef _BITS_UINTN_IDENTITY_H +#define _BITS_UINTN_IDENTITY_H 1 + +#include + +/* These inline functions are to ensure the appropriate type + conversions and associated diagnostics from macros that convert to + a given endianness. */ + +static __inline __uint16_t +__uint16_identity (__uint16_t __x) +{ + return __x; +} + +static __inline __uint32_t +__uint32_identity (__uint32_t __x) +{ + return __x; +} + +static __inline __uint64_t +__uint64_identity (__uint64_t __x) +{ + return __x; +} + +#endif /* _BITS_UINTN_IDENTITY_H. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d16c5d95eaab2399a5959e1952573ada9c5b5900 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uintn-identity.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..ef2b9705999905abdc731ee5c6caab7a7216841e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h @@ -0,0 +1,32 @@ +/* Implementation limits related to sys/uio.h - Linux version. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_UIO_LIM_H +#define _BITS_UIO_LIM_H 1 + +/* Maximum length of the 'struct iovec' array in a single call to + readv or writev. + + This macro has different values in different kernel versions. The + latest versions of the kernel use 1024 and this is good choice. Since + the C library implementation of readv/writev is able to emulate the + functionality even if the currently running kernel does not support + this large value the readv/writev call will not fail because of this. */ +#define __IOV_MAX 1024 + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..84f5009cf683973e1e3df5c933f1b7c98e09807a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@uio_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h new file mode 100644 index 0000000000000000000000000000000000000000..f6ac2077b906a29d104bb849556d1029c34ec5b0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h @@ -0,0 +1,50 @@ +/* System-specific extensions of , Linux version. + Copyright (C) 2019-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _UNISTD_H +# error "Never include directly; use instead." +#endif + +#ifdef __USE_GNU + +/* Return the kernel thread ID (TID) of the current thread. The + returned value is not subject to caching. Most Linux system calls + accept a TID in place of a PID. Using the TID to change properties + of a thread that has been created using pthread_create can lead to + undefined behavior (comparable to manipulating file descriptors + directly that have not been created explicitly). Note that a TID + uniquely identifies a thread only while this thread is running; a + TID can be reused once a thread has exited, even if the thread is + not detached and has not been joined. */ +extern __pid_t gettid (void) __THROW; + +#ifdef __has_include +# if __has_include ("linux/close_range.h") +# include "linux/close_range.h" +# endif +#endif +/* Unshare the file descriptor table before closing file descriptors. */ +#ifndef CLOSE_RANGE_UNSHARE +# define CLOSE_RANGE_UNSHARE (1U << 1) +#endif +/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */ +#ifndef CLOSE_RANGE_CLOEXEC +# define CLOSE_RANGE_CLOEXEC (1U << 2) +#endif + +#endif /* __USE_GNU */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d765bd27885e1dba32584d22c79d73e0e25f2b45 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@unistd_ext.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h new file mode 100644 index 0000000000000000000000000000000000000000..3834d61ff0900a1b4131b8659ab1015b7951e544 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h @@ -0,0 +1,39 @@ +/* Definitions of flag bits for `waitpid' et al. + Copyright (C) 1992-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined _SYS_WAIT_H && !defined _STDLIB_H +# error "Never include directly; use instead." +#endif + + +/* Bits in the third argument to `waitpid'. */ +#define WNOHANG 1 /* Don't block waiting. */ +#define WUNTRACED 2 /* Report status of stopped children. */ + +/* Bits in the fourth argument to `waitid'. */ +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +# define WSTOPPED 2 /* Report stopped child (same as WUNTRACED). */ +# define WEXITED 4 /* Report dead child. */ +# define WCONTINUED 8 /* Report continued child. */ +# define WNOWAIT 0x01000000 /* Don't reap, just poll status. */ +#endif + +#define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads + in this group */ +#define __WALL 0x40000000 /* Wait for any child. */ +#define __WCLONE 0x80000000 /* Wait for cloned process. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f3e788308cb1be9c8a9dd73a764bf28e4f99448e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitflags.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h new file mode 100644 index 0000000000000000000000000000000000000000..6633531171fd68b6bc00b77befdf88a939a8d1ad --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h @@ -0,0 +1,59 @@ +/* Definitions of status bits for `wait' et al. + Copyright (C) 1992-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !defined _SYS_WAIT_H && !defined _STDLIB_H +# error "Never include directly; use instead." +#endif + + +/* Everything extant so far uses these same bits. */ + + +/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ +#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) + +/* If WIFSIGNALED(STATUS), the terminating signal. */ +#define __WTERMSIG(status) ((status) & 0x7f) + +/* If WIFSTOPPED(STATUS), the signal that stopped the child. */ +#define __WSTOPSIG(status) __WEXITSTATUS(status) + +/* Nonzero if STATUS indicates normal termination. */ +#define __WIFEXITED(status) (__WTERMSIG(status) == 0) + +/* Nonzero if STATUS indicates termination by a signal. */ +#define __WIFSIGNALED(status) \ + (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) + +/* Nonzero if STATUS indicates the child is stopped. */ +#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f) + +/* Nonzero if STATUS indicates the child continued after a stop. We only + define this if provides the WCONTINUED flag bit. */ +#ifdef WCONTINUED +# define __WIFCONTINUED(status) ((status) == __W_CONTINUED) +#endif + +/* Nonzero if STATUS indicates the child dumped core. */ +#define __WCOREDUMP(status) ((status) & __WCOREFLAG) + +/* Macros for constructing status values. */ +#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f) +#define __W_CONTINUED 0xffff +#define __WCOREFLAG 0x80 diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..add652617e9412325647d48dd45e143e44673ce0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@waitstatus.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h new file mode 100644 index 0000000000000000000000000000000000000000..50c7ef37b1f593139c9a4682eb030a0b9b911929 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h @@ -0,0 +1,49 @@ +/* wchar_t type related definitions. + Copyright (C) 2000-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_WCHAR_H +#define _BITS_WCHAR_H 1 + +/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__ + are not defined, give the right value and type as long as both int + and wchar_t are 32-bit types. Adding L'\0' to a constant value + ensures that the type is correct; it is necessary to use (L'\0' + + 0) rather than just L'\0' so that the type in C++ is the promoted + version of wchar_t rather than the distinct wchar_t type itself. + Because wchar_t in preprocessor #if expressions is treated as + intmax_t or uintmax_t, the expression (L'\0' - 1) would have the + wrong value for WCHAR_MAX in such expressions and so cannot be used + to define __WCHAR_MAX in the unsigned case. */ + +#ifdef __WCHAR_MAX__ +# define __WCHAR_MAX __WCHAR_MAX__ +#elif L'\0' - 1 > 0 +# define __WCHAR_MAX (0xffffffffu + L'\0') +#else +# define __WCHAR_MAX (0x7fffffff + L'\0') +#endif + +#ifdef __WCHAR_MIN__ +# define __WCHAR_MIN __WCHAR_MIN__ +#elif L'\0' - 1 > 0 +# define __WCHAR_MIN (L'\0' + 0) +#else +# define __WCHAR_MIN (-__WCHAR_MAX - 1) +#endif + +#endif /* bits/wchar.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f98b3741756a4c3e4f6f0ebea90e59b4ddb243bf Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wchar.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h new file mode 100644 index 0000000000000000000000000000000000000000..8eca9262fd40dd191ab4a2f9a9e64ab1f4155071 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h @@ -0,0 +1,173 @@ +/* Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.25 + * Wide character classification and mapping utilities + */ + +#ifndef _BITS_WCTYPE_WCHAR_H +#define _BITS_WCTYPE_WCHAR_H 1 + +#if !defined _WCTYPE_H && !defined _WCHAR_H +#error "Never include directly; include or instead." +#endif + +#include +#include + +/* The definitions in this header are specified to appear in + in ISO C99, but in in Unix98. _GNU_SOURCE follows C99. */ + +/* Scalar type that can hold values which represent locale-specific + character classifications. */ +typedef unsigned long int wctype_t; + +# ifndef _ISwbit +/* The characteristics are stored always in network byte order (big + endian). We define the bit value interpretations here dependent on the + machine's byte order. */ + +# include +# if __BYTE_ORDER == __BIG_ENDIAN +# define _ISwbit(bit) (1 << (bit)) +# else /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# define _ISwbit(bit) \ + ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \ + : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \ + : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \ + : (int) ((1UL << (bit)) >> 24)))) +# endif + +enum +{ + __ISwupper = 0, /* UPPERCASE. */ + __ISwlower = 1, /* lowercase. */ + __ISwalpha = 2, /* Alphabetic. */ + __ISwdigit = 3, /* Numeric. */ + __ISwxdigit = 4, /* Hexadecimal numeric. */ + __ISwspace = 5, /* Whitespace. */ + __ISwprint = 6, /* Printing. */ + __ISwgraph = 7, /* Graphical. */ + __ISwblank = 8, /* Blank (usually SPC and TAB). */ + __ISwcntrl = 9, /* Control character. */ + __ISwpunct = 10, /* Punctuation. */ + __ISwalnum = 11, /* Alphanumeric. */ + + _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */ + _ISwlower = _ISwbit (__ISwlower), /* lowercase. */ + _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */ + _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */ + _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */ + _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */ + _ISwprint = _ISwbit (__ISwprint), /* Printing. */ + _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */ + _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */ + _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */ + _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */ + _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */ +}; +# endif /* Not _ISwbit */ + + +__BEGIN_DECLS + +/* + * Wide-character classification functions: 7.15.2.1. + */ + +/* Test for any wide character for which `iswalpha' or `iswdigit' is + true. */ +extern int iswalnum (wint_t __wc) __THROW; + +/* Test for any wide character for which `iswupper' or 'iswlower' is + true, or any wide character that is one of a locale-specific set of + wide-characters for which none of `iswcntrl', `iswdigit', + `iswpunct', or `iswspace' is true. */ +extern int iswalpha (wint_t __wc) __THROW; + +/* Test for any control wide character. */ +extern int iswcntrl (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a decimal-digit + character. */ +extern int iswdigit (wint_t __wc) __THROW; + +/* Test for any wide character for which `iswprint' is true and + `iswspace' is false. */ +extern int iswgraph (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a lowercase letter + or is one of a locale-specific set of wide characters for which + none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswlower (wint_t __wc) __THROW; + +/* Test for any printing wide character. */ +extern int iswprint (wint_t __wc) __THROW; + +/* Test for any printing wide character that is one of a + locale-specific et of wide characters for which neither `iswspace' + nor `iswalnum' is true. */ +extern int iswpunct (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a locale-specific + set of wide characters for which none of `iswalnum', `iswgraph', or + `iswpunct' is true. */ +extern int iswspace (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to an uppercase letter + or is one of a locale-specific set of wide character for which none + of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswupper (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a hexadecimal-digit + character equivalent to that performed be the functions described + in the previous subclause. */ +extern int iswxdigit (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a standard blank + wide character or a locale-specific set of wide characters for + which `iswalnum' is false. */ +# ifdef __USE_ISOC99 +extern int iswblank (wint_t __wc) __THROW; +# endif + +/* + * Extensible wide-character classification functions: 7.15.2.2. + */ + +/* Construct value that describes a class of wide characters identified + by the string argument PROPERTY. */ +extern wctype_t wctype (const char *__property) __THROW; + +/* Determine whether the wide-character WC has the property described by + DESC. */ +extern int iswctype (wint_t __wc, wctype_t __desc) __THROW; + +/* + * Wide-character case-mapping functions: 7.15.3.1. + */ + +/* Converts an uppercase letter to the corresponding lowercase letter. */ +extern wint_t towlower (wint_t __wc) __THROW; + +/* Converts an lowercase letter to the corresponding uppercase letter. */ +extern wint_t towupper (wint_t __wc) __THROW; + +__END_DECLS + +#endif /* bits/wctype-wchar.h. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1307932f1e1cb5fc54a991e7fb1a05220cd7af61 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wctype-wchar.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h new file mode 100644 index 0000000000000000000000000000000000000000..70f652bca14d65c1de5a21669e7c0ffb8ecfe5ea --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h @@ -0,0 +1,17 @@ +/* Determine the wordsize from the preprocessor defines. */ + +#if defined __x86_64__ && !defined __ILP32__ +# define __WORDSIZE 64 +#else +# define __WORDSIZE 32 +#define __WORDSIZE32_SIZE_ULONG 0 +#define __WORDSIZE32_PTRDIFF_LONG 0 +#endif + +#ifdef __x86_64__ +# define __WORDSIZE_TIME64_COMPAT32 1 +/* Both x86-64 and x32 use the 64-bit system call interface. */ +# define __SYSCALL_WORDSIZE 64 +#else +# define __WORDSIZE_TIME64_COMPAT32 0 +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d1471a5a0cca0023d4b9954952c9d36f34459608 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@wordsize.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h new file mode 100644 index 0000000000000000000000000000000000000000..8e002d6e60ac4c4e008ace5dc6ddf2afb3231053 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h @@ -0,0 +1,148 @@ +/* Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * Never include this file directly; use instead. + */ + +/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2 + System Interfaces and Headers, 4.16 + + Please note only the values which are not greater than the minimum + stated in the standard document are listed. The `sysconf' functions + should be used to obtain the actual value. */ + +#ifndef _XOPEN_LIM_H +#define _XOPEN_LIM_H 1 + +/* We do not provide fixed values for + + ARG_MAX Maximum length of argument to the `exec' function + including environment data. + + ATEXIT_MAX Maximum number of functions that may be registered + with `atexit'. + + CHILD_MAX Maximum number of simultaneous processes per real + user ID. + + OPEN_MAX Maximum number of files that one process can have open + at anyone time. + + PAGESIZE + PAGE_SIZE Size of bytes of a page. + + PASS_MAX Maximum number of significant bytes in a password. + + We only provide a fixed limit for + + IOV_MAX Maximum number of `iovec' structures that one process has + available for use with `readv' or writev'. + + if this is indeed fixed by the underlying system. +*/ + + +/* Maximum number of `iovec' structures that may be used in a single call + to `readv', `writev', etc. */ +#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV + +#include +#ifdef __IOV_MAX +# define IOV_MAX __IOV_MAX +#else +# undef IOV_MAX +#endif + +/* Maximum value of `digit' in calls to the `printf' and `scanf' + functions. We have no limit, so return a reasonable value. */ +#define NL_ARGMAX _POSIX_ARG_MAX + +/* Maximum number of bytes in a `LANG' name. We have no limit. */ +#define NL_LANGMAX _POSIX2_LINE_MAX + +/* Maximum message number. We have no limit. */ +#define NL_MSGMAX INT_MAX + +/* Maximum number of bytes in N-to-1 collation mapping. We have no + limit. */ +#if defined __USE_GNU || !defined __USE_XOPEN2K8 +# define NL_NMAX INT_MAX +#endif + +/* Maximum set number. We have no limit. */ +#define NL_SETMAX INT_MAX + +/* Maximum number of bytes in a message. We have no limit. */ +#define NL_TEXTMAX INT_MAX + +/* Default process priority. */ +#define NZERO 20 + + +/* Number of bits in a word of type `int'. */ +#ifdef INT_MAX +# if INT_MAX == 32767 +# define WORD_BIT 16 +# else +# if INT_MAX == 2147483647 +# define WORD_BIT 32 +# else +/* Safe assumption. */ +# define WORD_BIT 64 +# endif +# endif +#elif defined __INT_MAX__ +# if __INT_MAX__ == 32767 +# define WORD_BIT 16 +# else +# if __INT_MAX__ == 2147483647 +# define WORD_BIT 32 +# else +/* Safe assumption. */ +# define WORD_BIT 64 +# endif +# endif +#else +# define WORD_BIT 32 +#endif + +/* Number of bits in a word of type `long int'. */ +#ifdef LONG_MAX +# if LONG_MAX == 2147483647 +# define LONG_BIT 32 +# else +/* Safe assumption. */ +# define LONG_BIT 64 +# endif +#elif defined __LONG_MAX__ +# if __LONG_MAX__ == 2147483647 +# define LONG_BIT 32 +# else +/* Safe assumption. */ +# define LONG_BIT 64 +# endif +#else +# include +# if __WORDSIZE == 64 +# define LONG_BIT 64 +# else +# define LONG_BIT 32 +# endif +#endif + +#endif /* bits/xopen_lim.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..aa04d4e694fc851fbad3ffdfa1bb2705da7b95e2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@bits@xopen_lim.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h new file mode 100644 index 0000000000000000000000000000000000000000..eee1dcc7f54e7e9aeb4bbfddbdbd1993fb908b78 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h @@ -0,0 +1,329 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard 7.4: Character handling + */ + +#ifndef _CTYPE_H +#define _CTYPE_H 1 + +#include +#include + +__BEGIN_DECLS + +#ifndef _ISbit +/* These are all the characteristics of characters. + If there get to be more than 16 distinct characteristics, + many things must be changed that use `unsigned short int's. + + The characteristics are stored always in network byte order (big + endian). We define the bit value interpretations here dependent on the + machine's byte order. */ + +# include +# if __BYTE_ORDER == __BIG_ENDIAN +# define _ISbit(bit) (1 << (bit)) +# else /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) +# endif + +enum +{ + _ISupper = _ISbit (0), /* UPPERCASE. */ + _ISlower = _ISbit (1), /* lowercase. */ + _ISalpha = _ISbit (2), /* Alphabetic. */ + _ISdigit = _ISbit (3), /* Numeric. */ + _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */ + _ISspace = _ISbit (5), /* Whitespace. */ + _ISprint = _ISbit (6), /* Printing. */ + _ISgraph = _ISbit (7), /* Graphical. */ + _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ + _IScntrl = _ISbit (9), /* Control character. */ + _ISpunct = _ISbit (10), /* Punctuation. */ + _ISalnum = _ISbit (11) /* Alphanumeric. */ +}; +#endif /* ! _ISbit */ + +/* These are defined in ctype-info.c. + The declarations here must match those in localeinfo.h. + + In the thread-specific locale model (see `uselocale' in ) + we cannot use global variables for these as was done in the past. + Instead, the following accessor functions return the address of + each variable, which is local to the current thread if multithreaded. + + These point into arrays of 384, so they can be indexed by any `unsigned + char' value [0,255]; by EOF (-1); or by any `signed char' value + [-128,-1). ISO C requires that the ctype functions work for `unsigned + char' values and for EOF; we also support negative `signed char' values + for broken old programs. The case conversion arrays are of `int's + rather than `unsigned char's because tolower (EOF) must be EOF, which + doesn't fit into an `unsigned char'. But today more important is that + the arrays are also used for multi-byte character sets. */ +extern const unsigned short int **__ctype_b_loc (void) + __THROW __attribute__ ((__const__)); +extern const __int32_t **__ctype_tolower_loc (void) + __THROW __attribute__ ((__const__)); +extern const __int32_t **__ctype_toupper_loc (void) + __THROW __attribute__ ((__const__)); + + +#ifndef __cplusplus +# define __isctype(c, type) \ + ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type) +#elif defined __USE_EXTERN_INLINES +# define __isctype_f(type) \ + __extern_inline int \ + is##type (int __c) __THROW \ + { \ + return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \ + } +#endif + +#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ +#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ + +#define __exctype(name) extern int name (int) __THROW + +/* The following names are all functions: + int isCHARACTERISTIC(int c); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype (isalnum); +__exctype (isalpha); +__exctype (iscntrl); +__exctype (isdigit); +__exctype (islower); +__exctype (isgraph); +__exctype (isprint); +__exctype (ispunct); +__exctype (isspace); +__exctype (isupper); +__exctype (isxdigit); + + +/* Return the lowercase version of C. */ +extern int tolower (int __c) __THROW; + +/* Return the uppercase version of C. */ +extern int toupper (int __c) __THROW; + + +/* ISO C99 introduced one new function. */ +#ifdef __USE_ISOC99 +__exctype (isblank); +#endif + +#ifdef __USE_GNU +/* Test C for a set of character classes according to MASK. */ +extern int isctype (int __c, int __mask) __THROW; +#endif + +#if defined __USE_MISC || defined __USE_XOPEN + +/* Return nonzero iff C is in the ASCII set + (i.e., is no more than 7 bits wide). */ +extern int isascii (int __c) __THROW; + +/* Return the part of C that is in the ASCII set + (i.e., the low-order 7 bits of C). */ +extern int toascii (int __c) __THROW; + +/* These are the same as `toupper' and `tolower' except that they do not + check the argument for being in the range of a `char'. */ +__exctype (_toupper); +__exctype (_tolower); +#endif /* Use X/Open or use misc. */ + +/* This code is needed for the optimized mapping functions. */ +#define __tobody(c, f, a, args) \ + (__extension__ \ + ({ int __res; \ + if (sizeof (c) > 1) \ + { \ + if (__builtin_constant_p (c)) \ + { \ + int __c = (c); \ + __res = __c < -128 || __c > 255 ? __c : (a)[__c]; \ + } \ + else \ + __res = f args; \ + } \ + else \ + __res = (a)[(int) (c)]; \ + __res; })) + +#if !defined __NO_CTYPE +# ifdef __isctype_f +__isctype_f (alnum) +__isctype_f (alpha) +__isctype_f (cntrl) +__isctype_f (digit) +__isctype_f (lower) +__isctype_f (graph) +__isctype_f (print) +__isctype_f (punct) +__isctype_f (space) +__isctype_f (upper) +__isctype_f (xdigit) +# ifdef __USE_ISOC99 +__isctype_f (blank) +# endif +# elif defined __isctype +# define isalnum(c) __isctype((c), _ISalnum) +# define isalpha(c) __isctype((c), _ISalpha) +# define iscntrl(c) __isctype((c), _IScntrl) +# define isdigit(c) __isctype((c), _ISdigit) +# define islower(c) __isctype((c), _ISlower) +# define isgraph(c) __isctype((c), _ISgraph) +# define isprint(c) __isctype((c), _ISprint) +# define ispunct(c) __isctype((c), _ISpunct) +# define isspace(c) __isctype((c), _ISspace) +# define isupper(c) __isctype((c), _ISupper) +# define isxdigit(c) __isctype((c), _ISxdigit) +# ifdef __USE_ISOC99 +# define isblank(c) __isctype((c), _ISblank) +# endif +# endif + +# ifdef __USE_EXTERN_INLINES +__extern_inline int +__NTH (tolower (int __c)) +{ + return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c; +} + +__extern_inline int +__NTH (toupper (int __c)) +{ + return __c >= -128 && __c < 256 ? (*__ctype_toupper_loc ())[__c] : __c; +} +# endif + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c)) +# define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c)) +# endif /* Optimizing gcc */ + +# if defined __USE_MISC || defined __USE_XOPEN +# define isascii(c) __isascii (c) +# define toascii(c) __toascii (c) + +# define _tolower(c) ((int) (*__ctype_tolower_loc ())[(int) (c)]) +# define _toupper(c) ((int) (*__ctype_toupper_loc ())[(int) (c)]) +# endif + +#endif /* Not __NO_CTYPE. */ + + +#ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extended locale interface (see locale.h). */ +# include + +/* These definitions are similar to the ones above but all functions + take as an argument a handle for the locale which shall be used. */ +# define __isctype_l(c, type, locale) \ + ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type) + +# define __exctype_l(name) \ + extern int name (int, locale_t) __THROW + +/* The following names are all functions: + int isCHARACTERISTIC(int c, locale_t *locale); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype_l (isalnum_l); +__exctype_l (isalpha_l); +__exctype_l (iscntrl_l); +__exctype_l (isdigit_l); +__exctype_l (islower_l); +__exctype_l (isgraph_l); +__exctype_l (isprint_l); +__exctype_l (ispunct_l); +__exctype_l (isspace_l); +__exctype_l (isupper_l); +__exctype_l (isxdigit_l); + +__exctype_l (isblank_l); + + +/* Return the lowercase version of C in locale L. */ +extern int __tolower_l (int __c, locale_t __l) __THROW; +extern int tolower_l (int __c, locale_t __l) __THROW; + +/* Return the uppercase version of C. */ +extern int __toupper_l (int __c, locale_t __l) __THROW; +extern int toupper_l (int __c, locale_t __l) __THROW; + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define __tolower_l(c, locale) \ + __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale)) +# define __toupper_l(c, locale) \ + __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale)) +# define tolower_l(c, locale) __tolower_l ((c), (locale)) +# define toupper_l(c, locale) __toupper_l ((c), (locale)) +# endif /* Optimizing gcc */ + + +# ifndef __NO_CTYPE +# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l)) +# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l)) +# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l)) +# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l)) +# define __islower_l(c,l) __isctype_l((c), _ISlower, (l)) +# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l)) +# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l)) +# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l)) +# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l)) +# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l)) +# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l)) + +# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l)) + +# ifdef __USE_MISC +# define __isascii_l(c,l) ((l), __isascii (c)) +# define __toascii_l(c,l) ((l), __toascii (c)) +# endif + +# define isalnum_l(c,l) __isalnum_l ((c), (l)) +# define isalpha_l(c,l) __isalpha_l ((c), (l)) +# define iscntrl_l(c,l) __iscntrl_l ((c), (l)) +# define isdigit_l(c,l) __isdigit_l ((c), (l)) +# define islower_l(c,l) __islower_l ((c), (l)) +# define isgraph_l(c,l) __isgraph_l ((c), (l)) +# define isprint_l(c,l) __isprint_l ((c), (l)) +# define ispunct_l(c,l) __ispunct_l ((c), (l)) +# define isspace_l(c,l) __isspace_l ((c), (l)) +# define isupper_l(c,l) __isupper_l ((c), (l)) +# define isxdigit_l(c,l) __isxdigit_l ((c), (l)) + +# define isblank_l(c,l) __isblank_l ((c), (l)) + +# ifdef __USE_MISC +# define isascii_l(c,l) __isascii_l ((c), (l)) +# define toascii_l(c,l) __toascii_l ((c), (l)) +# endif + +# endif /* Not __NO_CTYPE. */ + +#endif /* Use POSIX 2008. */ + +__END_DECLS + +#endif /* ctype.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bfa43fd61e3d2752e7f381e5dba3a82bb16f070c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@ctype.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h new file mode 100644 index 0000000000000000000000000000000000000000..f91984686103d71b5bf499077d8eac4a0e0184c6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1992-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ENDIAN_H +#define _ENDIAN_H 1 + +#include + +/* Get the definitions of __*_ENDIAN, __BYTE_ORDER, and __FLOAT_WORD_ORDER. */ +#include + +#ifdef __USE_MISC +# define LITTLE_ENDIAN __LITTLE_ENDIAN +# define BIG_ENDIAN __BIG_ENDIAN +# define PDP_ENDIAN __PDP_ENDIAN +# define BYTE_ORDER __BYTE_ORDER +#endif + +#if defined __USE_MISC && !defined __ASSEMBLER__ +/* Conversion interfaces. */ +# include +# include + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define htobe16(x) __bswap_16 (x) +# define htole16(x) __uint16_identity (x) +# define be16toh(x) __bswap_16 (x) +# define le16toh(x) __uint16_identity (x) + +# define htobe32(x) __bswap_32 (x) +# define htole32(x) __uint32_identity (x) +# define be32toh(x) __bswap_32 (x) +# define le32toh(x) __uint32_identity (x) + +# define htobe64(x) __bswap_64 (x) +# define htole64(x) __uint64_identity (x) +# define be64toh(x) __bswap_64 (x) +# define le64toh(x) __uint64_identity (x) + +# else +# define htobe16(x) __uint16_identity (x) +# define htole16(x) __bswap_16 (x) +# define be16toh(x) __uint16_identity (x) +# define le16toh(x) __bswap_16 (x) + +# define htobe32(x) __uint32_identity (x) +# define htole32(x) __bswap_32 (x) +# define be32toh(x) __uint32_identity (x) +# define le32toh(x) __bswap_32 (x) + +# define htobe64(x) __uint64_identity (x) +# define htole64(x) __bswap_64 (x) +# define be64toh(x) __uint64_identity (x) +# define le64toh(x) __bswap_64 (x) +# endif +#endif + +#endif /* endian.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5c255fbd25d261b756efce7af0295d08957edb5f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@endian.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h new file mode 100644 index 0000000000000000000000000000000000000000..c63d16e62b60a5030a4d2953771ec131b69889ca --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h @@ -0,0 +1,55 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.5 Errors + */ + +#ifndef _ERRNO_H +#define _ERRNO_H 1 + +#include + +/* The system-specific definitions of the E* constants, as macros. */ +#include + +/* When included from assembly language, this header only provides the + E* constants. */ +#ifndef __ASSEMBLER__ + +__BEGIN_DECLS + +/* The error code set by various library functions. */ +extern int *__errno_location (void) __THROW __attribute_const__; +# define errno (*__errno_location ()) + +# ifdef __USE_GNU + +/* The full and simple forms of the name with which the program was + invoked. These variables are set up automatically at startup based on + the value of argv[0]. */ +extern char *program_invocation_name; +extern char *program_invocation_short_name; + +#include + +# endif /* __USE_GNU */ + +__END_DECLS + +#endif /* !__ASSEMBLER__ */ +#endif /* errno.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5f5b1e9912e38f27df8bac8ce8c7013baa181293 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@errno.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h new file mode 100644 index 0000000000000000000000000000000000000000..84d56ee3ff2ecfa0d2499385623f30606f84a1bf --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h @@ -0,0 +1,37 @@ +/* Features part to handle 64-bit time_t support. + Copyright (C) 2021-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* We need to know the word size in order to check the time size. */ +#include +#include + +#if defined _TIME_BITS +# if _TIME_BITS == 64 +# if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64 +# error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64" +# elif __TIMESIZE == 32 +# define __USE_TIME_BITS64 1 +# endif +# elif _TIME_BITS == 32 +# if __TIMESIZE > 32 +# error "_TIME_BITS=32 is not compatible with __TIMESIZE > 32" +# endif +# else +# error Invalid _TIME_BITS value (can only be 32 or 64-bit) +# endif +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e4673e544f1c523cdc11126a063ad84a2f3e106e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features-time64.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h new file mode 100644 index 0000000000000000000000000000000000000000..76b8b973d48317aee66929744107ecb9c4d2f776 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h @@ -0,0 +1,517 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _FEATURES_H +#define _FEATURES_H 1 + +/* These are defined by the user (or the compiler) + to specify the desired environment: + + __STRICT_ANSI__ ISO Standard C. + _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. + _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. + _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. + __STDC_WANT_LIB_EXT2__ + Extensions to ISO C99 from TR 27431-2:2010. + __STDC_WANT_IEC_60559_BFP_EXT__ + Extensions to ISO C11 from TS 18661-1:2014. + __STDC_WANT_IEC_60559_FUNCS_EXT__ + Extensions to ISO C11 from TS 18661-4:2015. + __STDC_WANT_IEC_60559_TYPES_EXT__ + Extensions to ISO C11 from TS 18661-3:2015. + __STDC_WANT_IEC_60559_EXT__ + ISO C2X interfaces defined only in Annex F. + + _POSIX_SOURCE IEEE Std 1003.1. + _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; + if >=199309L, add IEEE Std 1003.1b-1993; + if >=199506L, add IEEE Std 1003.1c-1995; + if >=200112L, all of IEEE 1003.1-2004 + if >=200809L, all of IEEE 1003.1-2008 + _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if + Single Unix conformance is wanted, to 600 for the + sixth revision, to 700 for the seventh revision. + _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. + _LARGEFILE_SOURCE Some more functions for correct standard I/O. + _LARGEFILE64_SOURCE Additional functionality from LFS for large files. + _FILE_OFFSET_BITS=N Select default filesystem interface. + _ATFILE_SOURCE Additional *at interfaces. + _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant) + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. + _GNU_SOURCE All of the above, plus GNU extensions. + _DEFAULT_SOURCE The default set of features (taking precedence over + __STRICT_ANSI__). + + _FORTIFY_SOURCE Add security hardening to many library functions. + Set to 1 or 2; 2 performs stricter checks than 1. + + _REENTRANT, _THREAD_SAFE + Obsolete; equivalent to _POSIX_C_SOURCE=199506L. + + The `-ansi' switch to the GNU C compiler, and standards conformance + options such as `-std=c99', define __STRICT_ANSI__. If none of + these are defined, or if _DEFAULT_SOURCE is defined, the default is + to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to + 200809L, as well as enabling miscellaneous functions from BSD and + SVID. If more than one of these are defined, they accumulate. For + example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together + give you ISO C, 1003.1, and 1003.2, but nothing else. + + These are defined by this file and are used by the + header files to decide what to declare or define: + + __GLIBC_USE (F) Define things from feature set F. This is defined + to 1 or 0; the subsequent macros are either defined + or undefined, and those tests should be moved to + __GLIBC_USE. + __USE_ISOC11 Define ISO C11 things. + __USE_ISOC99 Define ISO C99 things. + __USE_ISOC95 Define ISO C90 AMD1 (C95) things. + __USE_ISOCXX11 Define ISO C++11 things. + __USE_POSIX Define IEEE Std 1003.1 things. + __USE_POSIX2 Define IEEE Std 1003.2 things. + __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. + __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. + __USE_XOPEN Define XPG things. + __USE_XOPEN_EXTENDED Define X/Open Unix things. + __USE_UNIX98 Define Single Unix V2 things. + __USE_XOPEN2K Define XPG6 things. + __USE_XOPEN2KXSI Define XPG6 XSI things. + __USE_XOPEN2K8 Define XPG7 things. + __USE_XOPEN2K8XSI Define XPG7 XSI things. + __USE_LARGEFILE Define correct standard I/O things. + __USE_LARGEFILE64 Define LFS things with separate names. + __USE_FILE_OFFSET64 Define 64bit interface as default. + __USE_MISC Define things from 4.3BSD or System V Unix. + __USE_ATFILE Define *at interfaces and AT_* constants for them. + __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant) + MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. + __USE_GNU Define GNU extensions. + __USE_FORTIFY_LEVEL Additional security measures used, according to level. + + The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are + defined by this file unconditionally. `__GNU_LIBRARY__' is provided + only for compatibility. All new code should use the other symbols + to test for features. + + All macros listed above as possibly being defined by this file are + explicitly undefined if they are not explicitly defined. + Feature-test macros that are not defined by the user or compiler + but are implied by the other feature-test macros defined (or by the + lack of any definitions) are defined by the file. + + ISO C feature test macros depend on the definition of the macro + when an affected header is included, not when the first system + header is included, and so they are handled in + , which does not have a multiple include + guard. Feature test macros that can be handled from the first + system header included are handled here. */ + + +/* Undefine everything, so we get a clean slate. */ +#undef __USE_ISOC11 +#undef __USE_ISOC99 +#undef __USE_ISOC95 +#undef __USE_ISOCXX11 +#undef __USE_POSIX +#undef __USE_POSIX2 +#undef __USE_POSIX199309 +#undef __USE_POSIX199506 +#undef __USE_XOPEN +#undef __USE_XOPEN_EXTENDED +#undef __USE_UNIX98 +#undef __USE_XOPEN2K +#undef __USE_XOPEN2KXSI +#undef __USE_XOPEN2K8 +#undef __USE_XOPEN2K8XSI +#undef __USE_LARGEFILE +#undef __USE_LARGEFILE64 +#undef __USE_FILE_OFFSET64 +#undef __USE_MISC +#undef __USE_ATFILE +#undef __USE_DYNAMIC_STACK_SIZE +#undef __USE_GNU +#undef __USE_FORTIFY_LEVEL +#undef __KERNEL_STRICT_NAMES +#undef __GLIBC_USE_ISOC2X +#undef __GLIBC_USE_DEPRECATED_GETS +#undef __GLIBC_USE_DEPRECATED_SCANF + +/* Suppress kernel-name space pollution unless user expressedly asks + for it. */ +#ifndef _LOOSE_KERNEL_NAMES +# define __KERNEL_STRICT_NAMES +#endif + +/* Convenience macro to test the version of gcc. + Use like this: + #if __GNUC_PREREQ (2,8) + ... code requiring gcc 2.8 or later ... + #endif + Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was + added in 2.0. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj, min) 0 +#endif + +/* Similarly for clang. Features added to GCC after version 4.2 may + or may not also be available in clang, and clang's definitions of + __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such + features can be queried via __has_extension/__has_feature. */ +#if defined __clang_major__ && defined __clang_minor__ +# define __glibc_clang_prereq(maj, min) \ + ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) +#else +# define __glibc_clang_prereq(maj, min) 0 +#endif + +/* Whether to use feature set F. */ +#define __GLIBC_USE(F) __GLIBC_USE_ ## F + +/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for + _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not + issue a warning; the expectation is that the source is being + transitioned to use the new macro. */ +#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \ + && !defined _DEFAULT_SOURCE +# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 +#endif + +/* If _GNU_SOURCE was defined by the user, turn on all the other features. */ +#ifdef _GNU_SOURCE +# undef _ISOC95_SOURCE +# define _ISOC95_SOURCE 1 +# undef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +# undef _ISOC11_SOURCE +# define _ISOC11_SOURCE 1 +# undef _ISOC2X_SOURCE +# define _ISOC2X_SOURCE 1 +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200809L +# undef _XOPEN_SOURCE +# define _XOPEN_SOURCE 700 +# undef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +# undef _LARGEFILE64_SOURCE +# define _LARGEFILE64_SOURCE 1 +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 +# undef _ATFILE_SOURCE +# define _ATFILE_SOURCE 1 +# undef _DYNAMIC_STACK_SIZE_SOURCE +# define _DYNAMIC_STACK_SIZE_SOURCE 1 +#endif + +/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, + define _DEFAULT_SOURCE. */ +#if (defined _DEFAULT_SOURCE \ + || (!defined __STRICT_ANSI__ \ + && !defined _ISOC99_SOURCE && !defined _ISOC11_SOURCE \ + && !defined _ISOC2X_SOURCE \ + && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE \ + && !defined _XOPEN_SOURCE)) +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 +#endif + +/* This is to enable the ISO C2X extension. */ +#if (defined _ISOC2X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L)) +# define __GLIBC_USE_ISOC2X 1 +#else +# define __GLIBC_USE_ISOC2X 0 +#endif + +/* This is to enable the ISO C11 extension. */ +#if (defined _ISOC11_SOURCE || defined _ISOC2X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) +# define __USE_ISOC11 1 +#endif + +/* This is to enable the ISO C99 extension. */ +#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \ + || defined _ISOC2X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __USE_ISOC99 1 +#endif + +/* This is to enable the ISO C90 Amendment 1:1995 extension. */ +#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \ + || defined _ISOC2X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L)) +# define __USE_ISOC95 1 +#endif + +#ifdef __cplusplus +/* This is to enable compatibility for ISO C++17. */ +# if __cplusplus >= 201703L +# define __USE_ISOC11 1 +# endif +/* This is to enable compatibility for ISO C++11. + Check the temporary macro for now, too. */ +# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__ +# define __USE_ISOCXX11 1 +# define __USE_ISOC99 1 +# endif +#endif + +/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE + is defined, use POSIX.1-2008 (or another version depending on + _XOPEN_SOURCE). */ +#ifdef _DEFAULT_SOURCE +# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE +# define __USE_POSIX_IMPLICITLY 1 +# endif +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200809L +#endif + +#if ((!defined __STRICT_ANSI__ \ + || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)) \ + && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) +# define _POSIX_SOURCE 1 +# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 +# define _POSIX_C_SOURCE 2 +# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600 +# define _POSIX_C_SOURCE 199506L +# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700 +# define _POSIX_C_SOURCE 200112L +# else +# define _POSIX_C_SOURCE 200809L +# endif +# define __USE_POSIX_IMPLICITLY 1 +#endif + +/* Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be + defined in all multithreaded code. GNU libc has not required this + for many years. We now treat them as compatibility synonyms for + _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with + comprehensive support for multithreaded code. Using them never + lowers the selected level of POSIX conformance, only raises it. */ +#if ((!defined _POSIX_C_SOURCE || (_POSIX_C_SOURCE - 0) < 199506L) \ + && (defined _REENTRANT || defined _THREAD_SAFE)) +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 199506L +#endif + +#if (defined _POSIX_SOURCE \ + || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1) \ + || defined _XOPEN_SOURCE) +# define __USE_POSIX 1 +#endif + +#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE +# define __USE_POSIX2 1 +#endif + +#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L +# define __USE_POSIX199309 1 +#endif + +#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L +# define __USE_POSIX199506 1 +#endif + +#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L +# define __USE_XOPEN2K 1 +# undef __USE_ISOC95 +# define __USE_ISOC95 1 +# undef __USE_ISOC99 +# define __USE_ISOC99 1 +#endif + +#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L +# define __USE_XOPEN2K8 1 +# undef _ATFILE_SOURCE +# define _ATFILE_SOURCE 1 +#endif + +#ifdef _XOPEN_SOURCE +# define __USE_XOPEN 1 +# if (_XOPEN_SOURCE - 0) >= 500 +# define __USE_XOPEN_EXTENDED 1 +# define __USE_UNIX98 1 +# undef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# if (_XOPEN_SOURCE - 0) >= 600 +# if (_XOPEN_SOURCE - 0) >= 700 +# define __USE_XOPEN2K8 1 +# define __USE_XOPEN2K8XSI 1 +# endif +# define __USE_XOPEN2K 1 +# define __USE_XOPEN2KXSI 1 +# undef __USE_ISOC95 +# define __USE_ISOC95 1 +# undef __USE_ISOC99 +# define __USE_ISOC99 1 +# endif +# else +# ifdef _XOPEN_SOURCE_EXTENDED +# define __USE_XOPEN_EXTENDED 1 +# endif +# endif +#endif + +#ifdef _LARGEFILE_SOURCE +# define __USE_LARGEFILE 1 +#endif + +#ifdef _LARGEFILE64_SOURCE +# define __USE_LARGEFILE64 1 +#endif + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +# define __USE_FILE_OFFSET64 1 +#endif + +#include + +#if defined _DEFAULT_SOURCE +# define __USE_MISC 1 +#endif + +#ifdef _ATFILE_SOURCE +# define __USE_ATFILE 1 +#endif + +#ifdef _DYNAMIC_STACK_SIZE_SOURCE +# define __USE_DYNAMIC_STACK_SIZE 1 +#endif + +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 +# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0 +# warning _FORTIFY_SOURCE requires compiling with optimization (-O) +# elif !__GNUC_PREREQ (4, 1) +# warning _FORTIFY_SOURCE requires GCC 4.1 or later +# elif _FORTIFY_SOURCE > 2 && (__glibc_clang_prereq (9, 0) \ + || __GNUC_PREREQ (12, 0)) + +# if _FORTIFY_SOURCE > 3 +# warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform +# endif +# define __USE_FORTIFY_LEVEL 3 +# elif _FORTIFY_SOURCE > 1 +# if _FORTIFY_SOURCE > 2 +# warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform +# endif +# define __USE_FORTIFY_LEVEL 2 +# else +# define __USE_FORTIFY_LEVEL 1 +# endif +#endif +#ifndef __USE_FORTIFY_LEVEL +# define __USE_FORTIFY_LEVEL 0 +#endif + +/* The function 'gets' existed in C89, but is impossible to use + safely. It has been removed from ISO C11 and ISO C++14. Note: for + compatibility with various implementations of , this test + must consider only the value of __cplusplus when compiling C++. */ +#if defined __cplusplus ? __cplusplus >= 201402L : defined __USE_ISOC11 +# define __GLIBC_USE_DEPRECATED_GETS 0 +#else +# define __GLIBC_USE_DEPRECATED_GETS 1 +#endif + +/* GNU formerly extended the scanf functions with modified format + specifiers %as, %aS, and %a[...] that allocate a buffer for the + input using malloc. This extension conflicts with ISO C99, which + defines %a as a standalone format specifier that reads a floating- + point number; moreover, POSIX.1-2008 provides the same feature + using the modifier letter 'm' instead (%ms, %mS, %m[...]). + + We now follow C99 unless GNU extensions are active and the compiler + is specifically in C89 or C++98 mode (strict or not). For + instance, with GCC, -std=gnu11 will have C99-compliant scanf with + or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the + old extension. */ +#if (defined __USE_GNU \ + && (defined __cplusplus \ + ? (__cplusplus < 201103L && !defined __GXX_EXPERIMENTAL_CXX0X__) \ + : (!defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L))) +# define __GLIBC_USE_DEPRECATED_SCANF 1 +#else +# define __GLIBC_USE_DEPRECATED_SCANF 0 +#endif + +/* Get definitions of __STDC_* predefined macros, if the compiler has + not preincluded this header automatically. */ +#include + +/* This macro indicates that the installed library is the GNU C Library. + For historic reasons the value now is 6 and this will stay from now + on. The use of this variable is deprecated. Use __GLIBC__ and + __GLIBC_MINOR__ now (see below) when you want to test for a specific + GNU C library version and use the values in to get + the sonames of the shared libraries. */ +#undef __GNU_LIBRARY__ +#define __GNU_LIBRARY__ 6 + +/* Major and minor version number of the GNU C library package. Use + these macros to test for features in specific releases. */ +#define __GLIBC__ 2 +#define __GLIBC_MINOR__ 35 + +#define __GLIBC_PREREQ(maj, min) \ + ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) + +/* This is here only because every header file already includes this one. */ +#ifndef __ASSEMBLER__ +# ifndef _SYS_CDEFS_H +# include +# endif + +/* If we don't have __REDIRECT, prototypes will be missing if + __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ +# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT +# define __USE_LARGEFILE 1 +# define __USE_LARGEFILE64 1 +# endif + +#endif /* !ASSEMBLER */ + +/* Decide whether we can define 'extern inline' functions in headers. */ +#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ + && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \ + && defined __extern_inline +# define __USE_EXTERN_INLINES 1 +#endif + + +/* This is here only because every header file already includes this one. + Get the definitions of all the appropriate `__stub_FUNCTION' symbols. + contains `#define __stub_FUNCTION' when FUNCTION is a stub + that will always return failure (and set errno to ENOSYS). */ +#include + + +#endif /* features.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bfe99b746af9c5dd69ff616f8626f8199581f0b8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@features.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h new file mode 100644 index 0000000000000000000000000000000000000000..992e9fbd416c70397f39adbd24e11b9e1edfe285 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h @@ -0,0 +1,170 @@ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 7.6: Floating-point environment + */ + +#ifndef _FENV_H +#define _FENV_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +/* Get the architecture dependend definitions. The following definitions + are expected to be done: + + fenv_t type for object representing an entire floating-point + environment + + FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument + to functions taking an argument of type fenv_t; in this + case the default environment will be used + + fexcept_t type for object representing the floating-point exception + flags including status associated with the flags + + femode_t type for object representing floating-point control modes + + FE_DFL_MODE macro of type pointer to const femode_t to be used as the + argument to fesetmode; in this case the default control + modes will be used + + The following macros are defined iff the implementation supports this + kind of exception. + FE_INEXACT inexact result + FE_DIVBYZERO division by zero + FE_UNDERFLOW result not representable due to underflow + FE_OVERFLOW result not representable due to overflow + FE_INVALID invalid operation + + FE_ALL_EXCEPT bitwise OR of all supported exceptions + + The next macros are defined iff the appropriate rounding mode is + supported by the implementation. + FE_TONEAREST round to nearest + FE_UPWARD round toward +Inf + FE_DOWNWARD round toward -Inf + FE_TOWARDZERO round toward 0 +*/ +#include + +__BEGIN_DECLS + +/* Floating-point exception handling. */ + +/* Clear the supported exceptions represented by EXCEPTS. */ +extern int feclearexcept (int __excepts) __THROW; + +/* Store implementation-defined representation of the exception flags + indicated by EXCEPTS in the object pointed to by FLAGP. */ +extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW; + +/* Raise the supported exceptions represented by EXCEPTS. */ +extern int feraiseexcept (int __excepts) __THROW; + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* Set the supported exception flags represented by EXCEPTS, without + causing enabled traps to be taken. */ +extern int fesetexcept (int __excepts) __THROW; +#endif + +/* Set complete status for exceptions indicated by EXCEPTS according to + the representation in the object pointed to by FLAGP. */ +extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW; + +/* Determine which of subset of the exceptions specified by EXCEPTS are + currently set. */ +extern int fetestexcept (int __excepts) __THROW; + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* Determine which of subset of the exceptions specified by EXCEPTS + are set in *FLAGP. */ +extern int fetestexceptflag (const fexcept_t *__flagp, int __excepts) __THROW; +#endif + + +/* Rounding control. */ + +/* Get current rounding direction. */ +extern int fegetround (void) __THROW __attribute_pure__; + +/* Establish the rounding direction represented by ROUND. */ +extern int fesetround (int __rounding_direction) __THROW; + + +/* Floating-point environment. */ + +/* Store the current floating-point environment in the object pointed + to by ENVP. */ +extern int fegetenv (fenv_t *__envp) __THROW; + +/* Save the current environment in the object pointed to by ENVP, clear + exception flags and install a non-stop mode (if available) for all + exceptions. */ +extern int feholdexcept (fenv_t *__envp) __THROW; + +/* Establish the floating-point environment represented by the object + pointed to by ENVP. */ +extern int fesetenv (const fenv_t *__envp) __THROW; + +/* Save current exceptions in temporary storage, install environment + represented by object pointed to by ENVP and raise exceptions + according to saved exceptions. */ +extern int feupdateenv (const fenv_t *__envp) __THROW; + + +/* Control modes. */ + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* Store the current floating-point control modes in the object + pointed to by MODEP. */ +extern int fegetmode (femode_t *__modep) __THROW; + +/* Establish the floating-point control modes represented by the + object pointed to by MODEP. */ +extern int fesetmode (const femode_t *__modep) __THROW; +#endif + + +/* NaN support. */ + +#if (__GLIBC_USE (IEC_60559_BFP_EXT_C2X) \ + && defined FE_INVALID \ + && defined __SUPPORT_SNAN__) +# define FE_SNANS_ALWAYS_SIGNAL 1 +#endif + +#ifdef __USE_GNU + +/* Enable individual exceptions. Will not enable more exceptions than + EXCEPTS specifies. Returns the previous enabled exceptions if all + exceptions are successfully set, otherwise returns -1. */ +extern int feenableexcept (int __excepts) __THROW; + +/* Disable individual exceptions. Will not disable more exceptions than + EXCEPTS specifies. Returns the previous enabled exceptions if all + exceptions are successfully disabled, otherwise returns -1. */ +extern int fedisableexcept (int __excepts) __THROW; + +/* Return enabled exceptions. */ +extern int fegetexcept (void) __THROW; +#endif + +__END_DECLS + +#endif /* fenv.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..442d4dabb0edb35083dcd7d9172e08b8c4b8ee6a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@fenv.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h new file mode 100644 index 0000000000000000000000000000000000000000..b745721576c9fb62942410a17e2016cc10dc0884 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h @@ -0,0 +1,17 @@ +/* This file is automatically generated. + It defines a symbol `__stub_FUNCTION' for each function + in the C library which is a stub, meaning it will fail + every time called, usually setting errno to ENOSYS. */ + +#ifdef _LIBC + #error Applications may not define the macro _LIBC +#endif + +#define __stub___compat_bdflush +#define __stub_chflags +#define __stub_fchflags +#define __stub_gtty +#define __stub_revoke +#define __stub_setlogin +#define __stub_sigreturn +#define __stub_stty diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d92fedf4b3b4b6f84db451a01a94642b6fa49706 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs-64.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h new file mode 100644 index 0000000000000000000000000000000000000000..70a1ba017357d3111cc510e73b269541ca2aaf09 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h @@ -0,0 +1,14 @@ +/* This file is automatically generated. + This file selects the right generated file of `__stub_FUNCTION' macros + based on the architecture being compiled for. */ + + +#if !defined __x86_64__ +# include +#endif +#if defined __x86_64__ && defined __LP64__ +# include +#endif +#if defined __x86_64__ && defined __ILP32__ +# include +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..50bdc7a7f72faf4f29dd842e0291194c8f099991 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@gnu@stubs.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h new file mode 100644 index 0000000000000000000000000000000000000000..d550769f2aaddc989670879165d6fca9ac3cdd4d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h @@ -0,0 +1,316 @@ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99: 7.8 Format conversion of integer types + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H 1 + +#include +/* Get the type definitions. */ +#include + +/* Get a definition for wchar_t. But we must not define wchar_t itself. */ +#ifndef ____gwchar_t_defined +# ifdef __cplusplus +# define __gwchar_t wchar_t +# elif defined __WCHAR_TYPE__ +typedef __WCHAR_TYPE__ __gwchar_t; +# else +# define __need_wchar_t +# include +typedef wchar_t __gwchar_t; +# endif +# define ____gwchar_t_defined 1 +#endif + +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# define __PRIPTR_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX +# endif + +/* Macros for printing format specifiers. */ + +/* Decimal notation. */ +# define PRId8 "d" +# define PRId16 "d" +# define PRId32 "d" +# define PRId64 __PRI64_PREFIX "d" + +# define PRIdLEAST8 "d" +# define PRIdLEAST16 "d" +# define PRIdLEAST32 "d" +# define PRIdLEAST64 __PRI64_PREFIX "d" + +# define PRIdFAST8 "d" +# define PRIdFAST16 __PRIPTR_PREFIX "d" +# define PRIdFAST32 __PRIPTR_PREFIX "d" +# define PRIdFAST64 __PRI64_PREFIX "d" + + +# define PRIi8 "i" +# define PRIi16 "i" +# define PRIi32 "i" +# define PRIi64 __PRI64_PREFIX "i" + +# define PRIiLEAST8 "i" +# define PRIiLEAST16 "i" +# define PRIiLEAST32 "i" +# define PRIiLEAST64 __PRI64_PREFIX "i" + +# define PRIiFAST8 "i" +# define PRIiFAST16 __PRIPTR_PREFIX "i" +# define PRIiFAST32 __PRIPTR_PREFIX "i" +# define PRIiFAST64 __PRI64_PREFIX "i" + +/* Octal notation. */ +# define PRIo8 "o" +# define PRIo16 "o" +# define PRIo32 "o" +# define PRIo64 __PRI64_PREFIX "o" + +# define PRIoLEAST8 "o" +# define PRIoLEAST16 "o" +# define PRIoLEAST32 "o" +# define PRIoLEAST64 __PRI64_PREFIX "o" + +# define PRIoFAST8 "o" +# define PRIoFAST16 __PRIPTR_PREFIX "o" +# define PRIoFAST32 __PRIPTR_PREFIX "o" +# define PRIoFAST64 __PRI64_PREFIX "o" + +/* Unsigned integers. */ +# define PRIu8 "u" +# define PRIu16 "u" +# define PRIu32 "u" +# define PRIu64 __PRI64_PREFIX "u" + +# define PRIuLEAST8 "u" +# define PRIuLEAST16 "u" +# define PRIuLEAST32 "u" +# define PRIuLEAST64 __PRI64_PREFIX "u" + +# define PRIuFAST8 "u" +# define PRIuFAST16 __PRIPTR_PREFIX "u" +# define PRIuFAST32 __PRIPTR_PREFIX "u" +# define PRIuFAST64 __PRI64_PREFIX "u" + +/* lowercase hexadecimal notation. */ +# define PRIx8 "x" +# define PRIx16 "x" +# define PRIx32 "x" +# define PRIx64 __PRI64_PREFIX "x" + +# define PRIxLEAST8 "x" +# define PRIxLEAST16 "x" +# define PRIxLEAST32 "x" +# define PRIxLEAST64 __PRI64_PREFIX "x" + +# define PRIxFAST8 "x" +# define PRIxFAST16 __PRIPTR_PREFIX "x" +# define PRIxFAST32 __PRIPTR_PREFIX "x" +# define PRIxFAST64 __PRI64_PREFIX "x" + +/* UPPERCASE hexadecimal notation. */ +# define PRIX8 "X" +# define PRIX16 "X" +# define PRIX32 "X" +# define PRIX64 __PRI64_PREFIX "X" + +# define PRIXLEAST8 "X" +# define PRIXLEAST16 "X" +# define PRIXLEAST32 "X" +# define PRIXLEAST64 __PRI64_PREFIX "X" + +# define PRIXFAST8 "X" +# define PRIXFAST16 __PRIPTR_PREFIX "X" +# define PRIXFAST32 __PRIPTR_PREFIX "X" +# define PRIXFAST64 __PRI64_PREFIX "X" + + +/* Macros for printing `intmax_t' and `uintmax_t'. */ +# define PRIdMAX __PRI64_PREFIX "d" +# define PRIiMAX __PRI64_PREFIX "i" +# define PRIoMAX __PRI64_PREFIX "o" +# define PRIuMAX __PRI64_PREFIX "u" +# define PRIxMAX __PRI64_PREFIX "x" +# define PRIXMAX __PRI64_PREFIX "X" + + +/* Macros for printing `intptr_t' and `uintptr_t'. */ +# define PRIdPTR __PRIPTR_PREFIX "d" +# define PRIiPTR __PRIPTR_PREFIX "i" +# define PRIoPTR __PRIPTR_PREFIX "o" +# define PRIuPTR __PRIPTR_PREFIX "u" +# define PRIxPTR __PRIPTR_PREFIX "x" +# define PRIXPTR __PRIPTR_PREFIX "X" + + +/* Macros for scanning format specifiers. */ + +/* Signed decimal notation. */ +# define SCNd8 "hhd" +# define SCNd16 "hd" +# define SCNd32 "d" +# define SCNd64 __PRI64_PREFIX "d" + +# define SCNdLEAST8 "hhd" +# define SCNdLEAST16 "hd" +# define SCNdLEAST32 "d" +# define SCNdLEAST64 __PRI64_PREFIX "d" + +# define SCNdFAST8 "hhd" +# define SCNdFAST16 __PRIPTR_PREFIX "d" +# define SCNdFAST32 __PRIPTR_PREFIX "d" +# define SCNdFAST64 __PRI64_PREFIX "d" + +/* Signed decimal notation. */ +# define SCNi8 "hhi" +# define SCNi16 "hi" +# define SCNi32 "i" +# define SCNi64 __PRI64_PREFIX "i" + +# define SCNiLEAST8 "hhi" +# define SCNiLEAST16 "hi" +# define SCNiLEAST32 "i" +# define SCNiLEAST64 __PRI64_PREFIX "i" + +# define SCNiFAST8 "hhi" +# define SCNiFAST16 __PRIPTR_PREFIX "i" +# define SCNiFAST32 __PRIPTR_PREFIX "i" +# define SCNiFAST64 __PRI64_PREFIX "i" + +/* Unsigned decimal notation. */ +# define SCNu8 "hhu" +# define SCNu16 "hu" +# define SCNu32 "u" +# define SCNu64 __PRI64_PREFIX "u" + +# define SCNuLEAST8 "hhu" +# define SCNuLEAST16 "hu" +# define SCNuLEAST32 "u" +# define SCNuLEAST64 __PRI64_PREFIX "u" + +# define SCNuFAST8 "hhu" +# define SCNuFAST16 __PRIPTR_PREFIX "u" +# define SCNuFAST32 __PRIPTR_PREFIX "u" +# define SCNuFAST64 __PRI64_PREFIX "u" + +/* Octal notation. */ +# define SCNo8 "hho" +# define SCNo16 "ho" +# define SCNo32 "o" +# define SCNo64 __PRI64_PREFIX "o" + +# define SCNoLEAST8 "hho" +# define SCNoLEAST16 "ho" +# define SCNoLEAST32 "o" +# define SCNoLEAST64 __PRI64_PREFIX "o" + +# define SCNoFAST8 "hho" +# define SCNoFAST16 __PRIPTR_PREFIX "o" +# define SCNoFAST32 __PRIPTR_PREFIX "o" +# define SCNoFAST64 __PRI64_PREFIX "o" + +/* Hexadecimal notation. */ +# define SCNx8 "hhx" +# define SCNx16 "hx" +# define SCNx32 "x" +# define SCNx64 __PRI64_PREFIX "x" + +# define SCNxLEAST8 "hhx" +# define SCNxLEAST16 "hx" +# define SCNxLEAST32 "x" +# define SCNxLEAST64 __PRI64_PREFIX "x" + +# define SCNxFAST8 "hhx" +# define SCNxFAST16 __PRIPTR_PREFIX "x" +# define SCNxFAST32 __PRIPTR_PREFIX "x" +# define SCNxFAST64 __PRI64_PREFIX "x" + + +/* Macros for scanning `intmax_t' and `uintmax_t'. */ +# define SCNdMAX __PRI64_PREFIX "d" +# define SCNiMAX __PRI64_PREFIX "i" +# define SCNoMAX __PRI64_PREFIX "o" +# define SCNuMAX __PRI64_PREFIX "u" +# define SCNxMAX __PRI64_PREFIX "x" + +/* Macros for scaning `intptr_t' and `uintptr_t'. */ +# define SCNdPTR __PRIPTR_PREFIX "d" +# define SCNiPTR __PRIPTR_PREFIX "i" +# define SCNoPTR __PRIPTR_PREFIX "o" +# define SCNuPTR __PRIPTR_PREFIX "u" +# define SCNxPTR __PRIPTR_PREFIX "x" + + +__BEGIN_DECLS + +#if __WORDSIZE == 64 + +/* We have to define the `uintmax_t' type using `ldiv_t'. */ +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } imaxdiv_t; + +#else + +/* We have to define the `uintmax_t' type using `lldiv_t'. */ +typedef struct + { + __extension__ long long int quot; /* Quotient. */ + __extension__ long long int rem; /* Remainder. */ + } imaxdiv_t; + +#endif + + +/* Compute absolute value of N. */ +extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); + +/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ +extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) + __THROW __attribute__ ((__const__)); + +/* Like `strtol' but convert to `intmax_t'. */ +extern intmax_t strtoimax (const char *__restrict __nptr, + char **__restrict __endptr, int __base) __THROW; + +/* Like `strtoul' but convert to `uintmax_t'. */ +extern uintmax_t strtoumax (const char *__restrict __nptr, + char ** __restrict __endptr, int __base) __THROW; + +/* Like `wcstol' but convert to `intmax_t'. */ +extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr, + __gwchar_t **__restrict __endptr, int __base) + __THROW; + +/* Like `wcstoul' but convert to `uintmax_t'. */ +extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr, + __gwchar_t ** __restrict __endptr, int __base) + __THROW; + +__END_DECLS + +#endif /* inttypes.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..64e9e5ac1835bcaac4436ff2cbe24d01cf7b3839 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@inttypes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h new file mode 100644 index 0000000000000000000000000000000000000000..22f79b248cacee6d9c3a793a1211b63375fe64c4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h @@ -0,0 +1,123 @@ +/* Message catalogs for internationalization. + Copyright (C) 1995-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + This file is derived from the file libgettext.h in the GNU gettext package. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBINTL_H +#define _LIBINTL_H 1 + +#include + +/* We define an additional symbol to signal that we use the GNU + implementation of gettext. */ +#define __USE_GNU_GETTEXT 1 + +/* Provide information about the supported file formats. Returns the + maximum minor revision number supported for a given major revision. */ +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ + ((major) == 0 ? 1 : -1) + +__BEGIN_DECLS + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +extern char *gettext (const char *__msgid) + __THROW __attribute_format_arg__ (1); + +/* Look up MSGID in the DOMAINNAME message catalog for the current + LC_MESSAGES locale. */ +extern char *dgettext (const char *__domainname, const char *__msgid) + __THROW __attribute_format_arg__ (2); +extern char *__dgettext (const char *__domainname, const char *__msgid) + __THROW __attribute_format_arg__ (2); + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +extern char *dcgettext (const char *__domainname, + const char *__msgid, int __category) + __THROW __attribute_format_arg__ (2); +extern char *__dcgettext (const char *__domainname, + const char *__msgid, int __category) + __THROW __attribute_format_arg__ (2); + + +/* Similar to `gettext' but select the plural form corresponding to the + number N. */ +extern char *ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n) + __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2); + +/* Similar to `dgettext' but select the plural form corresponding to the + number N. */ +extern char *dngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + +/* Similar to `dcgettext' but select the plural form corresponding to the + number N. */ +extern char *dcngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n, + int __category) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +extern char *textdomain (const char *__domainname) __THROW; + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +extern char *bindtextdomain (const char *__domainname, + const char *__dirname) __THROW; + +/* Specify the character encoding in which the messages from the + DOMAINNAME message catalog will be returned. */ +extern char *bind_textdomain_codeset (const char *__domainname, + const char *__codeset) __THROW; + + +/* Optimized version of the function above. */ +#if defined __OPTIMIZE__ && !defined __cplusplus + +/* We need NULL for `gettext'. */ +# define __need_NULL +# include + +/* We need LC_MESSAGES for `dgettext'. */ +# include + +/* These must be macros. Inlined functions are useless because the + `__builtin_constant_p' predicate in dcgettext would always return + false. */ + +# define gettext(msgid) dgettext (NULL, msgid) + +# define dgettext(domainname, msgid) \ + dcgettext (domainname, msgid, LC_MESSAGES) + +# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) + +# define dngettext(domainname, msgid1, msgid2, n) \ + dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) + +#endif /* Optimizing. */ + +__END_DECLS + +#endif /* libintl.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0258babecaff59b14056aed8ac6da5eed14805c4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@libintl.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h new file mode 100644 index 0000000000000000000000000000000000000000..e332be732d103972ac95589798f566bdf0b6b484 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h @@ -0,0 +1,204 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types + */ + +#ifndef _LIBC_LIMITS_H_ +#define _LIBC_LIMITS_H_ 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + + +/* Maximum length of any multibyte character in any locale. + We define this value here since the gcc header does not define + the correct value. */ +#define MB_LEN_MAX 16 + + +/* If we are not using GNU CC we have to define all the symbols ourself. + Otherwise use gcc's definitions (see below). */ +#if !defined __GNUC__ || __GNUC__ < 2 + +/* We only protect from multiple inclusion here, because all the other + #include's protect themselves, and in GCC 2 we may #include_next through + multiple copies of this file before we get to GCC's. */ +# ifndef _LIMITS_H +# define _LIMITS_H 1 + +#include + +/* We don't have #include_next. + Define ANSI for standard 32-bit words. */ + +/* These assume 8-bit `char's, 16-bit `short int's, + and 32-bit `int's and `long int's. */ + +/* Number of bits in a `char'. */ +# define CHAR_BIT 8 + +/* Minimum and maximum values a `signed char' can hold. */ +# define SCHAR_MIN (-128) +# define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */ +# define UCHAR_MAX 255 + +/* Minimum and maximum values a `char' can hold. */ +# ifdef __CHAR_UNSIGNED__ +# define CHAR_MIN 0 +# define CHAR_MAX UCHAR_MAX +# else +# define CHAR_MIN SCHAR_MIN +# define CHAR_MAX SCHAR_MAX +# endif + +/* Minimum and maximum values a `signed short int' can hold. */ +# define SHRT_MIN (-32768) +# define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ +# define USHRT_MAX 65535 + +/* Minimum and maximum values a `signed int' can hold. */ +# define INT_MIN (-INT_MAX - 1) +# define INT_MAX 2147483647 + +/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */ +# define UINT_MAX 4294967295U + +/* Minimum and maximum values a `signed long int' can hold. */ +# if __WORDSIZE == 64 +# define LONG_MAX 9223372036854775807L +# else +# define LONG_MAX 2147483647L +# endif +# define LONG_MIN (-LONG_MAX - 1L) + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ +# if __WORDSIZE == 64 +# define ULONG_MAX 18446744073709551615UL +# else +# define ULONG_MAX 4294967295UL +# endif + +# ifdef __USE_ISOC99 + +/* Minimum and maximum values a `signed long long int' can hold. */ +# define LLONG_MAX 9223372036854775807LL +# define LLONG_MIN (-LLONG_MAX - 1LL) + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +# define ULLONG_MAX 18446744073709551615ULL + +# endif /* ISO C99 */ + +# endif /* limits.h */ +#endif /* GCC 2. */ + +#endif /* !_LIBC_LIMITS_H_ */ + + /* Get the compiler's limits.h, which defines almost all the ISO constants. + + We put this #include_next outside the double inclusion check because + it should be possible to include this file more than once and still get + the definitions from gcc's header. */ +#if defined __GNUC__ && !defined _GCC_LIMITS_H_ +/* `_GCC_LIMITS_H_' is what GCC's file defines. */ +# include_next +#endif + +/* The files in some gcc versions don't define LLONG_MIN, + LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for + ages are available. */ +#if defined __USE_ISOC99 && defined __GNUC__ +# ifndef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX-1) +# endif +# ifndef LLONG_MAX +# define LLONG_MAX __LONG_LONG_MAX__ +# endif +# ifndef ULLONG_MAX +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +# endif +#endif + +/* The integer width macros are not defined by GCC's before + GCC 7, or if _GNU_SOURCE rather than + __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */ +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +# ifndef CHAR_WIDTH +# define CHAR_WIDTH 8 +# endif +# ifndef SCHAR_WIDTH +# define SCHAR_WIDTH 8 +# endif +# ifndef UCHAR_WIDTH +# define UCHAR_WIDTH 8 +# endif +# ifndef SHRT_WIDTH +# define SHRT_WIDTH 16 +# endif +# ifndef USHRT_WIDTH +# define USHRT_WIDTH 16 +# endif +# ifndef INT_WIDTH +# define INT_WIDTH 32 +# endif +# ifndef UINT_WIDTH +# define UINT_WIDTH 32 +# endif +# ifndef LONG_WIDTH +# define LONG_WIDTH __WORDSIZE +# endif +# ifndef ULONG_WIDTH +# define ULONG_WIDTH __WORDSIZE +# endif +# ifndef LLONG_WIDTH +# define LLONG_WIDTH 64 +# endif +# ifndef ULLONG_WIDTH +# define ULLONG_WIDTH 64 +# endif +#endif /* Use IEC_60559_BFP_EXT. */ + +/* The macros for _Bool are not defined by GCC's before GCC + 11, or if _GNU_SOURCE is defined rather than enabling C2x support + with -std. */ +#if __GLIBC_USE (ISOC2X) +# ifndef BOOL_MAX +# define BOOL_MAX 1 +# endif +# ifndef BOOL_WIDTH +# define BOOL_WIDTH 1 +# endif +#endif + +#ifdef __USE_POSIX +/* POSIX adds things to . */ +# include +#endif + +#ifdef __USE_POSIX2 +# include +#endif + +#ifdef __USE_XOPEN +# include +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..85bea5f96a600f8b30a96c598dd66d854fa08b82 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@limits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h new file mode 100644 index 0000000000000000000000000000000000000000..1d85dff703d7e3d3b560f4d3df11f5067df96c65 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h @@ -0,0 +1,197 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.11 Localization + */ + +#ifndef _LOCALE_H +#define _LOCALE_H 1 + +#include + +#define __need_NULL +#include +#include + +__BEGIN_DECLS + +/* These are the possibilities for the first argument to setlocale. + The code assumes that the lowest LC_* symbol has the value zero. */ +#define LC_CTYPE __LC_CTYPE +#define LC_NUMERIC __LC_NUMERIC +#define LC_TIME __LC_TIME +#define LC_COLLATE __LC_COLLATE +#define LC_MONETARY __LC_MONETARY +#define LC_MESSAGES __LC_MESSAGES +#define LC_ALL __LC_ALL +#define LC_PAPER __LC_PAPER +#define LC_NAME __LC_NAME +#define LC_ADDRESS __LC_ADDRESS +#define LC_TELEPHONE __LC_TELEPHONE +#define LC_MEASUREMENT __LC_MEASUREMENT +#define LC_IDENTIFICATION __LC_IDENTIFICATION + + +/* Structure giving information about numeric and monetary notation. */ +struct lconv +{ + /* Numeric (non-monetary) information. */ + + char *decimal_point; /* Decimal point character. */ + char *thousands_sep; /* Thousands separator. */ + /* Each element is the number of digits in each group; + elements with higher indices are farther left. + An element with value CHAR_MAX means that no further grouping is done. + An element with value 0 means that the previous element is used + for all groups farther left. */ + char *grouping; + + /* Monetary information. */ + + /* First three chars are a currency symbol from ISO 4217. + Fourth char is the separator. Fifth char is '\0'. */ + char *int_curr_symbol; + char *currency_symbol; /* Local currency symbol. */ + char *mon_decimal_point; /* Decimal point character. */ + char *mon_thousands_sep; /* Thousands separator. */ + char *mon_grouping; /* Like `grouping' element (above). */ + char *positive_sign; /* Sign for positive values. */ + char *negative_sign; /* Sign for negative values. */ + char int_frac_digits; /* Int'l fractional digits. */ + char frac_digits; /* Local fractional digits. */ + /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ + char p_cs_precedes; + /* 1 iff a space separates currency_symbol from a positive value. */ + char p_sep_by_space; + /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ + char n_cs_precedes; + /* 1 iff a space separates currency_symbol from a negative value. */ + char n_sep_by_space; + /* Positive and negative sign positions: + 0 Parentheses surround the quantity and currency_symbol. + 1 The sign string precedes the quantity and currency_symbol. + 2 The sign string follows the quantity and currency_symbol. + 3 The sign string immediately precedes the currency_symbol. + 4 The sign string immediately follows the currency_symbol. */ + char p_sign_posn; + char n_sign_posn; +#ifdef __USE_ISOC99 + /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */ + char int_p_cs_precedes; + /* 1 iff a space separates int_curr_symbol from a positive value. */ + char int_p_sep_by_space; + /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */ + char int_n_cs_precedes; + /* 1 iff a space separates int_curr_symbol from a negative value. */ + char int_n_sep_by_space; + /* Positive and negative sign positions: + 0 Parentheses surround the quantity and int_curr_symbol. + 1 The sign string precedes the quantity and int_curr_symbol. + 2 The sign string follows the quantity and int_curr_symbol. + 3 The sign string immediately precedes the int_curr_symbol. + 4 The sign string immediately follows the int_curr_symbol. */ + char int_p_sign_posn; + char int_n_sign_posn; +#else + char __int_p_cs_precedes; + char __int_p_sep_by_space; + char __int_n_cs_precedes; + char __int_n_sep_by_space; + char __int_p_sign_posn; + char __int_n_sign_posn; +#endif +}; + + +/* Set and/or return the current locale. */ +extern char *setlocale (int __category, const char *__locale) __THROW; + +/* Return the numeric/monetary information for the current locale. */ +extern struct lconv *localeconv (void) __THROW; + + +#ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extends the locale interface with functions for + explicit creation and manipulation of 'locale_t' objects + representing locale contexts, and a set of parallel + locale-sensitive text processing functions that take a locale_t + argument. This enables applications to work with data from + multiple locales simultaneously and thread-safely. */ +# include + +/* Return a reference to a data structure representing a set of locale + datasets. Unlike for the CATEGORY parameter for `setlocale' the + CATEGORY_MASK parameter here uses a single bit for each category, + made by OR'ing together LC_*_MASK bits above. */ +extern locale_t newlocale (int __category_mask, const char *__locale, + locale_t __base) __THROW; + +/* These are the bits that can be set in the CATEGORY_MASK argument to + `newlocale'. In the GNU implementation, LC_FOO_MASK has the value + of (1 << LC_FOO), but this is not a part of the interface that + callers can assume will be true. */ +# define LC_CTYPE_MASK (1 << __LC_CTYPE) +# define LC_NUMERIC_MASK (1 << __LC_NUMERIC) +# define LC_TIME_MASK (1 << __LC_TIME) +# define LC_COLLATE_MASK (1 << __LC_COLLATE) +# define LC_MONETARY_MASK (1 << __LC_MONETARY) +# define LC_MESSAGES_MASK (1 << __LC_MESSAGES) +# define LC_PAPER_MASK (1 << __LC_PAPER) +# define LC_NAME_MASK (1 << __LC_NAME) +# define LC_ADDRESS_MASK (1 << __LC_ADDRESS) +# define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE) +# define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT) +# define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION) +# define LC_ALL_MASK (LC_CTYPE_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK \ + | LC_COLLATE_MASK \ + | LC_MONETARY_MASK \ + | LC_MESSAGES_MASK \ + | LC_PAPER_MASK \ + | LC_NAME_MASK \ + | LC_ADDRESS_MASK \ + | LC_TELEPHONE_MASK \ + | LC_MEASUREMENT_MASK \ + | LC_IDENTIFICATION_MASK \ + ) + +/* Return a duplicate of the set of locale in DATASET. All usage + counters are increased if necessary. */ +extern locale_t duplocale (locale_t __dataset) __THROW; + +/* Free the data associated with a locale dataset previously returned + by a call to `setlocale_r'. */ +extern void freelocale (locale_t __dataset) __THROW; + +/* Switch the current thread's locale to DATASET. + If DATASET is null, instead just return the current setting. + The special value LC_GLOBAL_LOCALE is the initial setting + for all threads and can also be installed any time, meaning + the thread uses the global settings controlled by `setlocale'. */ +extern locale_t uselocale (locale_t __dataset) __THROW; + +/* This value can be passed to `uselocale' and may be returned by it. + Passing this value to any other function has undefined behavior. */ +# define LC_GLOBAL_LOCALE ((locale_t) -1L) + +#endif + +__END_DECLS + +#endif /* locale.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..22603e661e3a27148a711ad7be3e46bf22097b52 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@locale.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h new file mode 100644 index 0000000000000000000000000000000000000000..27963ef6dcd4dcd718eccaca9844829dff03eab6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h @@ -0,0 +1,1426 @@ +/* Declarations for math functions. + Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.12 Mathematics + */ + +#ifndef _MATH_H +#define _MATH_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +#if defined log && defined __GNUC__ +# warning A macro called log was already defined when was included. +# warning This will cause compilation problems. +#endif + +__BEGIN_DECLS + +/* Get definitions of __intmax_t and __uintmax_t. */ +#include + +/* Get machine-dependent vector math functions declarations. */ +#include + +/* Gather machine dependent type support. */ +#include + +/* Value returned on overflow. With IEEE 754 floating point, this is + +Infinity, otherwise the largest representable positive value. */ +#if __GNUC_PREREQ (3, 3) +# define HUGE_VAL (__builtin_huge_val ()) +#else +/* This may provoke compiler warnings, and may not be rounded to + +Infinity in all IEEE 754 rounding modes, but is the best that can + be done in ISO C while remaining a constant expression. 10,000 is + greater than the maximum (decimal) exponent for all supported + floating-point formats and widths. */ +# define HUGE_VAL 1e10000 +#endif +#ifdef __USE_ISOC99 +# if __GNUC_PREREQ (3, 3) +# define HUGE_VALF (__builtin_huge_valf ()) +# define HUGE_VALL (__builtin_huge_vall ()) +# else +# define HUGE_VALF 1e10000f +# define HUGE_VALL 1e10000L +# endif +#endif +#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F16 (__builtin_huge_valf16 ()) +#endif +#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F32 (__builtin_huge_valf32 ()) +#endif +#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F64 (__builtin_huge_valf64 ()) +#endif +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F128 (__builtin_huge_valf128 ()) +#endif +#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F32X (__builtin_huge_valf32x ()) +#endif +#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F64X (__builtin_huge_valf64x ()) +#endif +#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define HUGE_VAL_F128X (__builtin_huge_valf128x ()) +#endif + +#ifdef __USE_ISOC99 +/* IEEE positive infinity. */ +# if __GNUC_PREREQ (3, 3) +# define INFINITY (__builtin_inff ()) +# else +# define INFINITY HUGE_VALF +# endif + +/* IEEE Not A Number. */ +# if __GNUC_PREREQ (3, 3) +# define NAN (__builtin_nanf ("")) +# else +/* This will raise an "invalid" exception outside static initializers, + but is the best that can be done in ISO C while remaining a + constant expression. */ +# define NAN (0.0f / 0.0f) +# endif +#endif /* __USE_ISOC99 */ + +#if __GLIBC_USE (IEC_60559_BFP_EXT) +/* Signaling NaN macros, if supported. */ +# if __GNUC_PREREQ (3, 3) +# define SNANF (__builtin_nansf ("")) +# define SNAN (__builtin_nans ("")) +# define SNANL (__builtin_nansl ("")) +# endif +#endif +#if (__HAVE_FLOAT16 \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF16 (__builtin_nansf16 ("")) +#endif +#if (__HAVE_FLOAT32 \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF32 (__builtin_nansf32 ("")) +#endif +#if (__HAVE_FLOAT64 \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF64 (__builtin_nansf64 ("")) +#endif +#if (__HAVE_FLOAT128 \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF128 (__builtin_nansf128 ("")) +#endif +#if (__HAVE_FLOAT32X \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF32X (__builtin_nansf32x ("")) +#endif +#if (__HAVE_FLOAT64X \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF64X (__builtin_nansf64x ("")) +#endif +#if (__HAVE_FLOAT128X \ + && __GLIBC_USE (IEC_60559_TYPES_EXT) \ + && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) +# define SNANF128X (__builtin_nansf128x ("")) +#endif + +/* Get __GLIBC_FLT_EVAL_METHOD. */ +#include + +#ifdef __USE_ISOC99 +/* Define the following typedefs. + + float_t floating-point type at least as wide as `float' used + to evaluate `float' expressions + double_t floating-point type at least as wide as `double' used + to evaluate `double' expressions +*/ +# if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16 +typedef float float_t; +typedef double double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 1 +typedef double float_t; +typedef double double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 2 +typedef long double float_t; +typedef long double double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 32 +typedef _Float32 float_t; +typedef double double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 33 +typedef _Float32x float_t; +typedef _Float32x double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 64 +typedef _Float64 float_t; +typedef _Float64 double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 65 +typedef _Float64x float_t; +typedef _Float64x double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 128 +typedef _Float128 float_t; +typedef _Float128 double_t; +# elif __GLIBC_FLT_EVAL_METHOD == 129 +typedef _Float128x float_t; +typedef _Float128x double_t; +# else +# error "Unknown __GLIBC_FLT_EVAL_METHOD" +# endif +#endif + +/* Define macros for the return values of ilogb and llogb, based on + __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. + + FP_ILOGB0 Expands to a value returned by `ilogb (0.0)'. + FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'. + FP_LLOGB0 Expands to a value returned by `llogb (0.0)'. + FP_LLOGBNAN Expands to a value returned by `llogb (NAN)'. + +*/ + +#include +#ifdef __USE_ISOC99 +# if __FP_LOGB0_IS_MIN +# define FP_ILOGB0 (-2147483647 - 1) +# else +# define FP_ILOGB0 (-2147483647) +# endif +# if __FP_LOGBNAN_IS_MIN +# define FP_ILOGBNAN (-2147483647 - 1) +# else +# define FP_ILOGBNAN 2147483647 +# endif +#endif +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +# if __WORDSIZE == 32 +# define __FP_LONG_MAX 0x7fffffffL +# else +# define __FP_LONG_MAX 0x7fffffffffffffffL +# endif +# if __FP_LOGB0_IS_MIN +# define FP_LLOGB0 (-__FP_LONG_MAX - 1) +# else +# define FP_LLOGB0 (-__FP_LONG_MAX) +# endif +# if __FP_LOGBNAN_IS_MIN +# define FP_LLOGBNAN (-__FP_LONG_MAX - 1) +# else +# define FP_LLOGBNAN __FP_LONG_MAX +# endif +#endif + +/* Get the architecture specific values describing the floating-point + evaluation. The following symbols will get defined: + + FP_FAST_FMA + FP_FAST_FMAF + FP_FAST_FMAL + If defined it indicates that the `fma' function + generally executes about as fast as a multiply and an add. + This macro is defined only iff the `fma' function is + implemented directly with a hardware multiply-add instructions. +*/ + +#include + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* Rounding direction macros for fromfp functions. */ +enum + { + FP_INT_UPWARD = +# define FP_INT_UPWARD 0 + FP_INT_UPWARD, + FP_INT_DOWNWARD = +# define FP_INT_DOWNWARD 1 + FP_INT_DOWNWARD, + FP_INT_TOWARDZERO = +# define FP_INT_TOWARDZERO 2 + FP_INT_TOWARDZERO, + FP_INT_TONEARESTFROMZERO = +# define FP_INT_TONEARESTFROMZERO 3 + FP_INT_TONEARESTFROMZERO, + FP_INT_TONEAREST = +# define FP_INT_TONEAREST 4 + FP_INT_TONEAREST, + }; +#endif + +/* The file contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', + and can declare the float versions `namef' and `__namef'. */ + +#define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function) + +#define __MATHCALL_VEC(function, suffix, args) \ + __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ + __MATHCALL (function, suffix, args) + +#define __MATHDECL_VEC(type, function,suffix, args) \ + __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ + __MATHDECL(type, function,suffix, args) + +#define __MATHCALL(function,suffix, args) \ + __MATHDECL (_Mdouble_,function,suffix, args) +#define __MATHDECL(type, function,suffix, args) \ + __MATHDECL_1(type, function,suffix, args); \ + __MATHDECL_1(type, __CONCAT(__,function),suffix, args) +#define __MATHCALLX(function,suffix, args, attrib) \ + __MATHDECLX (_Mdouble_,function,suffix, args, attrib) +#define __MATHDECLX(type, function,suffix, args, attrib) \ + __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \ + __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib) +#define __MATHDECL_1_IMPL(type, function, suffix, args) \ + extern type __MATH_PRECNAME(function,suffix) args __THROW +#define __MATHDECL_1(type, function, suffix, args) \ + __MATHDECL_1_IMPL(type, function, suffix, args) +/* Ignore the alias by default. The alias is only useful with + redirections. */ +#define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHDECL_1(type, function, suffix, args) + +#define __MATHREDIR(type, function, suffix, args, to) \ + extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to) + +#define _Mdouble_ double +#define __MATH_PRECNAME(name,r) __CONCAT(name,r) +#define __MATH_DECLARING_DOUBLE 1 +#define __MATH_DECLARING_FLOATN 0 +#include +#include +#undef _Mdouble_ +#undef __MATH_PRECNAME +#undef __MATH_DECLARING_DOUBLE +#undef __MATH_DECLARING_FLOATN + +#ifdef __USE_ISOC99 + + +/* Include the file of declarations again, this time using `float' + instead of `double' and appending f to each function name. */ + +# define _Mdouble_ float +# define __MATH_PRECNAME(name,r) name##f##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 0 +# include +# include +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN + +# if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \ + || defined __LDBL_COMPAT \ + || defined _LIBC_TEST +# ifdef __LDBL_COMPAT + +# ifdef __USE_ISOC99 +extern float __nldbl_nexttowardf (float __x, long double __y) + __THROW __attribute__ ((__const__)); +# ifdef __REDIRECT_NTH +extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), + __nldbl_nexttowardf) + __attribute__ ((__const__)); +extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), + nextafter) __attribute__ ((__const__)); +extern long double __REDIRECT_NTH (nexttowardl, + (long double __x, long double __y), + nextafter) __attribute__ ((__const__)); +# endif +# endif + +# undef __MATHDECL_1 +# define __MATHDECL_1(type, function,suffix, args) \ + __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix)) + +# elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# ifdef __REDIRECT_NTH +# ifdef __USE_ISOC99 +extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), + __nexttowardf_to_ieee128) + __attribute__ ((__const__)); +extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), + __nexttoward_to_ieee128) + __attribute__ ((__const__)); + +#define __dremieee128 __remainderieee128 +#define __gammaieee128 __lgammaieee128 + +# endif +# endif + +# undef __MATHDECL_1 +# undef __MATHDECL_ALIAS + +# define __REDIRTO(function, suffix) \ + __ ## function ## ieee128 ## suffix +# define __REDIRTO_ALT(function, suffix) \ + __ ## function ## f128 ## suffix + +# define __MATHDECL_1(type, function, suffix, args) \ + __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix)) +# define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix)) +# endif + +/* Include the file of declarations again, this time using `long double' + instead of `double' and appending l to each function name. */ + +# define _Mdouble_ long double +# define __MATH_PRECNAME(name,r) name##l##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 0 +# define __MATH_DECLARE_LDOUBLE 1 +# include +# include + +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN + +# if defined __LDBL_COMPAT \ + || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# undef __REDIRTO +# undef __REDIRTO_ALT +# undef __MATHDECL_1 +# undef __MATHDECL_ALIAS +# define __MATHDECL_1(type, function, suffix, args) \ + __MATHDECL_1_IMPL(type, function, suffix, args) +# define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHDECL_1(type, function, suffix, args) +# endif +# endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */ + +#endif /* Use ISO C99. */ + +/* Include the file of declarations for _FloatN and _FloatNx + types. */ + +#if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC) +# define _Mdouble_ _Float16 +# define __MATH_PRECNAME(name,r) name##f16##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT16 +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC) +# define _Mdouble_ _Float32 +# define __MATH_PRECNAME(name,r) name##f32##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT32 +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC) +# define _Mdouble_ _Float64 +# define __MATH_PRECNAME(name,r) name##f64##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT64 +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC) +# define _Mdouble_ _Float128 +# define __MATH_PRECNAME(name,r) name##f128##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT128 +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC) +# define _Mdouble_ _Float32x +# define __MATH_PRECNAME(name,r) name##f32x##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT32X +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC) +# define _Mdouble_ _Float64x +# define __MATH_PRECNAME(name,r) name##f64x##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT64X +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC). */ + +#if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC) +# define _Mdouble_ _Float128x +# define __MATH_PRECNAME(name,r) name##f128x##r +# define __MATH_DECLARING_DOUBLE 0 +# define __MATH_DECLARING_FLOATN 1 +# if __HAVE_DISTINCT_FLOAT128X +# include +# endif +# if __GLIBC_USE (IEC_60559_TYPES_EXT) +# include +# endif +# undef _Mdouble_ +# undef __MATH_PRECNAME +# undef __MATH_DECLARING_DOUBLE +# undef __MATH_DECLARING_FLOATN +#endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC). */ + +#undef __MATHDECL_1_IMPL +#undef __MATHDECL_1 +#undef __MATHDECL_ALIAS +#undef __MATHDECL +#undef __MATHCALL + +/* Declare functions returning a narrower type. */ +#define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x) +#define __MATHCALL_NARROW_ARGS_2 (_Marg_ __x, _Marg_ __y) +#define __MATHCALL_NARROW_ARGS_3 (_Marg_ __x, _Marg_ __y, _Marg_ __z) +#define __MATHCALL_NARROW_NORMAL(func, nargs) \ + extern _Mret_ func __MATHCALL_NARROW_ARGS_ ## nargs __THROW +#define __MATHCALL_NARROW_REDIR(func, redir, nargs) \ + extern _Mret_ __REDIRECT_NTH (func, __MATHCALL_NARROW_ARGS_ ## nargs, \ + redir) +#define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_NORMAL (func, nargs) + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) + +# define _Mret_ float +# define _Marg_ double +# define __MATHCALL_NAME(name) f ## name +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME + +# define _Mret_ float +# define _Marg_ long double +# define __MATHCALL_NAME(name) f ## name ## l +# ifdef __LDBL_COMPAT +# define __MATHCALL_REDIR_NAME(name) f ## name +# define __MATHCALL_REDIR_NAME2(name) f ## name +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128 +# define __MATHCALL_REDIR_NAME2(name) __ ## f32 ## name ## ieee128 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# endif +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# if defined __LDBL_COMPAT \ + || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# undef __MATHCALL_REDIR_NAME +# undef __MATHCALL_REDIR_NAME2 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_NORMAL (func, nargs) +# endif + +# define _Mret_ double +# define _Marg_ long double +# define __MATHCALL_NAME(name) d ## name ## l +# ifdef __LDBL_COMPAT +# define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l +# define __MATHCALL_REDIR_NAME2(name) name +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128 +# define __MATHCALL_REDIR_NAME2(name) __ ## f64 ## name ## ieee128 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# endif +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# if defined __LDBL_COMPAT \ + || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# undef __MATHCALL_REDIR_NAME +# undef __MATHCALL_REDIR_NAME2 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_NORMAL (func, nargs) +# endif + +#endif + +#if __GLIBC_USE (IEC_60559_TYPES_EXT) + +# if __HAVE_FLOAT16 && __HAVE_FLOAT32 +# define _Mret_ _Float16 +# define _Marg_ _Float32 +# define __MATHCALL_NAME(name) f16 ## name ## f32 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT16 && __HAVE_FLOAT32X +# define _Mret_ _Float16 +# define _Marg_ _Float32x +# define __MATHCALL_NAME(name) f16 ## name ## f32x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT16 && __HAVE_FLOAT64 +# define _Mret_ _Float16 +# define _Marg_ _Float64 +# define __MATHCALL_NAME(name) f16 ## name ## f64 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT16 && __HAVE_FLOAT64X +# define _Mret_ _Float16 +# define _Marg_ _Float64x +# define __MATHCALL_NAME(name) f16 ## name ## f64x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT16 && __HAVE_FLOAT128 +# define _Mret_ _Float16 +# define _Marg_ _Float128 +# define __MATHCALL_NAME(name) f16 ## name ## f128 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT16 && __HAVE_FLOAT128X +# define _Mret_ _Float16 +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f16 ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32 && __HAVE_FLOAT32X +# define _Mret_ _Float32 +# define _Marg_ _Float32x +# define __MATHCALL_NAME(name) f32 ## name ## f32x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32 && __HAVE_FLOAT64 +# define _Mret_ _Float32 +# define _Marg_ _Float64 +# define __MATHCALL_NAME(name) f32 ## name ## f64 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32 && __HAVE_FLOAT64X +# define _Mret_ _Float32 +# define _Marg_ _Float64x +# define __MATHCALL_NAME(name) f32 ## name ## f64x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32 && __HAVE_FLOAT128 +# define _Mret_ _Float32 +# define _Marg_ _Float128 +# define __MATHCALL_NAME(name) f32 ## name ## f128 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32 && __HAVE_FLOAT128X +# define _Mret_ _Float32 +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f32 ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32X && __HAVE_FLOAT64 +# define _Mret_ _Float32x +# define _Marg_ _Float64 +# define __MATHCALL_NAME(name) f32x ## name ## f64 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32X && __HAVE_FLOAT64X +# define _Mret_ _Float32x +# define _Marg_ _Float64x +# define __MATHCALL_NAME(name) f32x ## name ## f64x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32X && __HAVE_FLOAT128 +# define _Mret_ _Float32x +# define _Marg_ _Float128 +# define __MATHCALL_NAME(name) f32x ## name ## f128 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT32X && __HAVE_FLOAT128X +# define _Mret_ _Float32x +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f32x ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT64 && __HAVE_FLOAT64X +# define _Mret_ _Float64 +# define _Marg_ _Float64x +# define __MATHCALL_NAME(name) f64 ## name ## f64x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT64 && __HAVE_FLOAT128 +# define _Mret_ _Float64 +# define _Marg_ _Float128 +# define __MATHCALL_NAME(name) f64 ## name ## f128 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT64 && __HAVE_FLOAT128X +# define _Mret_ _Float64 +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f64 ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT64X && __HAVE_FLOAT128 +# define _Mret_ _Float64x +# define _Marg_ _Float128 +# define __MATHCALL_NAME(name) f64x ## name ## f128 +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT64X && __HAVE_FLOAT128X +# define _Mret_ _Float64x +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f64x ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +# if __HAVE_FLOAT128 && __HAVE_FLOAT128X +# define _Mret_ _Float128 +# define _Marg_ _Float128x +# define __MATHCALL_NAME(name) f128 ## name ## f128x +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# endif + +#endif + +#undef __MATHCALL_NARROW_ARGS_1 +#undef __MATHCALL_NARROW_ARGS_2 +#undef __MATHCALL_NARROW_ARGS_3 +#undef __MATHCALL_NARROW_NORMAL +#undef __MATHCALL_NARROW_REDIR +#undef __MATHCALL_NARROW + +#if defined __USE_MISC || defined __USE_XOPEN +/* This variable is used by `gamma' and `lgamma'. */ +extern int signgam; +#endif + +#if (__HAVE_DISTINCT_FLOAT16 \ + || __HAVE_DISTINCT_FLOAT32 \ + || __HAVE_DISTINCT_FLOAT64 \ + || __HAVE_DISTINCT_FLOAT32X \ + || __HAVE_DISTINCT_FLOAT64X \ + || __HAVE_DISTINCT_FLOAT128X) +# error "Unsupported _FloatN or _FloatNx types for ." +#endif + +/* Depending on the type of TG_ARG, call an appropriately suffixed + version of FUNC with arguments (including parentheses) ARGS. + Suffixed functions may not exist for long double if it has the same + format as double, or for other types with the same format as float, + double or long double. The behavior is undefined if the argument + does not have a real floating type. The definition may use a + conditional expression, so all suffixed versions of FUNC must + return the same type (FUNC may include a cast if necessary rather + than being a single identifier). */ +#ifdef __NO_LONG_DOUBLE_MATH +# if __HAVE_DISTINCT_FLOAT128 +# error "Distinct _Float128 without distinct long double not supported." +# endif +# define __MATH_TG(TG_ARG, FUNC, ARGS) \ + (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS) +#elif __HAVE_DISTINCT_FLOAT128 +# if __HAVE_GENERIC_SELECTION +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32 +# define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS, +# else +# define __MATH_TG_F32(FUNC, ARGS) +# endif +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X +# if __HAVE_FLOAT64X_LONG_DOUBLE +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS, +# else +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS, +# endif +# else +# define __MATH_TG_F64X(FUNC, ARGS) +# endif +# define __MATH_TG(TG_ARG, FUNC, ARGS) \ + _Generic ((TG_ARG), \ + float: FUNC ## f ARGS, \ + __MATH_TG_F32 (FUNC, ARGS) \ + default: FUNC ARGS, \ + long double: FUNC ## l ARGS, \ + __MATH_TG_F64X (FUNC, ARGS) \ + _Float128: FUNC ## f128 ARGS) +# else +# if __HAVE_FLOATN_NOT_TYPEDEF +# error "Non-typedef _FloatN but no _Generic." +# endif +# define __MATH_TG(TG_ARG, FUNC, ARGS) \ + __builtin_choose_expr \ + (__builtin_types_compatible_p (__typeof (TG_ARG), float), \ + FUNC ## f ARGS, \ + __builtin_choose_expr \ + (__builtin_types_compatible_p (__typeof (TG_ARG), double), \ + FUNC ARGS, \ + __builtin_choose_expr \ + (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \ + FUNC ## l ARGS, \ + FUNC ## f128 ARGS))) +# endif +#else +# define __MATH_TG(TG_ARG, FUNC, ARGS) \ + (sizeof (TG_ARG) == sizeof (float) \ + ? FUNC ## f ARGS \ + : sizeof (TG_ARG) == sizeof (double) \ + ? FUNC ARGS \ + : FUNC ## l ARGS) +#endif + +/* ISO C99 defines some generic macros which work on any data type. */ +#ifdef __USE_ISOC99 + +/* All floating-point numbers can be put in one of these categories. */ +enum + { + FP_NAN = +# define FP_NAN 0 + FP_NAN, + FP_INFINITE = +# define FP_INFINITE 1 + FP_INFINITE, + FP_ZERO = +# define FP_ZERO 2 + FP_ZERO, + FP_SUBNORMAL = +# define FP_SUBNORMAL 3 + FP_SUBNORMAL, + FP_NORMAL = +# define FP_NORMAL 4 + FP_NORMAL + }; + +/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan, + so disable builtins if this is enabled. When fixed in a newer GCC, + the __SUPPORT_SNAN__ check may be skipped for those versions. */ + +/* Return number of classification appropriate for X. */ +# if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8)) \ + && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus) + /* The check for __cplusplus allows the use of the builtin, even + when optimization for size is on. This is provided for + libstdc++, only to let its configure test work when it is built + with -Os. No further use of this definition of fpclassify is + expected in C++ mode, since libstdc++ provides its own version + of fpclassify in cmath (which undefines fpclassify). */ +# define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \ + FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) +# else +# define fpclassify(x) __MATH_TG ((x), __fpclassify, (x)) +# endif + +/* Return nonzero value if sign of X is negative. */ +# if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3) +# define signbit(x) __builtin_signbit (x) +# elif defined __cplusplus + /* In C++ mode, __MATH_TG cannot be used, because it relies on + __builtin_types_compatible_p, which is a C-only builtin. + The check for __cplusplus allows the use of the builtin instead of + __MATH_TG. This is provided for libstdc++, only to let its configure + test work. No further use of this definition of signbit is expected + in C++ mode, since libstdc++ provides its own version of signbit + in cmath (which undefines signbit). */ +# define signbit(x) __builtin_signbitl (x) +# elif __GNUC_PREREQ (4,0) +# define signbit(x) __MATH_TG ((x), __builtin_signbit, (x)) +# else +# define signbit(x) __MATH_TG ((x), __signbit, (x)) +# endif + +/* Return nonzero value if X is not +-Inf or NaN. */ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) +# define isfinite(x) __builtin_isfinite (x) +# else +# define isfinite(x) __MATH_TG ((x), __finite, (x)) +# endif + +/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) +# define isnormal(x) __builtin_isnormal (x) +# else +# define isnormal(x) (fpclassify (x) == FP_NORMAL) +# endif + +/* Return nonzero value if X is a NaN. We could use `fpclassify' but + we already have this functions `__isnan' and it is faster. */ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (2,8) +# define isnan(x) __builtin_isnan (x) +# else +# define isnan(x) __MATH_TG ((x), __isnan, (x)) +# endif + +/* Return nonzero value if X is positive or negative infinity. */ +# if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \ + && !defined __SUPPORT_SNAN__ && !defined __cplusplus + /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0, + use the helper function, __isinff128, with older compilers. This is + only provided for C mode, because in C++ mode, GCC has no support + for __builtin_types_compatible_p (and when in C++ mode, this macro is + not used anyway, because libstdc++ headers undefine it). */ +# define isinf(x) \ + (__builtin_types_compatible_p (__typeof (x), _Float128) \ + ? __isinff128 (x) : __builtin_isinf_sign (x)) +# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (3,7) +# define isinf(x) __builtin_isinf_sign (x) +# else +# define isinf(x) __MATH_TG ((x), __isinf, (x)) +# endif + +/* Bitmasks for the math_errhandling macro. */ +# define MATH_ERRNO 1 /* errno set by math functions. */ +# define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ + +/* By default all math functions support both errno and exception handling + (except for soft floating point implementations which may only support + errno handling). If errno handling is disabled, exceptions are still + supported by GLIBC. Set math_errhandling to 0 with -ffast-math (this is + nonconforming but it is more useful than leaving it undefined). */ +# ifdef __FAST_MATH__ +# define math_errhandling 0 +# elif defined __NO_MATH_ERRNO__ +# define math_errhandling (MATH_ERREXCEPT) +# else +# define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT) +# endif + +#endif /* Use ISO C99. */ + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +# include + +/* Return nonzero value if X is a signaling NaN. */ +# ifndef __cplusplus +# define issignaling(x) __MATH_TG ((x), __issignaling, (x)) +# else + /* In C++ mode, __MATH_TG cannot be used, because it relies on + __builtin_types_compatible_p, which is a C-only builtin. On the + other hand, overloading provides the means to distinguish between + the floating-point types. The overloading resolution will match + the correct parameter (regardless of type qualifiers (i.e.: const + and volatile)). */ +extern "C++" { +inline int issignaling (float __val) { return __issignalingf (__val); } +inline int issignaling (double __val) { return __issignaling (__val); } +inline int +issignaling (long double __val) +{ +# ifdef __NO_LONG_DOUBLE_MATH + return __issignaling (__val); +# else + return __issignalingl (__val); +# endif +} +# if __HAVE_FLOAT128_UNLIKE_LDBL +/* When using an IEEE 128-bit long double, _Float128 is defined as long double + in C++. */ +inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } +# endif +} /* extern C++ */ +# endif + +/* Return nonzero value if X is subnormal. */ +# define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) + +/* Return nonzero value if X is zero. */ +# ifndef __cplusplus +# ifdef __SUPPORT_SNAN__ +# define iszero(x) (fpclassify (x) == FP_ZERO) +# else +# define iszero(x) (((__typeof (x)) (x)) == 0) +# endif +# else /* __cplusplus */ +extern "C++" { +# ifdef __SUPPORT_SNAN__ +inline int +iszero (float __val) +{ + return __fpclassifyf (__val) == FP_ZERO; +} +inline int +iszero (double __val) +{ + return __fpclassify (__val) == FP_ZERO; +} +inline int +iszero (long double __val) +{ +# ifdef __NO_LONG_DOUBLE_MATH + return __fpclassify (__val) == FP_ZERO; +# else + return __fpclassifyl (__val) == FP_ZERO; +# endif +} +# if __HAVE_FLOAT128_UNLIKE_LDBL + /* When using an IEEE 128-bit long double, _Float128 is defined as long double + in C++. */ +inline int +iszero (_Float128 __val) +{ + return __fpclassifyf128 (__val) == FP_ZERO; +} +# endif +# else +template inline bool +iszero (__T __val) +{ + return __val == 0; +} +# endif +} /* extern C++ */ +# endif /* __cplusplus */ +#endif /* Use IEC_60559_BFP_EXT. */ + +#ifdef __USE_XOPEN +/* X/Open wants another strange constant. */ +# define MAXFLOAT 3.40282347e+38F +#endif + + +/* Some useful constants. */ +#if defined __USE_MISC || defined __USE_XOPEN +# define M_E 2.7182818284590452354 /* e */ +# define M_LOG2E 1.4426950408889634074 /* log_2 e */ +# define M_LOG10E 0.43429448190325182765 /* log_10 e */ +# define M_LN2 0.69314718055994530942 /* log_e 2 */ +# define M_LN10 2.30258509299404568402 /* log_e 10 */ +# define M_PI 3.14159265358979323846 /* pi */ +# define M_PI_2 1.57079632679489661923 /* pi/2 */ +# define M_PI_4 0.78539816339744830962 /* pi/4 */ +# define M_1_PI 0.31830988618379067154 /* 1/pi */ +# define M_2_PI 0.63661977236758134308 /* 2/pi */ +# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif + +/* GNU extension to provide float constants with similar names. */ +#ifdef __USE_GNU +# define M_Ef 2.7182818284590452354f /* e */ +# define M_LOG2Ef 1.4426950408889634074f /* log_2 e */ +# define M_LOG10Ef 0.43429448190325182765f /* log_10 e */ +# define M_LN2f 0.69314718055994530942f /* log_e 2 */ +# define M_LN10f 2.30258509299404568402f /* log_e 10 */ +# define M_PIf 3.14159265358979323846f /* pi */ +# define M_PI_2f 1.57079632679489661923f /* pi/2 */ +# define M_PI_4f 0.78539816339744830962f /* pi/4 */ +# define M_1_PIf 0.31830988618379067154f /* 1/pi */ +# define M_2_PIf 0.63661977236758134308f /* 2/pi */ +# define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(pi) */ +# define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */ +# define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */ +#endif + +/* The above constants are not adequate for computation using `long double's. + Therefore we provide as an extension constants with similar names as a + GNU extension. Provide enough digits for the 128-bit IEEE quad. */ +#ifdef __USE_GNU +# define M_El 2.718281828459045235360287471352662498L /* e */ +# define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */ +# define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */ +# define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */ +# define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */ +# define M_PIl 3.141592653589793238462643383279502884L /* pi */ +# define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */ +# define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */ +# define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */ +# define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */ +# define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */ +# define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */ +# define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT16 && defined __USE_GNU +# define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT32 && defined __USE_GNU +# define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT64 && defined __USE_GNU +# define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT128 && defined __USE_GNU +# define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef128 __f128 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f128 __f128 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f128 __f128 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf128 __f128 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f128 __f128 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f128 __f128 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf128 __f128 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf128 __f128 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf128 __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f128 __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT32X && defined __USE_GNU +# define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT64X && defined __USE_GNU +# define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT128X && defined __USE_GNU +# error "M_* values needed for _Float128x" +#endif + +#ifdef __USE_ISOC99 +# if __GNUC_PREREQ (3, 1) +/* ISO C99 defines some macros to compare number while taking care for + unordered numbers. Many FPUs provide special instructions to support + these operations. Generic support in GCC for these as builtins went + in 2.97, but not all cpus added their patterns until 3.1. Therefore + we enable the builtins from 3.1 onwards and use a generic implementation + othwerwise. */ +# define isgreater(x, y) __builtin_isgreater(x, y) +# define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) +# define isless(x, y) __builtin_isless(x, y) +# define islessequal(x, y) __builtin_islessequal(x, y) +# define islessgreater(x, y) __builtin_islessgreater(x, y) +# define isunordered(x, y) __builtin_isunordered(x, y) +# else +# define isgreater(x, y) \ + (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ + !isunordered (__x, __y) && __x > __y; })) +# define isgreaterequal(x, y) \ + (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ + !isunordered (__x, __y) && __x >= __y; })) +# define isless(x, y) \ + (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ + !isunordered (__x, __y) && __x < __y; })) +# define islessequal(x, y) \ + (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ + !isunordered (__x, __y) && __x <= __y; })) +# define islessgreater(x, y) \ + (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ + !isunordered (__x, __y) && __x != __y; })) +/* isunordered must always check both operands first for signaling NaNs. */ +# define isunordered(x, y) \ + (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \ + __u != __v && (__u != __u || __v != __v); })) +# endif +#endif + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +/* An expression whose type has the widest of the evaluation formats + of X and Y (which are of floating-point types). */ +# if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64 +# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L) +# elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32 +# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0) +# elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32 +# define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f) +# else +# define __MATH_EVAL_FMT2(x, y) ((x) + (y)) +# endif + +/* Return X == Y but raising "invalid" and setting errno if X or Y is + a NaN. */ +# if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__) +# define iseqsig(x, y) \ + __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y))) +# else +/* In C++ mode, __MATH_TG cannot be used, because it relies on + __builtin_types_compatible_p, which is a C-only builtin. Moreover, + the comparison macros from ISO C take two floating-point arguments, + which need not have the same type. Choosing what underlying function + to call requires evaluating the formats of the arguments, then + selecting which is wider. The macro __MATH_EVAL_FMT2 provides this + information, however, only the type of the macro expansion is + relevant (actually evaluating the expression would be incorrect). + Thus, the type is used as a template parameter for __iseqsig_type, + which calls the appropriate underlying function. */ +extern "C++" { +template struct __iseqsig_type; + +template<> struct __iseqsig_type +{ + static int __call (float __x, float __y) throw () + { + return __iseqsigf (__x, __y); + } +}; + +template<> struct __iseqsig_type +{ + static int __call (double __x, double __y) throw () + { + return __iseqsig (__x, __y); + } +}; + +template<> struct __iseqsig_type +{ + static int __call (long double __x, long double __y) throw () + { +# ifndef __NO_LONG_DOUBLE_MATH + return __iseqsigl (__x, __y); +# else + return __iseqsig (__x, __y); +# endif + } +}; + +# if __HAVE_FLOAT128_UNLIKE_LDBL + /* When using an IEEE 128-bit long double, _Float128 is defined as long double + in C++. */ +template<> struct __iseqsig_type<_Float128> +{ + static int __call (_Float128 __x, _Float128 __y) throw () + { + return __iseqsigf128 (__x, __y); + } +}; +# endif + +template +inline int +iseqsig (_T1 __x, _T2 __y) throw () +{ +# if __cplusplus >= 201103L + typedef decltype (__MATH_EVAL_FMT2 (__x, __y)) _T3; +# else + typedef __typeof (__MATH_EVAL_FMT2 (__x, __y)) _T3; +# endif + return __iseqsig_type<_T3>::__call (__x, __y); +} + +} /* extern "C++" */ +# endif /* __cplusplus */ + +#endif + +__END_DECLS + + +#endif /* math.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1e9920794ae199ef987b07ca73197b9f08fd5d7c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@math.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h new file mode 100644 index 0000000000000000000000000000000000000000..dedad4ec86a6fda3aa8c31447ad2dd9994a5ccf0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h @@ -0,0 +1,1348 @@ +/* Copyright (C) 2002-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _PTHREAD_H +#define _PTHREAD_H 1 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef __USE_MISC +# include +#endif + +/* Detach state. */ +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + + +/* Mutex types. */ +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 + , + 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 +#endif +#ifdef __USE_GNU + /* For compatibility. */ + , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP +#endif +}; + + +#ifdef __USE_XOPEN2K +/* Robust mutex or not flags. */ +enum +{ + PTHREAD_MUTEX_STALLED, + PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, + PTHREAD_MUTEX_ROBUST, + PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST +}; +#endif + + +#if defined __USE_POSIX199506 || defined __USE_UNIX98 +/* Mutex protocols. */ +enum +{ + PTHREAD_PRIO_NONE, + PTHREAD_PRIO_INHERIT, + PTHREAD_PRIO_PROTECT +}; +#endif + + +#define PTHREAD_MUTEX_INITIALIZER \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_TIMED_NP) } } +#ifdef __USE_GNU +# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } } +# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } } +# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } } +#endif + + +/* Read-write lock types. */ +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +enum +{ + PTHREAD_RWLOCK_PREFER_READER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, + PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP +}; + + +/* Read-write lock initializers. */ +# define PTHREAD_RWLOCK_INITIALIZER \ + { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_DEFAULT_NP) } } +# ifdef __USE_GNU +# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ + { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) } } +# endif +#endif /* Unix98 or XOpen2K */ + + +/* Scheduler inheritance. */ +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + + +/* Scope handling. */ +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + + +/* Process shared or private flag. */ +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + + + +/* Conditional variable handling. */ +#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } } + + +/* Cleanup buffers */ +struct _pthread_cleanup_buffer +{ + void (*__routine) (void *); /* Function to call. */ + void *__arg; /* Its argument. */ + int __canceltype; /* Saved cancellation type. */ + struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */ +}; + +/* Cancellation */ +enum +{ + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; +enum +{ + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS +}; +#define PTHREAD_CANCELED ((void *) -1) + + +/* Single execution handling. */ +#define PTHREAD_ONCE_INIT 0 + + +#ifdef __USE_XOPEN2K +/* Value returned by 'pthread_barrier_wait' for one of the threads after + the required number of threads have called this function. + -1 is distinct from 0 and all errno constants */ +# define PTHREAD_BARRIER_SERIAL_THREAD -1 +#endif + + +__BEGIN_DECLS + +/* Create a new thread, starting with execution of START-ROUTINE + getting passed ARG. Creation attributed come from ATTR. The new + handle is stored in *NEWTHREAD. */ +extern int pthread_create (pthread_t *__restrict __newthread, + const pthread_attr_t *__restrict __attr, + void *(*__start_routine) (void *), + void *__restrict __arg) __THROWNL __nonnull ((1, 3)); + +/* Terminate calling thread. + + The registered cleanup handlers are called via exception handling + so we cannot mark this function with __THROW.*/ +extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); + +/* Make calling thread wait for termination of the thread TH. The + exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN + is not NULL. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_join (pthread_t __th, void **__thread_return); + +#ifdef __USE_GNU +/* Check whether thread TH has terminated. If yes return the status of + the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */ +extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW; + +# ifndef __USE_TIME_BITS64 +/* Make calling thread wait for termination of the thread TH, but only + until TIMEOUT. The exit status of the thread is stored in + *THREAD_RETURN, if THREAD_RETURN is not NULL. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, + const struct timespec *__abstime); + +/* Make calling thread wait for termination of the thread TH, but only + until TIMEOUT measured against the clock specified by CLOCKID. The + exit status of the thread is stored in *THREAD_RETURN, if + THREAD_RETURN is not NULL. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return, + clockid_t __clockid, + const struct timespec *__abstime); +# else +# ifdef __REDIRECT +extern int __REDIRECT (pthread_timedjoin_np, + (pthread_t __th, void **__thread_return, + const struct timespec *__abstime), + __pthread_timedjoin_np64); + +extern int __REDIRECT (pthread_clockjoin_np, + (pthread_t __th, void **__thread_return, + clockid_t __clockid, + const struct timespec *__abstime), + __pthread_clockjoin_np64); +# else +# define pthread_timedjoin_np __pthread_timedjoin_np64 +# define pthread_clockjoin_np __pthread_clockjoin_np64 +# endif +# endif +#endif + +/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN. + The resources of TH will therefore be freed immediately when it + terminates, instead of waiting for another thread to perform PTHREAD_JOIN + on it. */ +extern int pthread_detach (pthread_t __th) __THROW; + + +/* Obtain the identifier of the current thread. */ +extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__)); + +/* Compare two thread identifiers. */ +extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) + __THROW __attribute__ ((__const__)); + + +/* Thread attribute handling. */ + +/* Initialize thread attribute *ATTR with default attributes + (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER, + no user-provided stack). */ +extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1)); + +/* Destroy thread attribute *ATTR. */ +extern int pthread_attr_destroy (pthread_attr_t *__attr) + __THROW __nonnull ((1)); + +/* Get detach state attribute. */ +extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, + int *__detachstate) + __THROW __nonnull ((1, 2)); + +/* Set detach state attribute. */ +extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, + int __detachstate) + __THROW __nonnull ((1)); + + +/* Get the size of the guard area created for stack overflow protection. */ +extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, + size_t *__guardsize) + __THROW __nonnull ((1, 2)); + +/* Set the size of the guard area created for stack overflow protection. */ +extern int pthread_attr_setguardsize (pthread_attr_t *__attr, + size_t __guardsize) + __THROW __nonnull ((1)); + + +/* Return in *PARAM the scheduling parameters of *ATTR. */ +extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, + struct sched_param *__restrict __param) + __THROW __nonnull ((1, 2)); + +/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */ +extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, + const struct sched_param *__restrict + __param) __THROW __nonnull ((1, 2)); + +/* Return in *POLICY the scheduling policy of *ATTR. */ +extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict + __attr, int *__restrict __policy) + __THROW __nonnull ((1, 2)); + +/* Set scheduling policy in *ATTR according to POLICY. */ +extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) + __THROW __nonnull ((1)); + +/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */ +extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict + __attr, int *__restrict __inherit) + __THROW __nonnull ((1, 2)); + +/* Set scheduling inheritance mode in *ATTR according to INHERIT. */ +extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, + int __inherit) + __THROW __nonnull ((1)); + + +/* Return in *SCOPE the scheduling contention scope of *ATTR. */ +extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, + int *__restrict __scope) + __THROW __nonnull ((1, 2)); + +/* Set scheduling contention scope in *ATTR according to SCOPE. */ +extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) + __THROW __nonnull ((1)); + +/* Return the previously set address for the stack. */ +extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict + __attr, void **__restrict __stackaddr) + __THROW __nonnull ((1, 2)) __attribute_deprecated__; + +/* Set the starting address of the stack of the thread to be created. + Depending on whether the stack grows up or down the value must either + be higher or lower than all the address in the memory block. The + minimal size of the block must be PTHREAD_STACK_MIN. */ +extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, + void *__stackaddr) + __THROW __nonnull ((1)) __attribute_deprecated__; + +/* Return the currently used minimal stack size. */ +extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict + __attr, size_t *__restrict __stacksize) + __THROW __nonnull ((1, 2)); + +/* Add information about the minimum stack size needed for the thread + to be started. This size must never be less than PTHREAD_STACK_MIN + and must also not exceed the system limits. */ +extern int pthread_attr_setstacksize (pthread_attr_t *__attr, + size_t __stacksize) + __THROW __nonnull ((1)); + +#ifdef __USE_XOPEN2K +/* Return the previously set address for the stack. */ +extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, + void **__restrict __stackaddr, + size_t *__restrict __stacksize) + __THROW __nonnull ((1, 2, 3)); + +/* The following two interfaces are intended to replace the last two. They + require setting the address as well as the size since only setting the + address will make the implementation on some architectures impossible. */ +extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, + size_t __stacksize) __THROW __nonnull ((1)); +#endif + +#ifdef __USE_GNU +/* Thread created with attribute ATTR will be limited to run only on + the processors represented in CPUSET. */ +extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, + size_t __cpusetsize, + const cpu_set_t *__cpuset) + __THROW __nonnull ((1, 3)); + +/* Get bit set in CPUSET representing the processors threads created with + ATTR can run on. */ +extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr, + size_t __cpusetsize, + cpu_set_t *__cpuset) + __THROW __nonnull ((1, 3)); + +/* Get the default attributes used by pthread_create in this process. */ +extern int pthread_getattr_default_np (pthread_attr_t *__attr) + __THROW __nonnull ((1)); + +/* Store *SIGMASK as the signal mask for the new thread in *ATTR. */ +extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr, + const __sigset_t *sigmask); + +/* Store the signal mask of *ATTR in *SIGMASK. If there is no signal + mask stored, return PTHREAD_ATTR_NOSIGMASK_NP. Return zero on + success. */ +extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr, + __sigset_t *sigmask); + +/* Special return value from pthread_attr_getsigmask_np if the signal + mask has not been set. */ +#define PTHREAD_ATTR_NO_SIGMASK_NP (-1) + +/* Set the default attributes to be used by pthread_create in this + process. */ +extern int pthread_setattr_default_np (const pthread_attr_t *__attr) + __THROW __nonnull ((1)); + +/* Initialize thread attribute *ATTR with attributes corresponding to the + already running thread TH. It shall be called on uninitialized ATTR + and destroyed with pthread_attr_destroy when no longer needed. */ +extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) + __THROW __nonnull ((2)); +#endif + + +/* Functions for scheduling control. */ + +/* Set the scheduling parameters for TARGET_THREAD according to POLICY + and *PARAM. */ +extern int pthread_setschedparam (pthread_t __target_thread, int __policy, + const struct sched_param *__param) + __THROW __nonnull ((3)); + +/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */ +extern int pthread_getschedparam (pthread_t __target_thread, + int *__restrict __policy, + struct sched_param *__restrict __param) + __THROW __nonnull ((2, 3)); + +/* Set the scheduling priority for TARGET_THREAD. */ +extern int pthread_setschedprio (pthread_t __target_thread, int __prio) + __THROW; + + +#ifdef __USE_GNU +/* Get thread name visible in the kernel and its interfaces. */ +extern int pthread_getname_np (pthread_t __target_thread, char *__buf, + size_t __buflen) + __THROW __nonnull ((2)); + +/* Set thread name visible in the kernel and its interfaces. */ +extern int pthread_setname_np (pthread_t __target_thread, const char *__name) + __THROW __nonnull ((2)); +#endif + + +#ifdef __USE_UNIX98 +/* Determine level of concurrency. */ +extern int pthread_getconcurrency (void) __THROW; + +/* Set new concurrency level to LEVEL. */ +extern int pthread_setconcurrency (int __level) __THROW; +#endif + +#ifdef __USE_GNU +extern int pthread_yield (void) __THROW; +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (pthread_yield, (void), sched_yield) + __attribute_deprecated_msg__ ("\ +pthread_yield is deprecated, use sched_yield instead"); +# else +# define pthread_yield sched_yield +# endif + + +/* Limit specified thread TH to run only on the processors represented + in CPUSET. */ +extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, + const cpu_set_t *__cpuset) + __THROW __nonnull ((3)); + +/* Get bit set in CPUSET representing the processors TH can run on. */ +extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, + cpu_set_t *__cpuset) + __THROW __nonnull ((3)); +#endif + + +/* Functions for handling initialization. */ + +/* Guarantee that the initialization function INIT_ROUTINE will be called + only once, even if pthread_once is executed several times with the + same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or + extern variable initialized to PTHREAD_ONCE_INIT. + + The initialization functions might throw exception which is why + this function is not marked with __THROW. */ +extern int pthread_once (pthread_once_t *__once_control, + void (*__init_routine) (void)) __nonnull ((1, 2)); + + +/* Functions for handling cancellation. + + Note that these functions are explicitly not marked to not throw an + exception in C++ code. If cancellation is implemented by unwinding + this is necessary to have the compiler generate the unwind information. */ + +/* Set cancelability state of current thread to STATE, returning old + state in *OLDSTATE if OLDSTATE is not NULL. */ +extern int pthread_setcancelstate (int __state, int *__oldstate); + +/* Set cancellation state of current thread to TYPE, returning the old + type in *OLDTYPE if OLDTYPE is not NULL. */ +extern int pthread_setcanceltype (int __type, int *__oldtype); + +/* Cancel THREAD immediately or at the next possibility. */ +extern int pthread_cancel (pthread_t __th); + +/* Test for pending cancellation for the current thread and terminate + the thread as per pthread_exit(PTHREAD_CANCELED) if it has been + cancelled. */ +extern void pthread_testcancel (void); + + +/* Cancellation handling with integration into exception handling. */ + +struct __cancel_jmp_buf_tag +{ + __jmp_buf __cancel_jmp_buf; + int __mask_was_saved; +}; + +typedef struct +{ + struct __cancel_jmp_buf_tag __cancel_jmp_buf[1]; + void *__pad[4]; +} __pthread_unwind_buf_t __attribute__ ((__aligned__)); + +/* No special attributes by default. */ +#ifndef __cleanup_fct_attribute +# define __cleanup_fct_attribute +#endif + + +/* Structure to hold the cleanup handler information. */ +struct __pthread_cleanup_frame +{ + void (*__cancel_routine) (void *); + void *__cancel_arg; + int __do_it; + int __cancel_type; +}; + +#if defined __GNUC__ && defined __EXCEPTIONS +# ifdef __cplusplus +/* Class to handle cancellation handler invocation. */ +class __pthread_cleanup_class +{ + void (*__cancel_routine) (void *); + void *__cancel_arg; + int __do_it; + int __cancel_type; + + public: + __pthread_cleanup_class (void (*__fct) (void *), void *__arg) + : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } + ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } + void __setdoit (int __newval) { __do_it = __newval; } + void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, + &__cancel_type); } + void __restore () const { pthread_setcanceltype (__cancel_type, 0); } +}; + +/* Install a cleanup handler: ROUTINE will be called with arguments ARG + when the thread is canceled or calls pthread_exit. ROUTINE will also + be called with arguments ARG when the matching pthread_cleanup_pop + is executed with non-zero EXECUTE argument. + + pthread_cleanup_push and pthread_cleanup_pop are macros and must always + be used in matching pairs at the same nesting level of braces. */ +# define pthread_cleanup_push(routine, arg) \ + do { \ + __pthread_cleanup_class __clframe (routine, arg) + +/* Remove a cleanup handler installed by the matching pthread_cleanup_push. + If EXECUTE is non-zero, the handler function is called. */ +# define pthread_cleanup_pop(execute) \ + __clframe.__setdoit (execute); \ + } while (0) + +# ifdef __USE_GNU +/* Install a cleanup handler as pthread_cleanup_push does, but also + saves the current cancellation type and sets it to deferred + cancellation. */ +# define pthread_cleanup_push_defer_np(routine, arg) \ + do { \ + __pthread_cleanup_class __clframe (routine, arg); \ + __clframe.__defer () + +/* Remove a cleanup handler as pthread_cleanup_pop does, but also + restores the cancellation type that was in effect when the matching + pthread_cleanup_push_defer was called. */ +# define pthread_cleanup_pop_restore_np(execute) \ + __clframe.__restore (); \ + __clframe.__setdoit (execute); \ + } while (0) +# endif +# else +/* Function called to call the cleanup handler. As an extern inline + function the compiler is free to decide inlining the change when + needed or fall back on the copy which must exist somewhere + else. */ +__extern_inline void +__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame) +{ + if (__frame->__do_it) + __frame->__cancel_routine (__frame->__cancel_arg); +} + +/* Install a cleanup handler: ROUTINE will be called with arguments ARG + when the thread is canceled or calls pthread_exit. ROUTINE will also + be called with arguments ARG when the matching pthread_cleanup_pop + is executed with non-zero EXECUTE argument. + + pthread_cleanup_push and pthread_cleanup_pop are macros and must always + be used in matching pairs at the same nesting level of braces. */ +# define pthread_cleanup_push(routine, arg) \ + do { \ + struct __pthread_cleanup_frame __clframe \ + __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \ + = { .__cancel_routine = (routine), .__cancel_arg = (arg), \ + .__do_it = 1 }; + +/* Remove a cleanup handler installed by the matching pthread_cleanup_push. + If EXECUTE is non-zero, the handler function is called. */ +# define pthread_cleanup_pop(execute) \ + __clframe.__do_it = (execute); \ + } while (0) + +# ifdef __USE_GNU +/* Install a cleanup handler as pthread_cleanup_push does, but also + saves the current cancellation type and sets it to deferred + cancellation. */ +# define pthread_cleanup_push_defer_np(routine, arg) \ + do { \ + struct __pthread_cleanup_frame __clframe \ + __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \ + = { .__cancel_routine = (routine), .__cancel_arg = (arg), \ + .__do_it = 1 }; \ + (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \ + &__clframe.__cancel_type) + +/* Remove a cleanup handler as pthread_cleanup_pop does, but also + restores the cancellation type that was in effect when the matching + pthread_cleanup_push_defer was called. */ +# define pthread_cleanup_pop_restore_np(execute) \ + (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \ + __clframe.__do_it = (execute); \ + } while (0) +# endif +# endif +#else +/* Install a cleanup handler: ROUTINE will be called with arguments ARG + when the thread is canceled or calls pthread_exit. ROUTINE will also + be called with arguments ARG when the matching pthread_cleanup_pop + is executed with non-zero EXECUTE argument. + + pthread_cleanup_push and pthread_cleanup_pop are macros and must always + be used in matching pairs at the same nesting level of braces. */ +# define pthread_cleanup_push(routine, arg) \ + do { \ + __pthread_unwind_buf_t __cancel_buf; \ + void (*__cancel_routine) (void *) = (routine); \ + void *__cancel_arg = (arg); \ + int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \ + 0); \ + if (__glibc_unlikely (__not_first_call)) \ + { \ + __cancel_routine (__cancel_arg); \ + __pthread_unwind_next (&__cancel_buf); \ + /* NOTREACHED */ \ + } \ + \ + __pthread_register_cancel (&__cancel_buf); \ + do { +extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute; + +/* Remove a cleanup handler installed by the matching pthread_cleanup_push. + If EXECUTE is non-zero, the handler function is called. */ +# define pthread_cleanup_pop(execute) \ + do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\ + } while (0); \ + __pthread_unregister_cancel (&__cancel_buf); \ + if (execute) \ + __cancel_routine (__cancel_arg); \ + } while (0) +extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute; + +# ifdef __USE_GNU +/* Install a cleanup handler as pthread_cleanup_push does, but also + saves the current cancellation type and sets it to deferred + cancellation. */ +# define pthread_cleanup_push_defer_np(routine, arg) \ + do { \ + __pthread_unwind_buf_t __cancel_buf; \ + void (*__cancel_routine) (void *) = (routine); \ + void *__cancel_arg = (arg); \ + int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \ + 0); \ + if (__glibc_unlikely (__not_first_call)) \ + { \ + __cancel_routine (__cancel_arg); \ + __pthread_unwind_next (&__cancel_buf); \ + /* NOTREACHED */ \ + } \ + \ + __pthread_register_cancel_defer (&__cancel_buf); \ + do { +extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute; + +/* Remove a cleanup handler as pthread_cleanup_pop does, but also + restores the cancellation type that was in effect when the matching + pthread_cleanup_push_defer was called. */ +# define pthread_cleanup_pop_restore_np(execute) \ + do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\ + } while (0); \ + __pthread_unregister_cancel_restore (&__cancel_buf); \ + if (execute) \ + __cancel_routine (__cancel_arg); \ + } while (0) +extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute; +# endif + +/* Internal interface to initiate cleanup. */ +extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute __attribute__ ((__noreturn__)) +# ifndef SHARED + __attribute__ ((__weak__)) +# endif + ; +#endif + +/* Function used in the macros. Calling __sigsetjmp, with its first + argument declared as an array, results in a -Wstringop-overflow + warning from GCC 11 because struct pthread_unwind_buf is smaller + than jmp_buf. The calls from the macros have __SAVEMASK set to 0, + so nothing beyond the common prefix is used and this warning is a + false positive. Use an alias with its first argument declared to + use the type in the macros if possible to avoid this warning. */ +#if __GNUC_PREREQ (11, 0) +extern int __REDIRECT_NTHNL (__sigsetjmp_cancel, + (struct __cancel_jmp_buf_tag __env[1], + int __savemask), + __sigsetjmp) __attribute_returns_twice__; +#else +# define __sigsetjmp_cancel(env, savemask) \ + __sigsetjmp ((struct __jmp_buf_tag *) (void *) (env), (savemask)) +extern int __sigsetjmp (struct __jmp_buf_tag __env[1], + int __savemask) __THROWNL; +#endif + + +/* Mutex handling. */ + +/* Initialize a mutex. */ +extern int pthread_mutex_init (pthread_mutex_t *__mutex, + const pthread_mutexattr_t *__mutexattr) + __THROW __nonnull ((1)); + +/* Destroy a mutex. */ +extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) + __THROW __nonnull ((1)); + +/* Try locking a mutex. */ +extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) + __THROWNL __nonnull ((1)); + +/* Lock a mutex. */ +extern int pthread_mutex_lock (pthread_mutex_t *__mutex) + __THROWNL __nonnull ((1)); + +#ifdef __USE_XOPEN2K +/* Wait until lock becomes available, or specified time passes. */ +# ifndef __USE_TIME_BITS64 +extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_mutex_timedlock, + (pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict __abstime), + __pthread_mutex_timedlock64) __nonnull ((1, 2)); +# else +# define pthread_mutex_timedlock __pthread_mutex_timedlock64 +# endif +# endif +#endif + +#ifdef __USE_GNU +# ifndef __USE_TIME_BITS64 +extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_mutex_clocklock, + (pthread_mutex_t *__restrict __mutex, + clockid_t __clockid, + const struct timespec *__restrict __abstime), + __pthread_mutex_clocklock64) __nonnull ((1, 3)); +# else +# define pthread_mutex_clocklock __pthread_mutex_clocklock64 +# endif +# endif +#endif + +/* Unlock a mutex. */ +extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) + __THROWNL __nonnull ((1)); + + +/* Get the priority ceiling of MUTEX. */ +extern int pthread_mutex_getprioceiling (const pthread_mutex_t * + __restrict __mutex, + int *__restrict __prioceiling) + __THROW __nonnull ((1, 2)); + +/* Set the priority ceiling of MUTEX to PRIOCEILING, return old + priority ceiling value in *OLD_CEILING. */ +extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, + int __prioceiling, + int *__restrict __old_ceiling) + __THROW __nonnull ((1, 3)); + + +#ifdef __USE_XOPEN2K8 +/* Declare the state protected by MUTEX as consistent. */ +extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) + __THROW __nonnull ((1)); +# ifdef __USE_GNU +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (pthread_mutex_consistent_np, (pthread_mutex_t *), + pthread_mutex_consistent) __nonnull ((1)) + __attribute_deprecated_msg__ ("\ +pthread_mutex_consistent_np is deprecated, use pthread_mutex_consistent"); +# else +# define pthread_mutex_consistent_np pthread_mutex_consistent +# endif +# endif +#endif + + +/* Functions for handling mutex attributes. */ + +/* Initialize mutex attribute object ATTR with default attributes + (kind is PTHREAD_MUTEX_TIMED_NP). */ +extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) + __THROW __nonnull ((1)); + +/* Destroy mutex attribute object ATTR. */ +extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) + __THROW __nonnull ((1)); + +/* Get the process-shared flag of the mutex attribute ATTR. */ +extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __pshared) + __THROW __nonnull ((1, 2)); + +/* Set the process-shared flag of the mutex attribute ATTR. */ +extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, + int __pshared) + __THROW __nonnull ((1)); + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 +/* Return in *KIND the mutex kind attribute in *ATTR. */ +extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict + __attr, int *__restrict __kind) + __THROW __nonnull ((1, 2)); + +/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL, + PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or + PTHREAD_MUTEX_DEFAULT). */ +extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) + __THROW __nonnull ((1)); +#endif + +/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */ +extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __protocol) + __THROW __nonnull ((1, 2)); + +/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either + PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */ +extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, + int __protocol) + __THROW __nonnull ((1)); + +/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */ +extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __prioceiling) + __THROW __nonnull ((1, 2)); + +/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */ +extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, + int __prioceiling) + __THROW __nonnull ((1)); + +#ifdef __USE_XOPEN2K +/* Get the robustness flag of the mutex attribute ATTR. */ +extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, + int *__robustness) + __THROW __nonnull ((1, 2)); +# ifdef __USE_GNU +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (pthread_mutexattr_getrobust_np, + (pthread_mutexattr_t *, int *), + pthread_mutexattr_getrobust) __nonnull ((1)) + __attribute_deprecated_msg__ ("\ +pthread_mutexattr_getrobust_np is deprecated, use pthread_mutexattr_getrobust"); +# else +# define pthread_mutexattr_getrobust_np pthread_mutexattr_getrobust +# endif +# endif + +/* Set the robustness flag of the mutex attribute ATTR. */ +extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, + int __robustness) + __THROW __nonnull ((1)); +# ifdef __USE_GNU +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (pthread_mutexattr_setrobust_np, + (pthread_mutexattr_t *, int), + pthread_mutexattr_setrobust) __nonnull ((1)) + __attribute_deprecated_msg__ ("\ +pthread_mutexattr_setrobust_np is deprecated, use pthread_mutexattr_setrobust"); +# else +# define pthread_mutexattr_setrobust_np pthread_mutexattr_setrobust +# endif +# endif +#endif + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +/* Functions for handling read-write locks. */ + +/* Initialize read-write lock RWLOCK using attributes ATTR, or use + the default values if later is NULL. */ +extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, + const pthread_rwlockattr_t *__restrict + __attr) __THROW __nonnull ((1)); + +/* Destroy read-write lock RWLOCK. */ +extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) + __THROW __nonnull ((1)); + +/* Acquire read lock for RWLOCK. */ +extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) + __THROWNL __nonnull ((1)); + +/* Try to acquire read lock for RWLOCK. */ +extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) + __THROWNL __nonnull ((1)); + +# ifdef __USE_XOPEN2K +/* Try to acquire read lock for RWLOCK or return after specfied time. */ +# ifndef __USE_TIME_BITS64 +extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock, + (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict __abstime), + __pthread_rwlock_timedrdlock64) + __nonnull ((1, 2)); +# else +# define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock64 +# endif +# endif +# endif + +# ifdef __USE_GNU +# ifndef __USE_TIME_BITS64 +extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_rwlock_clockrdlock, + (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict __abstime), + __pthread_rwlock_clockrdlock64) + __nonnull ((1, 3)); +# else +# define pthread_rwlock_clockrdlock __pthread_rwlock_clockrdlock64 +# endif +# endif +# endif + +/* Acquire write lock for RWLOCK. */ +extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) + __THROWNL __nonnull ((1)); + +/* Try to acquire write lock for RWLOCK. */ +extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) + __THROWNL __nonnull ((1)); + +# ifdef __USE_XOPEN2K +/* Try to acquire write lock for RWLOCK or return after specfied time. */ +# ifndef __USE_TIME_BITS64 +extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_rwlock_timedwrlock, + (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict __abstime), + __pthread_rwlock_timedwrlock64) + __nonnull ((1, 2)); +# else +# define pthread_rwlock_timedwrlock __pthread_rwlock_timedwrlock64 +# endif +# endif +# endif + +# ifdef __USE_GNU +# ifndef __USE_TIME_BITS64 +extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); + +# else +# ifdef __REDIRECT_NTHNL +extern int __REDIRECT_NTHNL (pthread_rwlock_clockwrlock, + (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict __abstime), + __pthread_rwlock_clockwrlock64) + __nonnull ((1, 3)); +# else +# define pthread_rwlock_clockwrlock __pthread_rwlock_clockwrlock64 +# endif +# endif +# endif + +/* Unlock RWLOCK. */ +extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) + __THROWNL __nonnull ((1)); + + +/* Functions for handling read-write lock attributes. */ + +/* Initialize attribute object ATTR with default values. */ +extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) + __THROW __nonnull ((1)); + +/* Destroy attribute object ATTR. */ +extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) + __THROW __nonnull ((1)); + +/* Return current setting of process-shared attribute of ATTR in PSHARED. */ +extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * + __restrict __attr, + int *__restrict __pshared) + __THROW __nonnull ((1, 2)); + +/* Set process-shared attribute of ATTR to PSHARED. */ +extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, + int __pshared) + __THROW __nonnull ((1)); + +/* Return current setting of reader/writer preference. */ +extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * + __restrict __attr, + int *__restrict __pref) + __THROW __nonnull ((1, 2)); + +/* Set reader/write preference. */ +extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, + int __pref) __THROW __nonnull ((1)); +#endif + + +/* Functions for handling conditional variables. */ + +/* Initialize condition variable COND using attributes ATTR, or use + the default values if later is NULL. */ +extern int pthread_cond_init (pthread_cond_t *__restrict __cond, + const pthread_condattr_t *__restrict __cond_attr) + __THROW __nonnull ((1)); + +/* Destroy condition variable COND. */ +extern int pthread_cond_destroy (pthread_cond_t *__cond) + __THROW __nonnull ((1)); + +/* Wake up one thread waiting for condition variable COND. */ +extern int pthread_cond_signal (pthread_cond_t *__cond) + __THROWNL __nonnull ((1)); + +/* Wake up all threads waiting for condition variables COND. */ +extern int pthread_cond_broadcast (pthread_cond_t *__cond) + __THROWNL __nonnull ((1)); + +/* Wait for condition variable COND to be signaled or broadcast. + MUTEX is assumed to be locked before. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex) + __nonnull ((1, 2)); + +/* Wait for condition variable COND to be signaled or broadcast until + ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an + absolute time specification; zero is the beginning of the epoch + (00:00:00 GMT, January 1, 1970). + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_TIME_BITS64 +extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict __abstime) + __nonnull ((1, 2, 3)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (pthread_cond_timedwait, + (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict __abstime), + __pthread_cond_timedwait64) + __nonnull ((1, 2, 3)); +# else +# define pthread_cond_timedwait __pthread_cond_timedwait64 +# endif +# endif + +# ifdef __USE_GNU +/* Wait for condition variable COND to be signaled or broadcast until + ABSTIME measured by the specified clock. MUTEX is assumed to be + locked before. CLOCK is the clock to use. ABSTIME is an absolute + time specification against CLOCK's epoch. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_TIME_BITS64 +extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + __clockid_t __clock_id, + const struct timespec *__restrict __abstime) + __nonnull ((1, 2, 4)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (pthread_cond_clockwait, + (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + __clockid_t __clock_id, + const struct timespec *__restrict __abstime), + __pthread_cond_clockwait64) + __nonnull ((1, 2, 4)); +# else +# define pthread_cond_clockwait __pthread_cond_clockwait64 +# endif +# endif +# endif + +/* Functions for handling condition variable attributes. */ + +/* Initialize condition variable attribute ATTR. */ +extern int pthread_condattr_init (pthread_condattr_t *__attr) + __THROW __nonnull ((1)); + +/* Destroy condition variable attribute ATTR. */ +extern int pthread_condattr_destroy (pthread_condattr_t *__attr) + __THROW __nonnull ((1)); + +/* Get the process-shared flag of the condition variable attribute ATTR. */ +extern int pthread_condattr_getpshared (const pthread_condattr_t * + __restrict __attr, + int *__restrict __pshared) + __THROW __nonnull ((1, 2)); + +/* Set the process-shared flag of the condition variable attribute ATTR. */ +extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, + int __pshared) __THROW __nonnull ((1)); + +#ifdef __USE_XOPEN2K +/* Get the clock selected for the condition variable attribute ATTR. */ +extern int pthread_condattr_getclock (const pthread_condattr_t * + __restrict __attr, + __clockid_t *__restrict __clock_id) + __THROW __nonnull ((1, 2)); + +/* Set the clock selected for the condition variable attribute ATTR. */ +extern int pthread_condattr_setclock (pthread_condattr_t *__attr, + __clockid_t __clock_id) + __THROW __nonnull ((1)); +#endif + + +#ifdef __USE_XOPEN2K +/* Functions to handle spinlocks. */ + +/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can + be shared between different processes. */ +extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) + __THROW __nonnull ((1)); + +/* Destroy the spinlock LOCK. */ +extern int pthread_spin_destroy (pthread_spinlock_t *__lock) + __THROW __nonnull ((1)); + +/* Wait until spinlock LOCK is retrieved. */ +extern int pthread_spin_lock (pthread_spinlock_t *__lock) + __THROWNL __nonnull ((1)); + +/* Try to lock spinlock LOCK. */ +extern int pthread_spin_trylock (pthread_spinlock_t *__lock) + __THROWNL __nonnull ((1)); + +/* Release spinlock LOCK. */ +extern int pthread_spin_unlock (pthread_spinlock_t *__lock) + __THROWNL __nonnull ((1)); + + +/* Functions to handle barriers. */ + +/* Initialize BARRIER with the attributes in ATTR. The barrier is + opened when COUNT waiters arrived. */ +extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, + const pthread_barrierattr_t *__restrict + __attr, unsigned int __count) + __THROW __nonnull ((1)); + +/* Destroy a previously dynamically initialized barrier BARRIER. */ +extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) + __THROW __nonnull ((1)); + +/* Wait on barrier BARRIER. */ +extern int pthread_barrier_wait (pthread_barrier_t *__barrier) + __THROWNL __nonnull ((1)); + + +/* Initialize barrier attribute ATTR. */ +extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) + __THROW __nonnull ((1)); + +/* Destroy previously dynamically initialized barrier attribute ATTR. */ +extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) + __THROW __nonnull ((1)); + +/* Get the process-shared flag of the barrier attribute ATTR. */ +extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * + __restrict __attr, + int *__restrict __pshared) + __THROW __nonnull ((1, 2)); + +/* Set the process-shared flag of the barrier attribute ATTR. */ +extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, + int __pshared) + __THROW __nonnull ((1)); +#endif + + +/* Functions for handling thread-specific data. */ + +/* Create a key value identifying a location in the thread-specific + data area. Each thread maintains a distinct thread-specific data + area. DESTR_FUNCTION, if non-NULL, is called with the value + associated to that key when the key is destroyed. + DESTR_FUNCTION is not called if the value associated is NULL when + the key is destroyed. */ +extern int pthread_key_create (pthread_key_t *__key, + void (*__destr_function) (void *)) + __THROW __nonnull ((1)); + +/* Destroy KEY. */ +extern int pthread_key_delete (pthread_key_t __key) __THROW; + +/* Return current value of the thread-specific data slot identified by KEY. */ +extern void *pthread_getspecific (pthread_key_t __key) __THROW; + +/* Store POINTER in the thread-specific data slot identified by KEY. */ +extern int pthread_setspecific (pthread_key_t __key, + const void *__pointer) + __THROW __attr_access_none (2); + + +#ifdef __USE_XOPEN2K +/* Get ID of CPU-time clock for thread THREAD_ID. */ +extern int pthread_getcpuclockid (pthread_t __thread_id, + __clockid_t *__clock_id) + __THROW __nonnull ((2)); +#endif + + +/* Install handlers to be called when a new process is created with FORK. + The PREPARE handler is called in the parent process just before performing + FORK. The PARENT handler is called in the parent process just after FORK. + The CHILD handler is called in the child process. Each of the three + handlers can be NULL, meaning that no handler needs to be called at that + point. + PTHREAD_ATFORK can be called several times, in which case the PREPARE + handlers are called in LIFO order (last added with PTHREAD_ATFORK, + first called before FORK), and the PARENT and CHILD handlers are called + in FIFO (first added, first called). */ + +extern int pthread_atfork (void (*__prepare) (void), + void (*__parent) (void), + void (*__child) (void)) __THROW; + + +#ifdef __USE_EXTERN_INLINES +/* Optimizations. */ +__extern_inline int +__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2)) +{ + return __thread1 == __thread2; +} +#endif + +__END_DECLS + +#endif /* pthread.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..cfe923ae4485873d2167f2238e0b6e4962074620 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@pthread.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h new file mode 100644 index 0000000000000000000000000000000000000000..a9b7f0aac3e080e0b3c345578bf14d64a32f5d85 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h @@ -0,0 +1,140 @@ +/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SCHED_H +#define _SCHED_H 1 + +#include + +/* Get type definitions. */ +#include + +#define __need_size_t +#define __need_NULL +#include + +#include +#include +#ifndef __USE_XOPEN2K +# include +#endif + +#ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif + +/* Get system specific constant and data structure definitions. */ +#include +#include + +/* Backward compatibility. */ +#define sched_priority sched_priority +#define __sched_priority sched_priority + + +__BEGIN_DECLS + +/* Set scheduling parameters for a process. */ +extern int sched_setparam (__pid_t __pid, const struct sched_param *__param) + __THROW; + +/* Retrieve scheduling parameters for a particular process. */ +extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW; + +/* Set scheduling algorithm and/or parameters for a process. */ +extern int sched_setscheduler (__pid_t __pid, int __policy, + const struct sched_param *__param) __THROW; + +/* Retrieve scheduling algorithm for a particular purpose. */ +extern int sched_getscheduler (__pid_t __pid) __THROW; + +/* Yield the processor. */ +extern int sched_yield (void) __THROW; + +/* Get maximum priority value for a scheduler. */ +extern int sched_get_priority_max (int __algorithm) __THROW; + +/* Get minimum priority value for a scheduler. */ +extern int sched_get_priority_min (int __algorithm) __THROW; + +/* Get the SCHED_RR interval for the named process. */ +#ifndef __USE_TIME_BITS64 +extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW; +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (sched_rr_get_interval, + (__pid_t __pid, struct timespec *__t), + __sched_rr_get_interval64); +# else +# define sched_rr_get_interval __sched_rr_get_interval64 +# endif +#endif + +#ifdef __USE_GNU +/* Access macros for `cpu_set'. */ +# define CPU_SETSIZE __CPU_SETSIZE +# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp) +# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp) +# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \ + cpusetp) +# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp) +# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp) + +# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp) +# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp) +# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \ + cpusetp) +# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp) +# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp) + +# define CPU_EQUAL(cpusetp1, cpusetp2) \ + __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2) +# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ + __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2) + +# define CPU_AND(destset, srcset1, srcset2) \ + __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &) +# define CPU_OR(destset, srcset1, srcset2) \ + __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |) +# define CPU_XOR(destset, srcset1, srcset2) \ + __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^) +# define CPU_AND_S(setsize, destset, srcset1, srcset2) \ + __CPU_OP_S (setsize, destset, srcset1, srcset2, &) +# define CPU_OR_S(setsize, destset, srcset1, srcset2) \ + __CPU_OP_S (setsize, destset, srcset1, srcset2, |) +# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \ + __CPU_OP_S (setsize, destset, srcset1, srcset2, ^) + +# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count) +# define CPU_ALLOC(count) __CPU_ALLOC (count) +# define CPU_FREE(cpuset) __CPU_FREE (cpuset) + + +/* Set the CPU affinity for a task */ +extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, + const cpu_set_t *__cpuset) __THROW; + +/* Get the CPU affinity for a task */ +extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize, + cpu_set_t *__cpuset) __THROW; +#endif + +__END_DECLS + +#endif /* sched.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d45a3115e1d4844493f8cb396d2a42f1878926b6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sched.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h new file mode 100644 index 0000000000000000000000000000000000000000..f61af67cf69a1625907a0592f799c159ad51e205 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h @@ -0,0 +1,92 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.13 Nonlocal jumps + */ + +#ifndef _SETJMP_H +#define _SETJMP_H 1 + +#include + +__BEGIN_DECLS + +#include /* Get `__jmp_buf'. */ +#include + +typedef struct __jmp_buf_tag jmp_buf[1]; + +/* Store the calling environment in ENV, also saving the signal mask. + Return 0. */ +extern int setjmp (jmp_buf __env) __THROWNL; + +/* Store the calling environment in ENV, also saving the + signal mask if SAVEMASK is nonzero. Return 0. + This is the internal name for `sigsetjmp'. */ +extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL; + +/* Store the calling environment in ENV, not saving the signal mask. + Return 0. */ +extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL; + +/* Do not save the signal mask. This is equivalent to the `_setjmp' + BSD function. */ +#define setjmp(env) _setjmp (env) + + +/* Jump to the environment saved in ENV, making the + `setjmp' call there return VAL, or 1 if VAL is 0. */ +extern void longjmp (struct __jmp_buf_tag __env[1], int __val) + __THROWNL __attribute__ ((__noreturn__)); + +#if defined __USE_MISC || defined __USE_XOPEN +/* Same. Usually `_longjmp' is used with `_setjmp', which does not save + the signal mask. But it is how ENV was saved that determines whether + `longjmp' restores the mask; `_longjmp' is just an alias. */ +extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) + __THROWNL __attribute__ ((__noreturn__)); +#endif + + +#ifdef __USE_POSIX +/* Use the same type for `jmp_buf' and `sigjmp_buf'. + The `__mask_was_saved' flag determines whether + or not `longjmp' will restore the signal mask. */ +typedef struct __jmp_buf_tag sigjmp_buf[1]; + +/* Store the calling environment in ENV, also saving the + signal mask if SAVEMASK is nonzero. Return 0. */ +# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask) + +/* Jump to the environment saved in ENV, making the + sigsetjmp call there return VAL, or 1 if VAL is 0. + Restore the signal mask if that sigsetjmp call saved it. + This is just an alias `longjmp'. */ +extern void siglongjmp (sigjmp_buf __env, int __val) + __THROWNL __attribute__ ((__noreturn__)); +#endif /* Use POSIX. */ + + +/* Define helper functions to catch unsafe code. */ +#if __USE_FORTIFY_LEVEL > 0 +# include +#endif + +__END_DECLS + +#endif /* setjmp.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4b9f2b4f2e40a25e8fec17c115fe1e3a3ac0a803 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@setjmp.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h new file mode 100644 index 0000000000000000000000000000000000000000..78d0d819aa580c27cabb3b8071a0cef8e0dc94fc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h @@ -0,0 +1,395 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.14 Signal handling + */ + +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include + +__BEGIN_DECLS + +#include +#include + +#include + +#if defined __USE_POSIX +#include +#endif + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif +#ifdef __USE_XOPEN +# endif +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif +#endif /* Unix98 */ + +#ifdef __USE_POSIX199309 +/* We need `struct timespec' later on. */ +# include +#endif + +#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED +# include +# include +#endif + +#ifdef __USE_MISC +# include +#endif + +#ifdef __USE_POSIX199309 +# include +# include +#endif + + +/* Type of a signal handler. */ +typedef void (*__sighandler_t) (int); + +/* The X/Open definition of `signal' specifies the SVID semantic. Use + the additional function `sysv_signal' when X/Open compatibility is + requested. */ +extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#ifdef __USE_GNU +extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Set the handler for the signal SIG to HANDLER, returning the old + handler, or SIG_ERR on error. + By default `signal' has the BSD semantic. */ +#ifdef __USE_MISC +extern __sighandler_t signal (int __sig, __sighandler_t __handler) + __THROW; +#else +/* Make sure the used `signal' implementation is the SVID version. */ +# ifdef __REDIRECT_NTH +extern __sighandler_t __REDIRECT_NTH (signal, + (int __sig, __sighandler_t __handler), + __sysv_signal); +# else +# define signal __sysv_signal +# endif +#endif + +#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8 +/* The X/Open definition of `signal' conflicts with the BSD version. + So they defined another function `bsd_signal'. */ +extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Send signal SIG to process number PID. If PID is zero, + send SIG to all processes in the current process's process group. + If PID is < -1, send SIG to all processes in process group - PID. */ +#ifdef __USE_POSIX +extern int kill (__pid_t __pid, int __sig) __THROW; +#endif /* Use POSIX. */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Send SIG to all processes in process group PGRP. + If PGRP is zero, send SIG to all processes in + the current process's process group. */ +extern int killpg (__pid_t __pgrp, int __sig) __THROW; +#endif /* Use misc || X/Open Unix. */ + +/* Raise signal SIG, i.e., send SIG to yourself. */ +extern int raise (int __sig) __THROW; + +#ifdef __USE_MISC +/* SVID names for the same things. */ +extern __sighandler_t ssignal (int __sig, __sighandler_t __handler) + __THROW; +extern int gsignal (int __sig) __THROW; +#endif /* Use misc. */ + +#ifdef __USE_XOPEN2K8 +/* Print a message describing the meaning of the given signal number. */ +extern void psignal (int __sig, const char *__s); + +/* Print a message describing the meaning of the given signal information. */ +extern void psiginfo (const siginfo_t *__pinfo, const char *__s); +#endif /* POSIX 2008. */ + + + +/* The `sigpause' function in X/Open defines the argument as the + signal number. This requires redirecting to another function + because the default version in glibc uses an old BSD interface. + + This function is a cancellation point and therefore not marked with + __THROW. */ + +#ifdef __USE_XOPEN_EXTENDED +# ifdef __GNUC__ +extern int sigpause (int __sig) __asm__ ("__xpg_sigpause") + __attribute_deprecated_msg__ ("Use the sigsuspend function instead"); +# else +extern int __sigpause (int __sig_or_mask, int __is_sig); +/* Remove a signal from the signal mask and suspend the process. */ +# define sigpause(sig) __sigpause ((sig), 1) +# endif +#endif + + +#ifdef __USE_MISC +/* None of the following functions should be used anymore. They are here + only for compatibility. A single word (`int') is not guaranteed to be + enough to hold a complete signal mask and therefore these functions + simply do not work in many situations. Use `sigprocmask' instead. */ + +/* Compute mask for signal SIG. */ +# define sigmask(sig) \ + __glibc_macro_warning ("sigmask is deprecated") \ + ((int)(1u << ((sig) - 1))) + +/* Block signals in MASK, returning the old mask. */ +extern int sigblock (int __mask) __THROW __attribute_deprecated__; + +/* Set the mask of blocked signals to MASK, returning the old mask. */ +extern int sigsetmask (int __mask) __THROW __attribute_deprecated__; + +/* Return currently selected signal mask. */ +extern int siggetmask (void) __THROW __attribute_deprecated__; +#endif /* Use misc. */ + + +#ifdef __USE_MISC +# define NSIG _NSIG +#endif + +#ifdef __USE_GNU +typedef __sighandler_t sighandler_t; +#endif + +/* 4.4 BSD uses the name `sig_t' for this. */ +#ifdef __USE_MISC +typedef __sighandler_t sig_t; +#endif + +#ifdef __USE_POSIX + +/* Clear all signals from SET. */ +extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Set all signals in SET. */ +extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Add SIGNO to SET. */ +extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Remove SIGNO from SET. */ +extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Return 1 if SIGNO is in SET, 0 if not. */ +extern int sigismember (const sigset_t *__set, int __signo) + __THROW __nonnull ((1)); + +# ifdef __USE_GNU +/* Return non-empty value is SET is not empty. */ +extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1)); + +/* Build new signal set by combining the two inputs set using logical AND. */ +extern int sigandset (sigset_t *__set, const sigset_t *__left, + const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); + +/* Build new signal set by combining the two inputs set using logical OR. */ +extern int sigorset (sigset_t *__set, const sigset_t *__left, + const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); +# endif /* GNU */ + +/* Get the system-specific definitions of `struct sigaction' + and the `SA_*' and `SIG_*'. constants. */ +# include + +/* Get and/or change the set of blocked signals. */ +extern int sigprocmask (int __how, const sigset_t *__restrict __set, + sigset_t *__restrict __oset) __THROW; + +/* Change the set of blocked signals to SET, + wait until a signal arrives, and restore the set of blocked signals. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigsuspend (const sigset_t *__set) __nonnull ((1)); + +/* Get and/or set the action for signal SIG. */ +extern int sigaction (int __sig, const struct sigaction *__restrict __act, + struct sigaction *__restrict __oact) __THROW; + +/* Put in SET all signals that are blocked and waiting to be delivered. */ +extern int sigpending (sigset_t *__set) __THROW __nonnull ((1)); + + +# ifdef __USE_POSIX199506 +/* Select any of pending signals from SET or wait for any to arrive. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig) + __nonnull ((1, 2)); +# endif /* Use POSIX 1995. */ + +# ifdef __USE_POSIX199309 +/* Select any of pending signals from SET and place information in INFO. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwaitinfo (const sigset_t *__restrict __set, + siginfo_t *__restrict __info) __nonnull ((1)); + +/* Select any of pending signals from SET and place information in INFO. + Wait the time specified by TIMEOUT if no signal is pending. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_TIME_BITS64 +extern int sigtimedwait (const sigset_t *__restrict __set, + siginfo_t *__restrict __info, + const struct timespec *__restrict __timeout) + __nonnull ((1)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (sigtimedwait, + (const sigset_t *__restrict __set, + siginfo_t *__restrict __info, + const struct timespec *__restrict __timeout), + __sigtimedwait64) + __nonnull ((1)); +# else +# define sigtimedwait __sigtimedwait64 +# endif +# endif + +/* Send signal SIG to the process PID. Associate data in VAL with the + signal. */ +extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val) + __THROW; +# endif /* Use POSIX 199306. */ + +#endif /* Use POSIX. */ + +#ifdef __USE_MISC + +/* Get machine-dependent `struct sigcontext' and signal subcodes. */ +# include + +/* Restore the state saved in SCP. */ +extern int sigreturn (struct sigcontext *__scp) __THROW; + +#endif /* Use misc. */ + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +# define __need_size_t +# include + +# include +# if defined __USE_XOPEN || defined __USE_XOPEN2K8 +/* This will define `ucontext_t' and `mcontext_t'. */ +# include +# endif +#endif /* Use POSIX.1-2008 or X/Open Unix. */ + +#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC +/* If INTERRUPT is nonzero, make signal SIG interrupt system calls + (causing them to fail with EINTR); if INTERRUPT is zero, make system + calls be restarted after signal SIG. */ +extern int siginterrupt (int __sig, int __interrupt) __THROW + __attribute_deprecated_msg__ ("Use sigaction with SA_RESTART instead"); + +# include +# include +# include + +/* Alternate signal handler stack interface. + This interface should always be preferred over `sigstack'. */ +extern int sigaltstack (const stack_t *__restrict __ss, + stack_t *__restrict __oss) __THROW; +#endif /* __USE_XOPEN_EXTENDED || __USE_MISC */ + +#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC) +# include +#endif + +#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ + || defined __USE_MISC) +/* Run signals handlers on the stack specified by SS (if not NULL). + If OSS is not NULL, it is filled in with the old signal stack status. + This interface is obsolete and on many platform not implemented. */ +extern int sigstack (struct sigstack *__ss, struct sigstack *__oss) + __THROW __attribute_deprecated__; +#endif + +#ifdef __USE_XOPEN_EXTENDED +/* Simplified interface for signal management. */ + +/* Add SIG to the calling process' signal mask. */ +extern int sighold (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the sigprocmask function instead"); + +/* Remove SIG from the calling process' signal mask. */ +extern int sigrelse (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the sigprocmask function instead"); + +/* Set the disposition of SIG to SIG_IGN. */ +extern int sigignore (int __sig) __THROW + __attribute_deprecated_msg__ ("Use the signal function instead"); + +/* Set the disposition of SIG. */ +extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW + __attribute_deprecated_msg__ + ("Use the signal and sigprocmask functions instead"); +#endif + +#if defined __USE_POSIX199506 || defined __USE_UNIX98 +/* Some of the functions for handling signals in threaded programs must + be defined here. */ +# include +# include +#endif /* use Unix98 */ + +/* The following functions are used internally in the C library and in + other code which need deep insights. */ + +/* Return number of available real-time signal with highest priority. */ +extern int __libc_current_sigrtmin (void) __THROW; +/* Return number of available real-time signal with lowest priority. */ +extern int __libc_current_sigrtmax (void) __THROW; + +#define SIGRTMIN (__libc_current_sigrtmin ()) +#define SIGRTMAX (__libc_current_sigrtmax ()) + +/* System-specific extensions. */ +#include + +__END_DECLS + +#endif /* not signal.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8a6a7a07031d168d9b7606c027cf02da18f26d5f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@signal.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h new file mode 100644 index 0000000000000000000000000000000000000000..d76933d4682871702c4b127938273b6b11c8addd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h @@ -0,0 +1,64 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STDC_PREDEF_H +#define _STDC_PREDEF_H 1 + +/* This header is separate from features.h so that the compiler can + include it implicitly at the start of every compilation. It must + not itself include or any other header that includes + because the implicit include comes before any feature + test macros that may be defined in a source file before it first + explicitly includes a system header. GCC knows the name of this + header in order to preinclude it. */ + +/* glibc's intent is to support the IEC 559 math functionality, real + and complex. If the GCC (4.9 and later) predefined macros + specifying compiler intent are available, use them to determine + whether the overall intent is to support these features; otherwise, + presume an older compiler has intent to support these features and + define these macros by default. */ + +#ifdef __GCC_IEC_559 +# if __GCC_IEC_559 > 0 +# define __STDC_IEC_559__ 1 +# define __STDC_IEC_60559_BFP__ 201404L +# endif +#else +# define __STDC_IEC_559__ 1 +# define __STDC_IEC_60559_BFP__ 201404L +#endif + +#ifdef __GCC_IEC_559_COMPLEX +# if __GCC_IEC_559_COMPLEX > 0 +# define __STDC_IEC_559_COMPLEX__ 1 +# define __STDC_IEC_60559_COMPLEX__ 201404L +# endif +#else +# define __STDC_IEC_559_COMPLEX__ 1 +# define __STDC_IEC_60559_COMPLEX__ 201404L +#endif + +/* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is + synchronized with ISO/IEC 10646:2017, fifth edition, plus + the following additions from Amendment 1 to the fifth edition: + - 56 emoji characters + - 285 hentaigana + - 3 additional Zanabazar Square characters */ +#define __STDC_ISO_10646__ 201706L + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..fe2df7ed6deeed18d1755728fb62fb1531fb061f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdc-predef.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h new file mode 100644 index 0000000000000000000000000000000000000000..2d666f79fd97aa419ad1febcb420914fbe1a0dd1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h @@ -0,0 +1,319 @@ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99: 7.18 Integer types + */ + +#ifndef _STDINT_H +#define _STDINT_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include +#include +#include +#include + +/* Exact integral types. */ + +/* Signed. */ +#include + +/* Unsigned. */ +#include + + +/* Small types. */ + +/* Signed. */ +typedef __int_least8_t int_least8_t; +typedef __int_least16_t int_least16_t; +typedef __int_least32_t int_least32_t; +typedef __int_least64_t int_least64_t; + +/* Unsigned. */ +typedef __uint_least8_t uint_least8_t; +typedef __uint_least16_t uint_least16_t; +typedef __uint_least32_t uint_least32_t; +typedef __uint_least64_t uint_least64_t; + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if __WORDSIZE == 64 +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +__extension__ +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +__extension__ +typedef unsigned long long int uint_fast64_t; +#endif + + +/* Types for `void *' pointers. */ +#if __WORDSIZE == 64 +# ifndef __intptr_t_defined +typedef long int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned long int uintptr_t; +#else +# ifndef __intptr_t_defined +typedef int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned int uintptr_t; +#endif + + +/* Largest integral types. */ +typedef __intmax_t intmax_t; +typedef __uintmax_t uintmax_t; + + +# if __WORDSIZE == 64 +# define __INT64_C(c) c ## L +# define __UINT64_C(c) c ## UL +# else +# define __INT64_C(c) c ## LL +# define __UINT64_C(c) c ## ULL +# endif + +/* Limits of integral types. */ + +/* Minimum of signed integral types. */ +# define INT8_MIN (-128) +# define INT16_MIN (-32767-1) +# define INT32_MIN (-2147483647-1) +# define INT64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types. */ +# define INT8_MAX (127) +# define INT16_MAX (32767) +# define INT32_MAX (2147483647) +# define INT64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types. */ +# define UINT8_MAX (255) +# define UINT16_MAX (65535) +# define UINT32_MAX (4294967295U) +# define UINT64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of signed integral types having a minimum size. */ +# define INT_LEAST8_MIN (-128) +# define INT_LEAST16_MIN (-32767-1) +# define INT_LEAST32_MIN (-2147483647-1) +# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types having a minimum size. */ +# define INT_LEAST8_MAX (127) +# define INT_LEAST16_MAX (32767) +# define INT_LEAST32_MAX (2147483647) +# define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types having a minimum size. */ +# define UINT_LEAST8_MAX (255) +# define UINT_LEAST16_MAX (65535) +# define UINT_LEAST32_MAX (4294967295U) +# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MIN (-128) +# if __WORDSIZE == 64 +# define INT_FAST16_MIN (-9223372036854775807L-1) +# define INT_FAST32_MIN (-9223372036854775807L-1) +# else +# define INT_FAST16_MIN (-2147483647-1) +# define INT_FAST32_MIN (-2147483647-1) +# endif +# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MAX (127) +# if __WORDSIZE == 64 +# define INT_FAST16_MAX (9223372036854775807L) +# define INT_FAST32_MAX (9223372036854775807L) +# else +# define INT_FAST16_MAX (2147483647) +# define INT_FAST32_MAX (2147483647) +# endif +# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of fast unsigned integral types having a minimum size. */ +# define UINT_FAST8_MAX (255) +# if __WORDSIZE == 64 +# define UINT_FAST16_MAX (18446744073709551615UL) +# define UINT_FAST32_MAX (18446744073709551615UL) +# else +# define UINT_FAST16_MAX (4294967295U) +# define UINT_FAST32_MAX (4294967295U) +# endif +# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Values to test for integral types holding `void *' pointer. */ +# if __WORDSIZE == 64 +# define INTPTR_MIN (-9223372036854775807L-1) +# define INTPTR_MAX (9223372036854775807L) +# define UINTPTR_MAX (18446744073709551615UL) +# else +# define INTPTR_MIN (-2147483647-1) +# define INTPTR_MAX (2147483647) +# define UINTPTR_MAX (4294967295U) +# endif + + +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (__INT64_C(9223372036854775807)) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (__UINT64_C(18446744073709551615)) + + +/* Limits of other integer types. */ + +/* Limits of `ptrdiff_t' type. */ +# if __WORDSIZE == 64 +# define PTRDIFF_MIN (-9223372036854775807L-1) +# define PTRDIFF_MAX (9223372036854775807L) +# else +# if __WORDSIZE32_PTRDIFF_LONG +# define PTRDIFF_MIN (-2147483647L-1) +# define PTRDIFF_MAX (2147483647L) +# else +# define PTRDIFF_MIN (-2147483647-1) +# define PTRDIFF_MAX (2147483647) +# endif +# endif + +/* Limits of `sig_atomic_t'. */ +# define SIG_ATOMIC_MIN (-2147483647-1) +# define SIG_ATOMIC_MAX (2147483647) + +/* Limit of `size_t' type. */ +# if __WORDSIZE == 64 +# define SIZE_MAX (18446744073709551615UL) +# else +# if __WORDSIZE32_SIZE_ULONG +# define SIZE_MAX (4294967295UL) +# else +# define SIZE_MAX (4294967295U) +# endif +# endif + +/* Limits of `wchar_t'. */ +# ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +# endif + +/* Limits of `wint_t'. */ +# define WINT_MIN (0u) +# define WINT_MAX (4294967295u) + +/* Signed. */ +# define INT8_C(c) c +# define INT16_C(c) c +# define INT32_C(c) c +# if __WORDSIZE == 64 +# define INT64_C(c) c ## L +# else +# define INT64_C(c) c ## LL +# endif + +/* Unsigned. */ +# define UINT8_C(c) c +# define UINT16_C(c) c +# define UINT32_C(c) c ## U +# if __WORDSIZE == 64 +# define UINT64_C(c) c ## UL +# else +# define UINT64_C(c) c ## ULL +# endif + +/* Maximal type. */ +# if __WORDSIZE == 64 +# define INTMAX_C(c) c ## L +# define UINTMAX_C(c) c ## UL +# else +# define INTMAX_C(c) c ## LL +# define UINTMAX_C(c) c ## ULL +# endif + +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) + +# define INT8_WIDTH 8 +# define UINT8_WIDTH 8 +# define INT16_WIDTH 16 +# define UINT16_WIDTH 16 +# define INT32_WIDTH 32 +# define UINT32_WIDTH 32 +# define INT64_WIDTH 64 +# define UINT64_WIDTH 64 + +# define INT_LEAST8_WIDTH 8 +# define UINT_LEAST8_WIDTH 8 +# define INT_LEAST16_WIDTH 16 +# define UINT_LEAST16_WIDTH 16 +# define INT_LEAST32_WIDTH 32 +# define UINT_LEAST32_WIDTH 32 +# define INT_LEAST64_WIDTH 64 +# define UINT_LEAST64_WIDTH 64 + +# define INT_FAST8_WIDTH 8 +# define UINT_FAST8_WIDTH 8 +# define INT_FAST16_WIDTH __WORDSIZE +# define UINT_FAST16_WIDTH __WORDSIZE +# define INT_FAST32_WIDTH __WORDSIZE +# define UINT_FAST32_WIDTH __WORDSIZE +# define INT_FAST64_WIDTH 64 +# define UINT_FAST64_WIDTH 64 + +# define INTPTR_WIDTH __WORDSIZE +# define UINTPTR_WIDTH __WORDSIZE + +# define INTMAX_WIDTH 64 +# define UINTMAX_WIDTH 64 + +# define PTRDIFF_WIDTH __WORDSIZE +# define SIG_ATOMIC_WIDTH 32 +# define SIZE_WIDTH __WORDSIZE +# define WCHAR_WIDTH 32 +# define WINT_WIDTH 32 + +#endif + +#endif /* stdint.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..284f3d431770b0bc927b0fde32a4d259bfbe466c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdint.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h new file mode 100644 index 0000000000000000000000000000000000000000..0e0f16b46410c8e289a7f2bb35d96e255135b70e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h @@ -0,0 +1,911 @@ +/* Define ISO C stdio on top of C++ iostreams. + Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.19 Input/output + */ + +#ifndef _STDIO_H +#define _STDIO_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +__BEGIN_DECLS + +#define __need_size_t +#define __need_NULL +#include + +#define __need___va_list +#include + +#include +#include +#include +#include +#include +#include + +#ifdef __USE_GNU +# include +#endif + +#if defined __USE_XOPEN || defined __USE_XOPEN2K8 +# ifdef __GNUC__ +# ifndef _VA_LIST_DEFINED +typedef __gnuc_va_list va_list; +# define _VA_LIST_DEFINED +# endif +# else +# include +# endif +#endif + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +# ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +# endif +# if defined __USE_LARGEFILE64 && !defined __off64_t_defined +typedef __off64_t off64_t; +# define __off64_t_defined +# endif +#endif + +#ifdef __USE_XOPEN2K8 +# ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +# endif +#endif + +/* The type of the second argument to `fgetpos' and `fsetpos'. */ +#ifndef __USE_FILE_OFFSET64 +typedef __fpos_t fpos_t; +#else +typedef __fpos64_t fpos_t; +#endif +#ifdef __USE_LARGEFILE64 +typedef __fpos64_t fpos64_t; +#endif + +/* The possibilities for the third argument to `setvbuf'. */ +#define _IOFBF 0 /* Fully buffered. */ +#define _IOLBF 1 /* Line buffered. */ +#define _IONBF 2 /* No buffering. */ + + +/* Default buffer size. */ +#define BUFSIZ 8192 + + +/* The value returned by fgetc and similar functions to indicate the + end of the file. */ +#define EOF (-1) + + +/* The possibilities for the third argument to `fseek'. + These values should not be changed. */ +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Seek from end of file. */ +#ifdef __USE_GNU +# define SEEK_DATA 3 /* Seek to next data. */ +# define SEEK_HOLE 4 /* Seek to next hole. */ +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN +/* Default path prefix for `tempnam' and `tmpnam'. */ +# define P_tmpdir "/tmp" +#endif + + +/* Get the values: + L_tmpnam How long an array of chars must be to be passed to `tmpnam'. + TMP_MAX The minimum number of unique filenames generated by tmpnam + (and tempnam when it uses tmpnam's name space), + or tempnam (the two are separate). + L_ctermid How long an array to pass to `ctermid'. + L_cuserid How long an array to pass to `cuserid'. + FOPEN_MAX Minimum number of files that can be open at once. + FILENAME_MAX Maximum length of a filename. */ +#include + + +#if __GLIBC_USE (ISOC2X) +/* Maximum length of printf output for a NaN. */ +# define _PRINTF_NAN_LEN_MAX 4 +#endif + + +/* Standard streams. */ +extern FILE *stdin; /* Standard input stream. */ +extern FILE *stdout; /* Standard output stream. */ +extern FILE *stderr; /* Standard error output stream. */ +/* C89/C99 say they're macros. Make them happy. */ +#define stdin stdin +#define stdout stdout +#define stderr stderr + +/* Remove file FILENAME. */ +extern int remove (const char *__filename) __THROW; +/* Rename file OLD to NEW. */ +extern int rename (const char *__old, const char *__new) __THROW; + +#ifdef __USE_ATFILE +/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */ +extern int renameat (int __oldfd, const char *__old, int __newfd, + const char *__new) __THROW; +#endif + +#ifdef __USE_GNU +/* Flags for renameat2. */ +# define RENAME_NOREPLACE (1 << 0) +# define RENAME_EXCHANGE (1 << 1) +# define RENAME_WHITEOUT (1 << 2) + +/* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with + additional flags. */ +extern int renameat2 (int __oldfd, const char *__old, int __newfd, + const char *__new, unsigned int __flags) __THROW; +#endif + +/* Close STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fclose (FILE *__stream); + +#undef __attr_dealloc_fclose +#define __attr_dealloc_fclose __attr_dealloc (fclose, 1) + +/* Create a temporary file and open it read/write. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern FILE *tmpfile (void) + __attribute_malloc__ __attr_dealloc_fclose __wur; +#else +# ifdef __REDIRECT +extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) + __attribute_malloc__ __attr_dealloc_fclose __wur; +# else +# define tmpfile tmpfile64 +# endif +#endif + +#ifdef __USE_LARGEFILE64 +extern FILE *tmpfile64 (void) + __attribute_malloc__ __attr_dealloc_fclose __wur; +#endif + +/* Generate a temporary filename. */ +extern char *tmpnam (char[L_tmpnam]) __THROW __wur; + +#ifdef __USE_MISC +/* This is the reentrant variant of `tmpnam'. The only difference is + that it does not allow S to be NULL. */ +extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur; +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN +/* Generate a unique temporary filename using up to five characters of PFX + if it is not NULL. The directory to put this file in is searched for + as follows: First the environment variable "TMPDIR" is checked. + If it contains the name of a writable directory, that directory is used. + If not and if DIR is not NULL, that value is checked. If that fails, + P_tmpdir is tried and finally "/tmp". The storage for the filename + is allocated by `malloc'. */ +extern char *tempnam (const char *__dir, const char *__pfx) + __THROW __attribute_malloc__ __wur __attr_dealloc_free; +#endif + +/* Flush STREAM, or all streams if STREAM is NULL. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fflush (FILE *__stream); + +#ifdef __USE_MISC +/* Faster versions when locking is not required. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fflush_unlocked (FILE *__stream); +#endif + +#ifdef __USE_GNU +/* Close all streams. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fcloseall (void); +#endif + + +#ifndef __USE_FILE_OFFSET64 +/* Open a file and create a new stream for it. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *fopen (const char *__restrict __filename, + const char *__restrict __modes) + __attribute_malloc__ __attr_dealloc_fclose __wur; +/* Open a file, replacing an existing stream with it. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *freopen (const char *__restrict __filename, + const char *__restrict __modes, + FILE *__restrict __stream) __wur; +#else +# ifdef __REDIRECT +extern FILE *__REDIRECT (fopen, (const char *__restrict __filename, + const char *__restrict __modes), fopen64) + __attribute_malloc__ __attr_dealloc_fclose __wur; +extern FILE *__REDIRECT (freopen, (const char *__restrict __filename, + const char *__restrict __modes, + FILE *__restrict __stream), freopen64) + __wur; +# else +# define fopen fopen64 +# define freopen freopen64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern FILE *fopen64 (const char *__restrict __filename, + const char *__restrict __modes) + __attribute_malloc__ __attr_dealloc_fclose __wur; +extern FILE *freopen64 (const char *__restrict __filename, + const char *__restrict __modes, + FILE *__restrict __stream) __wur; +#endif + +#ifdef __USE_POSIX +/* Create a new stream that refers to an existing system file descriptor. */ +extern FILE *fdopen (int __fd, const char *__modes) __THROW + __attribute_malloc__ __attr_dealloc_fclose __wur; +#endif + +#ifdef __USE_GNU +/* Create a new stream that refers to the given magic cookie, + and uses the given functions for input and output. */ +extern FILE *fopencookie (void *__restrict __magic_cookie, + const char *__restrict __modes, + cookie_io_functions_t __io_funcs) __THROW + __attribute_malloc__ __attr_dealloc_fclose __wur; +#endif + +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) +/* Create a new stream that refers to a memory buffer. */ +extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) + __THROW __attribute_malloc__ __attr_dealloc_fclose __wur; + +/* Open a stream that writes into a malloc'd buffer that is expanded as + necessary. *BUFLOC and *SIZELOC are updated with the buffer's location + and the number of characters written on fflush or fclose. */ +extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW + __attribute_malloc__ __attr_dealloc_fclose __wur; + +#ifdef _WCHAR_H +/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces + a wide character string. Declared here only to add attribute malloc + and only if has been previously #included. */ +extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW + __attribute_malloc__ __attr_dealloc_fclose; +# endif +#endif + +/* If BUF is NULL, make STREAM unbuffered. + Else make it use buffer BUF, of size BUFSIZ. */ +extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW; +/* Make STREAM use buffering mode MODE. + If BUF is not NULL, use N bytes of it for buffering; + else allocate an internal buffer N bytes long. */ +extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, + int __modes, size_t __n) __THROW; + +#ifdef __USE_MISC +/* If BUF is NULL, make STREAM unbuffered. + Else make it use SIZE bytes of BUF for buffering. */ +extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, + size_t __size) __THROW; + +/* Make STREAM line-buffered. */ +extern void setlinebuf (FILE *__stream) __THROW; +#endif + + +/* Write formatted output to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fprintf (FILE *__restrict __stream, + const char *__restrict __format, ...); +/* Write formatted output to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int printf (const char *__restrict __format, ...); +/* Write formatted output to S. */ +extern int sprintf (char *__restrict __s, + const char *__restrict __format, ...) __THROWNL; + +/* Write formatted output to S from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg); +/* Write formatted output to stdout from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); +/* Write formatted output to S from argument list ARG. */ +extern int vsprintf (char *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) __THROWNL; + +#if defined __USE_ISOC99 || defined __USE_UNIX98 +/* Maximum chars of output to write in MAXLEN. */ +extern int snprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, ...) + __THROWNL __attribute__ ((__format__ (__printf__, 3, 4))); + +extern int vsnprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, __gnuc_va_list __arg) + __THROWNL __attribute__ ((__format__ (__printf__, 3, 0))); +#endif + +#if __GLIBC_USE (LIB_EXT2) +/* Write formatted output to a string dynamically allocated with `malloc'. + Store the address of the string in *PTR. */ +extern int vasprintf (char **__restrict __ptr, const char *__restrict __f, + __gnuc_va_list __arg) + __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur; +extern int __asprintf (char **__restrict __ptr, + const char *__restrict __fmt, ...) + __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur; +extern int asprintf (char **__restrict __ptr, + const char *__restrict __fmt, ...) + __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur; +#endif + +#ifdef __USE_XOPEN2K8 +/* Write formatted output to a file descriptor. */ +extern int vdprintf (int __fd, const char *__restrict __fmt, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__printf__, 2, 0))); +extern int dprintf (int __fd, const char *__restrict __fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +#endif + + +/* Read formatted input from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fscanf (FILE *__restrict __stream, + const char *__restrict __format, ...) __wur; +/* Read formatted input from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int scanf (const char *__restrict __format, ...) __wur; +/* Read formatted input from S. */ +extern int sscanf (const char *__restrict __s, + const char *__restrict __format, ...) __THROW; + +/* For historical reasons, the C99-compliant versions of the scanf + functions are at alternative names. When __LDBL_COMPAT or + __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in + bits/stdio-ldbl.h. */ +#include +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \ + && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 +# ifdef __REDIRECT +extern int __REDIRECT (fscanf, (FILE *__restrict __stream, + const char *__restrict __format, ...), + __isoc99_fscanf) __wur; +extern int __REDIRECT (scanf, (const char *__restrict __format, ...), + __isoc99_scanf) __wur; +extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s, + const char *__restrict __format, ...), + __isoc99_sscanf); +# else +extern int __isoc99_fscanf (FILE *__restrict __stream, + const char *__restrict __format, ...) __wur; +extern int __isoc99_scanf (const char *__restrict __format, ...) __wur; +extern int __isoc99_sscanf (const char *__restrict __s, + const char *__restrict __format, ...) __THROW; +# define fscanf __isoc99_fscanf +# define scanf __isoc99_scanf +# define sscanf __isoc99_sscanf +# endif +#endif + +#ifdef __USE_ISOC99 +/* Read formatted input from S into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; + +/* Read formatted input from stdin into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; + +/* Read formatted input from S into argument list ARG. */ +extern int vsscanf (const char *__restrict __s, + const char *__restrict __format, __gnuc_va_list __arg) + __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); + +/* Same redirection as above for the v*scanf family. */ +# if !__GLIBC_USE (DEPRECATED_SCANF) +# if defined __REDIRECT && !defined __LDBL_COMPAT \ + && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 +extern int __REDIRECT (vfscanf, + (FILE *__restrict __s, + const char *__restrict __format, __gnuc_va_list __arg), + __isoc99_vfscanf) + __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; +extern int __REDIRECT (vscanf, (const char *__restrict __format, + __gnuc_va_list __arg), __isoc99_vscanf) + __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; +extern int __REDIRECT_NTH (vsscanf, + (const char *__restrict __s, + const char *__restrict __format, + __gnuc_va_list __arg), __isoc99_vsscanf) + __attribute__ ((__format__ (__scanf__, 2, 0))); +# elif !defined __REDIRECT +extern int __isoc99_vfscanf (FILE *__restrict __s, + const char *__restrict __format, + __gnuc_va_list __arg) __wur; +extern int __isoc99_vscanf (const char *__restrict __format, + __gnuc_va_list __arg) __wur; +extern int __isoc99_vsscanf (const char *__restrict __s, + const char *__restrict __format, + __gnuc_va_list __arg) __THROW; +# define vfscanf __isoc99_vfscanf +# define vscanf __isoc99_vscanf +# define vsscanf __isoc99_vsscanf +# endif +# endif +#endif /* Use ISO C9x. */ + + +/* Read a character from STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int fgetc (FILE *__stream); +extern int getc (FILE *__stream); + +/* Read a character from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getchar (void); + +#ifdef __USE_POSIX199506 +/* These are defined in POSIX.1:1996. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int getc_unlocked (FILE *__stream); +extern int getchar_unlocked (void); +#endif /* Use POSIX. */ + +#ifdef __USE_MISC +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fgetc_unlocked (FILE *__stream); +#endif /* Use MISC. */ + + +/* Write a character to STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. + + These functions is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fputc (int __c, FILE *__stream); +extern int putc (int __c, FILE *__stream); + +/* Write a character to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int putchar (int __c); + +#ifdef __USE_MISC +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputc_unlocked (int __c, FILE *__stream); +#endif /* Use MISC. */ + +#ifdef __USE_POSIX199506 +/* These are defined in POSIX.1:1996. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int putc_unlocked (int __c, FILE *__stream); +extern int putchar_unlocked (int __c); +#endif /* Use POSIX. */ + + +#if defined __USE_MISC \ + || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +/* Get a word (int) from STREAM. */ +extern int getw (FILE *__stream); + +/* Write a word (int) to STREAM. */ +extern int putw (int __w, FILE *__stream); +#endif + + +/* Get a newline-terminated string of finite length from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) + __wur __fortified_attr_access (__write_only__, 1, 2); + +#if __GLIBC_USE (DEPRECATED_GETS) +/* Get a newline-terminated string from stdin, removing the newline. + + This function is impossible to use safely. It has been officially + removed from ISO C11 and ISO C++14, and we have also removed it + from the _GNU_SOURCE feature list. It remains available when + explicitly using an old ISO C, Unix, or POSIX standard. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern char *gets (char *__s) __wur __attribute_deprecated__; +#endif + +#ifdef __USE_GNU +/* This function does the same as `fgets' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern char *fgets_unlocked (char *__restrict __s, int __n, + FILE *__restrict __stream) __wur + __fortified_attr_access (__write_only__, 1, 2); +#endif + + +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) +/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR + (and null-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'd as + necessary. Returns the number of characters read (not including the + null terminator), or -1 on error or EOF. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern __ssize_t __getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) __wur; +extern __ssize_t getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) __wur; + +/* Like `getdelim', but reads up to a newline. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern __ssize_t getline (char **__restrict __lineptr, + size_t *__restrict __n, + FILE *__restrict __stream) __wur; +#endif + + +/* Write a string to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fputs (const char *__restrict __s, FILE *__restrict __stream); + +/* Write a string, followed by a newline, to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int puts (const char *__s); + + +/* Push a character back onto the input buffer of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int ungetc (int __c, FILE *__stream); + + +/* Read chunks of generic data from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern size_t fread (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) __wur; +/* Write chunks of generic data to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern size_t fwrite (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __s); + +#ifdef __USE_GNU +/* This function does the same as `fputs' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputs_unlocked (const char *__restrict __s, + FILE *__restrict __stream); +#endif + +#ifdef __USE_MISC +/* Faster versions when locking is not necessary. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) __wur; +extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); +#endif + + +/* Seek to a certain position on STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fseek (FILE *__stream, long int __off, int __whence); +/* Return the current position of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern long int ftell (FILE *__stream) __wur; +/* Rewind to the beginning of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void rewind (FILE *__stream); + +/* The Single Unix Specification, Version 2, specifies an alternative, + more adequate interface for the two functions above which deal with + file offset. `long int' is not the right type. These definitions + are originally defined in the Large File Support API. */ + +#if defined __USE_LARGEFILE || defined __USE_XOPEN2K +# ifndef __USE_FILE_OFFSET64 +/* Seek to a certain position on STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fseeko (FILE *__stream, __off_t __off, int __whence); +/* Return the current position of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern __off_t ftello (FILE *__stream) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (fseeko, + (FILE *__stream, __off64_t __off, int __whence), + fseeko64); +extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64); +# else +# define fseeko fseeko64 +# define ftello ftello64 +# endif +# endif +#endif + +#ifndef __USE_FILE_OFFSET64 +/* Get STREAM's position. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); +/* Set STREAM's position. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fsetpos (FILE *__stream, const fpos_t *__pos); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fgetpos, (FILE *__restrict __stream, + fpos_t *__restrict __pos), fgetpos64); +extern int __REDIRECT (fsetpos, + (FILE *__stream, const fpos_t *__pos), fsetpos64); +# else +# define fgetpos fgetpos64 +# define fsetpos fsetpos64 +# endif +#endif + +#ifdef __USE_LARGEFILE64 +extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); +extern __off64_t ftello64 (FILE *__stream) __wur; +extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); +extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos); +#endif + +/* Clear the error and EOF indicators for STREAM. */ +extern void clearerr (FILE *__stream) __THROW; +/* Return the EOF indicator for STREAM. */ +extern int feof (FILE *__stream) __THROW __wur; +/* Return the error indicator for STREAM. */ +extern int ferror (FILE *__stream) __THROW __wur; + +#ifdef __USE_MISC +/* Faster versions when locking is not required. */ +extern void clearerr_unlocked (FILE *__stream) __THROW; +extern int feof_unlocked (FILE *__stream) __THROW __wur; +extern int ferror_unlocked (FILE *__stream) __THROW __wur; +#endif + + +/* Print a message describing the meaning of the value of errno. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void perror (const char *__s); + + +#ifdef __USE_POSIX +/* Return the system file descriptor for STREAM. */ +extern int fileno (FILE *__stream) __THROW __wur; +#endif /* Use POSIX. */ + +#ifdef __USE_MISC +/* Faster version when locking is not required. */ +extern int fileno_unlocked (FILE *__stream) __THROW __wur; +#endif + + +#ifdef __USE_POSIX2 +/* Close a stream opened by popen and return the status of its child. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int pclose (FILE *__stream); + +/* Create a new stream connected to a pipe running the given command. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *popen (const char *__command, const char *__modes) + __attribute_malloc__ __attr_dealloc (pclose, 1) __wur; + +#endif + + +#ifdef __USE_POSIX +/* Return the name of the controlling terminal. */ +extern char *ctermid (char *__s) __THROW + __attr_access ((__write_only__, 1)); +#endif /* Use POSIX. */ + + +#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU +/* Return the name of the current user. */ +extern char *cuserid (char *__s) + __attr_access ((__write_only__, 1)); +#endif /* Use X/Open, but not issue 6. */ + + +#ifdef __USE_GNU +struct obstack; /* See . */ + +/* Write formatted output to an obstack. */ +extern int obstack_printf (struct obstack *__restrict __obstack, + const char *__restrict __format, ...) + __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))); +extern int obstack_vprintf (struct obstack *__restrict __obstack, + const char *__restrict __format, + __gnuc_va_list __args) + __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))); +#endif /* Use GNU. */ + + +#ifdef __USE_POSIX199506 +/* These are defined in POSIX.1:1996. */ + +/* Acquire ownership of STREAM. */ +extern void flockfile (FILE *__stream) __THROW; + +/* Try to acquire ownership of STREAM but do not block if it is not + possible. */ +extern int ftrylockfile (FILE *__stream) __THROW __wur; + +/* Relinquish the ownership granted for STREAM. */ +extern void funlockfile (FILE *__stream) __THROW; +#endif /* POSIX */ + +#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU +/* X/Open Issues 1-5 required getopt to be declared in this + header. It was removed in Issue 6. GNU follows Issue 6. */ +# include +#endif + +/* Slow-path routines used by the optimized inline functions in + bits/stdio.h. */ +extern int __uflow (FILE *); +extern int __overflow (FILE *, int); + +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +/* Declare all functions from bits/stdio2-decl.h first. */ +# include +#endif + +/* The following headers provide asm redirections. These redirections must + appear before the first usage of these functions, e.g. in bits/stdio.h. */ +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# include +#endif + +/* If we are compiling with optimizing read this file. It contains + several optimizing inline functions and macros. */ +#ifdef __USE_EXTERN_INLINES +# include +#endif +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +/* Now include the function definitions and redirects too. */ +# include +#endif + +__END_DECLS + +#endif /* included. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..dd11181db1b168f4beefa48df1e1af2c9baadab0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdio.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h new file mode 100644 index 0000000000000000000000000000000000000000..bf7cd438e1d6e11500210c30bfe7f82f7ae4d5f7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h @@ -0,0 +1,1037 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.20 General utilities + */ + +#ifndef _STDLIB_H + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +/* Get size_t, wchar_t and NULL from . */ +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#include + +__BEGIN_DECLS + +#define _STDLIB_H 1 + +#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H +/* XPG requires a few symbols from being defined. */ +# include +# include + +/* Define the macros also would define this way. */ +# define WEXITSTATUS(status) __WEXITSTATUS (status) +# define WTERMSIG(status) __WTERMSIG (status) +# define WSTOPSIG(status) __WSTOPSIG (status) +# define WIFEXITED(status) __WIFEXITED (status) +# define WIFSIGNALED(status) __WIFSIGNALED (status) +# define WIFSTOPPED(status) __WIFSTOPPED (status) +# ifdef __WIFCONTINUED +# define WIFCONTINUED(status) __WIFCONTINUED (status) +# endif +#endif /* X/Open or XPG7 and not included. */ + +/* _FloatN API tests for enablement. */ +#include + +/* Returned by `div'. */ +typedef struct + { + int quot; /* Quotient. */ + int rem; /* Remainder. */ + } div_t; + +/* Returned by `ldiv'. */ +#ifndef __ldiv_t_defined +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } ldiv_t; +# define __ldiv_t_defined 1 +#endif + +#if defined __USE_ISOC99 && !defined __lldiv_t_defined +/* Returned by `lldiv'. */ +__extension__ typedef struct + { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ + } lldiv_t; +# define __lldiv_t_defined 1 +#endif + + +/* The largest number rand will return (same as INT_MAX). */ +#define RAND_MAX 2147483647 + + +/* We define these the same for all machines. + Changes from this to the outside world should be done in `_exit'. */ +#define EXIT_FAILURE 1 /* Failing exit status. */ +#define EXIT_SUCCESS 0 /* Successful exit status. */ + + +/* Maximum length of a multibyte character in the current locale. */ +#define MB_CUR_MAX (__ctype_get_mb_cur_max ()) +extern size_t __ctype_get_mb_cur_max (void) __THROW __wur; + + +/* Convert a string to a floating-point number. */ +extern double atof (const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +/* Convert a string to an integer. */ +extern int atoi (const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +/* Convert a string to a long integer. */ +extern long int atol (const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; + +#ifdef __USE_ISOC99 +/* Convert a string to a long long integer. */ +__extension__ extern long long int atoll (const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +#endif + +/* Convert a string to a floating-point number. */ +extern double strtod (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); + +#ifdef __USE_ISOC99 +/* Likewise for `float' and `long double' sizes of floating-point numbers. */ +extern float strtof (const char *__restrict __nptr, + char **__restrict __endptr) __THROW __nonnull ((1)); + +extern long double strtold (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +/* Likewise for '_FloatN' and '_FloatNx'. */ + +#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float16 strtof16 (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float32 strtof32 (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float64 strtof64 (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float128 strtof128 (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float32x strtof32x (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float64x strtof64x (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern _Float128x strtof128x (const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)); +#endif + +/* Convert a string to a long integer. */ +extern long int strtol (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); +/* Convert a string to an unsigned long integer. */ +extern unsigned long int strtoul (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); + +#ifdef __USE_MISC +/* Convert a string to a quadword integer. */ +__extension__ +extern long long int strtoq (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); +/* Convert a string to an unsigned quadword integer. */ +__extension__ +extern unsigned long long int strtouq (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); +#endif /* Use misc. */ + +#ifdef __USE_ISOC99 +/* Convert a string to a quadword integer. */ +__extension__ +extern long long int strtoll (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); +/* Convert a string to an unsigned quadword integer. */ +__extension__ +extern unsigned long long int strtoull (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)); +#endif /* ISO C99 or use MISC. */ + +/* Convert a floating-point number to a string. */ +#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +extern int strfromd (char *__dest, size_t __size, const char *__format, + double __f) + __THROW __nonnull ((3)); + +extern int strfromf (char *__dest, size_t __size, const char *__format, + float __f) + __THROW __nonnull ((3)); + +extern int strfroml (char *__dest, size_t __size, const char *__format, + long double __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf16 (char *__dest, size_t __size, const char * __format, + _Float16 __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf32 (char *__dest, size_t __size, const char * __format, + _Float32 __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf64 (char *__dest, size_t __size, const char * __format, + _Float64 __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf128 (char *__dest, size_t __size, const char * __format, + _Float128 __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf32x (char *__dest, size_t __size, const char * __format, + _Float32x __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf64x (char *__dest, size_t __size, const char * __format, + _Float64x __f) + __THROW __nonnull ((3)); +#endif + +#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) +extern int strfromf128x (char *__dest, size_t __size, const char * __format, + _Float128x __f) + __THROW __nonnull ((3)); +#endif + + +#ifdef __USE_GNU +/* Parallel versions of the functions above which take the locale to + use as an additional parameter. These are GNU extensions inspired + by the POSIX.1-2008 extended locale API. */ +# include + +extern long int strtol_l (const char *__restrict __nptr, + char **__restrict __endptr, int __base, + locale_t __loc) __THROW __nonnull ((1, 4)); + +extern unsigned long int strtoul_l (const char *__restrict __nptr, + char **__restrict __endptr, + int __base, locale_t __loc) + __THROW __nonnull ((1, 4)); + +__extension__ +extern long long int strtoll_l (const char *__restrict __nptr, + char **__restrict __endptr, int __base, + locale_t __loc) + __THROW __nonnull ((1, 4)); + +__extension__ +extern unsigned long long int strtoull_l (const char *__restrict __nptr, + char **__restrict __endptr, + int __base, locale_t __loc) + __THROW __nonnull ((1, 4)); + +extern double strtod_l (const char *__restrict __nptr, + char **__restrict __endptr, locale_t __loc) + __THROW __nonnull ((1, 3)); + +extern float strtof_l (const char *__restrict __nptr, + char **__restrict __endptr, locale_t __loc) + __THROW __nonnull ((1, 3)); + +extern long double strtold_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); + +# if __HAVE_FLOAT16 +extern _Float16 strtof16_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT32 +extern _Float32 strtof32_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT64 +extern _Float64 strtof64_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT128 +extern _Float128 strtof128_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT32X +extern _Float32x strtof32x_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT64X +extern _Float64x strtof64x_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif + +# if __HAVE_FLOAT128X +extern _Float128x strtof128x_l (const char *__restrict __nptr, + char **__restrict __endptr, + locale_t __loc) + __THROW __nonnull ((1, 3)); +# endif +#endif /* GNU */ + + +#ifdef __USE_EXTERN_INLINES +__extern_inline int +__NTH (atoi (const char *__nptr)) +{ + return (int) strtol (__nptr, (char **) NULL, 10); +} +__extern_inline long int +__NTH (atol (const char *__nptr)) +{ + return strtol (__nptr, (char **) NULL, 10); +} + +# ifdef __USE_ISOC99 +__extension__ __extern_inline long long int +__NTH (atoll (const char *__nptr)) +{ + return strtoll (__nptr, (char **) NULL, 10); +} +# endif +#endif /* Optimizing and Inlining. */ + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant + digit first. Returns a pointer to static storage overwritten by the + next call. */ +extern char *l64a (long int __n) __THROW __wur; + +/* Read a number from a string S in base 64 as above. */ +extern long int a64l (const char *__s) + __THROW __attribute_pure__ __nonnull ((1)) __wur; + +#endif /* Use misc || extended X/Open. */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +# include /* we need int32_t... */ + +/* These are the functions that actually do things. The `random', `srandom', + `initstate' and `setstate' functions are those from BSD Unices. + The `rand' and `srand' functions are required by the ANSI standard. + We provide both interfaces to the same random number generator. */ +/* Return a random long integer between 0 and 2^31-1 inclusive. */ +extern long int random (void) __THROW; + +/* Seed the random number generator with the given number. */ +extern void srandom (unsigned int __seed) __THROW; + +/* Initialize the random number generator to use state buffer STATEBUF, + of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16, + 32, 64, 128 and 256, the bigger the better; values less than 8 will + cause an error and values greater than 256 will be rounded down. */ +extern char *initstate (unsigned int __seed, char *__statebuf, + size_t __statelen) __THROW __nonnull ((2)); + +/* Switch the random number generator to state buffer STATEBUF, + which should have been previously initialized by `initstate'. */ +extern char *setstate (char *__statebuf) __THROW __nonnull ((1)); + + +# ifdef __USE_MISC +/* Reentrant versions of the `random' family of functions. + These functions all use the following data structure to contain + state, rather than global state variables. */ + +struct random_data + { + int32_t *fptr; /* Front pointer. */ + int32_t *rptr; /* Rear pointer. */ + int32_t *state; /* Array of state values. */ + int rand_type; /* Type of random number generator. */ + int rand_deg; /* Degree of random number generator. */ + int rand_sep; /* Distance between front and rear. */ + int32_t *end_ptr; /* Pointer behind state table. */ + }; + +extern int random_r (struct random_data *__restrict __buf, + int32_t *__restrict __result) __THROW __nonnull ((1, 2)); + +extern int srandom_r (unsigned int __seed, struct random_data *__buf) + __THROW __nonnull ((2)); + +extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, + size_t __statelen, + struct random_data *__restrict __buf) + __THROW __nonnull ((2, 4)); + +extern int setstate_r (char *__restrict __statebuf, + struct random_data *__restrict __buf) + __THROW __nonnull ((1, 2)); +# endif /* Use misc. */ +#endif /* Use extended X/Open || misc. */ + + +/* Return a random integer between 0 and RAND_MAX inclusive. */ +extern int rand (void) __THROW; +/* Seed the random number generator with the given number. */ +extern void srand (unsigned int __seed) __THROW; + +#ifdef __USE_POSIX199506 +/* Reentrant interface according to POSIX.1. */ +extern int rand_r (unsigned int *__seed) __THROW; +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN +/* System V style 48-bit random number generator functions. */ + +/* Return non-negative, double-precision floating-point value in [0.0,1.0). */ +extern double drand48 (void) __THROW; +extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1)); + +/* Return non-negative, long integer in [0,2^31). */ +extern long int lrand48 (void) __THROW; +extern long int nrand48 (unsigned short int __xsubi[3]) + __THROW __nonnull ((1)); + +/* Return signed, long integers in [-2^31,2^31). */ +extern long int mrand48 (void) __THROW; +extern long int jrand48 (unsigned short int __xsubi[3]) + __THROW __nonnull ((1)); + +/* Seed random number generator. */ +extern void srand48 (long int __seedval) __THROW; +extern unsigned short int *seed48 (unsigned short int __seed16v[3]) + __THROW __nonnull ((1)); +extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1)); + +# ifdef __USE_MISC +/* Data structure for communication with thread safe versions. This + type is to be regarded as opaque. It's only exported because users + have to allocate objects of this type. */ +struct drand48_data + { + unsigned short int __x[3]; /* Current state. */ + unsigned short int __old_x[3]; /* Old state. */ + unsigned short int __c; /* Additive const. in congruential formula. */ + unsigned short int __init; /* Flag for initializing. */ + __extension__ unsigned long long int __a; /* Factor in congruential + formula. */ + }; + +/* Return non-negative, double-precision floating-point value in [0.0,1.0). */ +extern int drand48_r (struct drand48_data *__restrict __buffer, + double *__restrict __result) __THROW __nonnull ((1, 2)); +extern int erand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + double *__restrict __result) __THROW __nonnull ((1, 2)); + +/* Return non-negative, long integer in [0,2^31). */ +extern int lrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); +extern int nrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); + +/* Return signed, long integers in [-2^31,2^31). */ +extern int mrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); +extern int jrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); + +/* Seed random number generator. */ +extern int srand48_r (long int __seedval, struct drand48_data *__buffer) + __THROW __nonnull ((2)); + +extern int seed48_r (unsigned short int __seed16v[3], + struct drand48_data *__buffer) __THROW __nonnull ((1, 2)); + +extern int lcong48_r (unsigned short int __param[7], + struct drand48_data *__buffer) + __THROW __nonnull ((1, 2)); +# endif /* Use misc. */ +#endif /* Use misc or X/Open. */ + +/* Allocate SIZE bytes of memory. */ +extern void *malloc (size_t __size) __THROW __attribute_malloc__ + __attribute_alloc_size__ ((1)) __wur; +/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ +extern void *calloc (size_t __nmemb, size_t __size) + __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur; + +/* Re-allocate the previously allocated block + in PTR, making the new block SIZE bytes long. */ +/* __attribute_malloc__ is not used, because if realloc returns + the same pointer that was passed to it, aliasing needs to be allowed + between objects pointed by the old and new pointers. */ +extern void *realloc (void *__ptr, size_t __size) + __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2)); + +/* Free a block allocated by `malloc', `realloc' or `calloc'. */ +extern void free (void *__ptr) __THROW; + +#ifdef __USE_MISC +/* Re-allocate the previously allocated block in PTR, making the new + block large enough for NMEMB elements of SIZE bytes each. */ +/* __attribute_malloc__ is not used, because if reallocarray returns + the same pointer that was passed to it, aliasing needs to be allowed + between objects pointed by the old and new pointers. */ +extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) + __THROW __attribute_warn_unused_result__ + __attribute_alloc_size__ ((2, 3)) + __attr_dealloc_free; + +/* Add reallocarray as its own deallocator. */ +extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) + __THROW __attr_dealloc (reallocarray, 1); +#endif + +#ifdef __USE_MISC +# include +#endif /* Use misc. */ + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ + || defined __USE_MISC +/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ +extern void *valloc (size_t __size) __THROW __attribute_malloc__ + __attribute_alloc_size__ ((1)) __wur; +#endif + +#ifdef __USE_XOPEN2K +/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */ +extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) + __THROW __nonnull ((1)) __wur; +#endif + +#ifdef __USE_ISOC11 +/* ISO C variant of aligned allocation. */ +extern void *aligned_alloc (size_t __alignment, size_t __size) + __THROW __attribute_malloc__ __attribute_alloc_align__ ((1)) + __attribute_alloc_size__ ((2)) __wur; +#endif + +/* Abort execution and generate a core-dump. */ +extern void abort (void) __THROW __attribute__ ((__noreturn__)); + + +/* Register a function to be called when `exit' is called. */ +extern int atexit (void (*__func) (void)) __THROW __nonnull ((1)); + +#if defined __USE_ISOC11 || defined __USE_ISOCXX11 +/* Register a function to be called when `quick_exit' is called. */ +# ifdef __cplusplus +extern "C++" int at_quick_exit (void (*__func) (void)) + __THROW __asm ("at_quick_exit") __nonnull ((1)); +# else +extern int at_quick_exit (void (*__func) (void)) __THROW __nonnull ((1)); +# endif +#endif + +#ifdef __USE_MISC +/* Register a function to be called with the status + given to `exit' and the given argument. */ +extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) + __THROW __nonnull ((1)); +#endif + +/* Call all functions registered with `atexit' and `on_exit', + in the reverse of the order in which they were registered, + perform stdio cleanup, and terminate program execution with STATUS. */ +extern void exit (int __status) __THROW __attribute__ ((__noreturn__)); + +#if defined __USE_ISOC11 || defined __USE_ISOCXX11 +/* Call all functions registered with `at_quick_exit' in the reverse + of the order in which they were registered and terminate program + execution with STATUS. */ +extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__)); +#endif + +#ifdef __USE_ISOC99 +/* Terminate the program with STATUS without calling any of the + functions registered with `atexit' or `on_exit'. */ +extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__)); +#endif + + +/* Return the value of envariable NAME, or NULL if it doesn't exist. */ +extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur; + +#ifdef __USE_GNU +/* This function is similar to the above but returns NULL if the + programs is running with SUID or SGID enabled. */ +extern char *secure_getenv (const char *__name) + __THROW __nonnull ((1)) __wur; +#endif + +#if defined __USE_MISC || defined __USE_XOPEN +/* The SVID says this is in , but this seems a better place. */ +/* Put STRING, which is of the form "NAME=VALUE", in the environment. + If there is no `=', remove NAME from the environment. */ +extern int putenv (char *__string) __THROW __nonnull ((1)); +#endif + +#ifdef __USE_XOPEN2K +/* Set NAME to VALUE in the environment. + If REPLACE is nonzero, overwrite an existing value. */ +extern int setenv (const char *__name, const char *__value, int __replace) + __THROW __nonnull ((2)); + +/* Remove the variable NAME from the environment. */ +extern int unsetenv (const char *__name) __THROW __nonnull ((1)); +#endif + +#ifdef __USE_MISC +/* The `clearenv' was planned to be added to POSIX.1 but probably + never made it. Nevertheless the POSIX.9 standard (POSIX bindings + for Fortran 77) requires this function. */ +extern int clearenv (void) __THROW; +#endif + + +#if defined __USE_MISC \ + || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) +/* Generate a unique temporary file name from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + Always returns TEMPLATE, it's either a temporary file name or a null + string if it cannot get a unique file name. */ +extern char *mktemp (char *__template) __THROW __nonnull ((1)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Generate a unique temporary file name from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the filename unique. + Returns a file descriptor open on the file for reading and writing, + or -1 if it cannot create a uniquely-named file. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkstemp (char *__template) __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkstemp, (char *__template), mkstemp64) + __nonnull ((1)) __wur; +# else +# define mkstemp mkstemp64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkstemp64 (char *__template) __nonnull ((1)) __wur; +# endif +#endif + +#ifdef __USE_MISC +/* Similar to mkstemp, but the template can have a suffix after the + XXXXXX. The length of the suffix is specified in the second + parameter. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen), + mkstemps64) __nonnull ((1)) __wur; +# else +# define mkstemps mkstemps64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkstemps64 (char *__template, int __suffixlen) + __nonnull ((1)) __wur; +# endif +#endif + +#ifdef __USE_XOPEN2K8 +/* Create a unique temporary directory from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the directory name unique. + Returns TEMPLATE, or a null pointer if it cannot get a unique name. + The directory is created mode 700. */ +extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur; +#endif + +#ifdef __USE_GNU +/* Generate a unique temporary file name from TEMPLATE similar to + mkstemp. But allow the caller to pass additional flags which are + used in the open call to create the file.. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64) + __nonnull ((1)) __wur; +# else +# define mkostemp mkostemp64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur; +# endif + +/* Similar to mkostemp, but the template can have a suffix after the + XXXXXX. The length of the suffix is specified in the second + parameter. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkostemps (char *__template, int __suffixlen, int __flags) + __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen, + int __flags), mkostemps64) + __nonnull ((1)) __wur; +# else +# define mkostemps mkostemps64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkostemps64 (char *__template, int __suffixlen, int __flags) + __nonnull ((1)) __wur; +# endif +#endif + + +/* Execute the given line as a shell command. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int system (const char *__command) __wur; + + +#ifdef __USE_GNU +/* Return a malloc'd string containing the canonical absolute name of the + existing named file. */ +extern char *canonicalize_file_name (const char *__name) + __THROW __nonnull ((1)) __attribute_malloc__ + __attr_dealloc_free __wur; +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Return the canonical absolute name of file NAME. If RESOLVED is + null, the result is malloc'd; otherwise, if the canonical name is + PATH_MAX chars or more, returns null with `errno' set to + ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, + returns the name in RESOLVED. */ +extern char *realpath (const char *__restrict __name, + char *__restrict __resolved) __THROW __wur; +#endif + + +/* Shorthand for type of comparison functions. */ +#ifndef __COMPAR_FN_T +# define __COMPAR_FN_T +typedef int (*__compar_fn_t) (const void *, const void *); + +# ifdef __USE_GNU +typedef __compar_fn_t comparison_fn_t; +# endif +#endif +#ifdef __USE_GNU +typedef int (*__compar_d_fn_t) (const void *, const void *, void *); +#endif + +/* Do a binary search for KEY in BASE, which consists of NMEMB elements + of SIZE bytes each, using COMPAR to perform the comparisons. */ +extern void *bsearch (const void *__key, const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t __compar) + __nonnull ((1, 2, 5)) __wur; + +#ifdef __USE_EXTERN_INLINES +# include +#endif + +/* Sort NMEMB elements of BASE, of SIZE bytes each, + using COMPAR to perform the comparisons. */ +extern void qsort (void *__base, size_t __nmemb, size_t __size, + __compar_fn_t __compar) __nonnull ((1, 4)); +#ifdef __USE_GNU +extern void qsort_r (void *__base, size_t __nmemb, size_t __size, + __compar_d_fn_t __compar, void *__arg) + __nonnull ((1, 4)); +#endif + + +/* Return the absolute value of X. */ +extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; +extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur; + +#ifdef __USE_ISOC99 +__extension__ extern long long int llabs (long long int __x) + __THROW __attribute__ ((__const__)) __wur; +#endif + + +/* Return the `div_t', `ldiv_t' or `lldiv_t' representation + of the value of NUMER over DENOM. */ +/* GCC may have built-ins for these someday. */ +extern div_t div (int __numer, int __denom) + __THROW __attribute__ ((__const__)) __wur; +extern ldiv_t ldiv (long int __numer, long int __denom) + __THROW __attribute__ ((__const__)) __wur; + +#ifdef __USE_ISOC99 +__extension__ extern lldiv_t lldiv (long long int __numer, + long long int __denom) + __THROW __attribute__ ((__const__)) __wur; +#endif + + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC +/* Convert floating point numbers to strings. The returned values are + valid only until another call to the same function. */ + +/* Convert VALUE to a string with NDIGIT digits and return a pointer to + this. Set *DECPT with the position of the decimal character and *SIGN + with the sign of the number. */ +extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur; + +/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT + with the position of the decimal character and *SIGN with the sign of + the number. */ +extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur; + +/* If possible convert VALUE to a string with NDIGIT significant digits. + Otherwise use exponential representation. The resulting string will + be written to BUF. */ +extern char *gcvt (double __value, int __ndigit, char *__buf) + __THROW __nonnull ((3)) __wur; +#endif + +#ifdef __USE_MISC +/* Long double versions of above functions. */ +extern char *qecvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __THROW __nonnull ((3, 4)) __wur; +extern char *qfcvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __THROW __nonnull ((3, 4)) __wur; +extern char *qgcvt (long double __value, int __ndigit, char *__buf) + __THROW __nonnull ((3)) __wur; + + +/* Reentrant version of the functions above which provide their own + buffers. */ +extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __THROW __nonnull ((3, 4, 5)); +extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __THROW __nonnull ((3, 4, 5)); + +extern int qecvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((3, 4, 5)); +extern int qfcvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((3, 4, 5)); +#endif /* misc */ + + +/* Return the length of the multibyte character + in S, which is no longer than N. */ +extern int mblen (const char *__s, size_t __n) __THROW; +/* Return the length of the given multibyte character, + putting its `wchar_t' representation in *PWC. */ +extern int mbtowc (wchar_t *__restrict __pwc, + const char *__restrict __s, size_t __n) __THROW; +/* Put the multibyte character represented + by WCHAR in S, returning its length. */ +extern int wctomb (char *__s, wchar_t __wchar) __THROW; + + +/* Convert a multibyte string to a wide char string. */ +extern size_t mbstowcs (wchar_t *__restrict __pwcs, + const char *__restrict __s, size_t __n) __THROW + __attr_access ((__read_only__, 2)); +/* Convert a wide char string to multibyte string. */ +extern size_t wcstombs (char *__restrict __s, + const wchar_t *__restrict __pwcs, size_t __n) + __THROW + __fortified_attr_access (__write_only__, 1, 3) + __attr_access ((__read_only__, 2)); + +#ifdef __USE_MISC +/* Determine whether the string value of RESPONSE matches the affirmation + or negative response expression as specified by the LC_MESSAGES category + in the program's current locale. Returns 1 if affirmative, 0 if + negative, and -1 if not matching. */ +extern int rpmatch (const char *__response) __THROW __nonnull ((1)) __wur; +#endif + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Parse comma separated suboption from *OPTIONP and match against + strings in TOKENS. If found return index and set *VALUEP to + optional value introduced by an equal sign. If the suboption is + not part of TOKENS return in *VALUEP beginning of unknown + suboption. On exit *OPTIONP is set to the beginning of the next + token or at the terminating NUL character. */ +extern int getsubopt (char **__restrict __optionp, + char *const *__restrict __tokens, + char **__restrict __valuep) + __THROW __nonnull ((1, 2, 3)) __wur; +#endif + + +/* X/Open pseudo terminal handling. */ + +#ifdef __USE_XOPEN2KXSI +/* Return a master pseudo-terminal handle. */ +extern int posix_openpt (int __oflag) __wur; +#endif + +#ifdef __USE_XOPEN_EXTENDED +/* The next four functions all take a master pseudo-tty fd and + perform an operation on the associated slave: */ + +/* Chown the slave to the calling user. */ +extern int grantpt (int __fd) __THROW; + +/* Release an internal lock so the slave can be opened. + Call after grantpt(). */ +extern int unlockpt (int __fd) __THROW; + +/* Return the pathname of the pseudo terminal slave associated with + the master FD is open on, or NULL on errors. + The returned storage is good until the next call to this function. */ +extern char *ptsname (int __fd) __THROW __wur; +#endif + +#ifdef __USE_GNU +/* Store at most BUFLEN characters of the pathname of the slave pseudo + terminal associated with the master FD is open on in BUF. + Return 0 on success, otherwise an error number. */ +extern int ptsname_r (int __fd, char *__buf, size_t __buflen) + __THROW __nonnull ((2)) __fortified_attr_access (__write_only__, 2, 3); + +/* Open a master pseudo terminal and return its file descriptor. */ +extern int getpt (void); +#endif + +#ifdef __USE_MISC +/* Put the 1 minute, 5 minute and 15 minute load averages into the first + NELEM elements of LOADAVG. Return the number written (never more than + three, but may be less than NELEM), or -1 if an error occurred. */ +extern int getloadavg (double __loadavg[], int __nelem) + __THROW __nonnull ((1)); +#endif + +#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K +/* Return the index into the active-logins file (utmp) for + the controlling terminal. */ +extern int ttyslot (void) __THROW; +#endif + +#include + +/* Define some macros helping to catch buffer overflows. */ +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +# include +#endif + +#include +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# include +#endif + +__END_DECLS + +#endif /* stdlib.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6aa34b3aeec7bb085e7cd01d62216b3b0009b5cb Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@stdlib.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h new file mode 100644 index 0000000000000000000000000000000000000000..d494a1d5f9ea13f93dacecc8d1be3843ad8bd891 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h @@ -0,0 +1,541 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.21 String handling + */ + +#ifndef _STRING_H +#define _STRING_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +__BEGIN_DECLS + +/* Get size_t and NULL from . */ +#define __need_size_t +#define __need_NULL +#include + +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && (__GNUC_PREREQ (4, 4) \ + || __glibc_clang_prereq (3, 5)) +# define __CORRECT_ISO_CPP_STRING_H_PROTO +#endif + + +/* Copy N bytes of SRC to DEST. */ +extern void *memcpy (void *__restrict __dest, const void *__restrict __src, + size_t __n) __THROW __nonnull ((1, 2)); +/* Copy N bytes of SRC to DEST, guaranteeing + correct behavior for overlapping strings. */ +extern void *memmove (void *__dest, const void *__src, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Copy no more than N bytes of SRC to DEST, stopping when C is found. + Return the position in DEST one byte past where C was copied, + or NULL if C was not found in the first N bytes of SRC. */ +#if defined __USE_MISC || defined __USE_XOPEN || __GLIBC_USE (ISOC2X) +extern void *memccpy (void *__restrict __dest, const void *__restrict __src, + int __c, size_t __n) + __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 4)); +#endif /* Misc || X/Open. */ + + +/* Set N bytes of S to C. */ +extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); + +/* Compare N bytes of S1 and S2. */ +extern int memcmp (const void *__s1, const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare N bytes of S1 and S2. Return zero if S1 and S2 are equal. + Return some non-zero value otherwise. + + Essentially __memcmpeq has the exact same semantics as memcmp + except the return value is less constrained. memcmp is always a + correct implementation of __memcmpeq. As well !!memcmp, -memcmp, + or bcmp are correct implementations. + + __memcmpeq is meant to be used by compilers when memcmp return is + only used for its bolean value. + + __memcmpeq is declared only for use by compilers. Programs should + continue to use memcmp. */ +extern int __memcmpeq (const void *__s1, const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Search N bytes of S for C. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern void *memchr (void *__s, int __c, size_t __n) + __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); +extern const void *memchr (const void *__s, int __c, size_t __n) + __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline void * +memchr (void *__s, int __c, size_t __n) __THROW +{ + return __builtin_memchr (__s, __c, __n); +} + +__extern_always_inline const void * +memchr (const void *__s, int __c, size_t __n) __THROW +{ + return __builtin_memchr (__s, __c, __n); +} +# endif +} +#else +extern void *memchr (const void *__s, int __c, size_t __n) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + +#ifdef __USE_GNU +/* Search in S for C. This is similar to `memchr' but there is no + length limit. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" void *rawmemchr (void *__s, int __c) + __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1)); +extern "C++" const void *rawmemchr (const void *__s, int __c) + __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1)); +# else +extern void *rawmemchr (const void *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif + +/* Search N bytes of S for the final occurrence of C. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" void *memrchr (void *__s, int __c, size_t __n) + __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)) + __attr_access ((__read_only__, 1, 3)); +extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) + __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)) + __attr_access ((__read_only__, 1, 3)); +# else +extern void *memrchr (const void *__s, int __c, size_t __n) + __THROW __attribute_pure__ __nonnull ((1)) + __attr_access ((__read_only__, 1, 3)); +# endif +#endif + + +/* Copy SRC to DEST. */ +extern char *strcpy (char *__restrict __dest, const char *__restrict __src) + __THROW __nonnull ((1, 2)); +/* Copy no more than N characters of SRC to DEST. */ +extern char *strncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Append SRC onto DEST. */ +extern char *strcat (char *__restrict __dest, const char *__restrict __src) + __THROW __nonnull ((1, 2)); +/* Append no more than N characters from SRC onto DEST. */ +extern char *strncat (char *__restrict __dest, const char *__restrict __src, + size_t __n) __THROW __nonnull ((1, 2)); + +/* Compare S1 and S2. */ +extern int strcmp (const char *__s1, const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Compare N characters of S1 and S2. */ +extern int strncmp (const char *__s1, const char *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare the collated forms of S1 and S2. */ +extern int strcoll (const char *__s1, const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Put a transformation of SRC into no more than N bytes of DEST. */ +extern size_t strxfrm (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3)); + +#ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extended locale interface (see locale.h). */ +# include + +/* Compare the collated forms of S1 and S2, using sorting rules from L. */ +extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l) + __THROW __attribute_pure__ __nonnull ((1, 2, 3)); +/* Put a transformation of SRC into no more than N bytes of DEST, + using sorting rules from L. */ +extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, + locale_t __l) __THROW __nonnull ((2, 4)) + __attr_access ((__write_only__, 1, 3)); +#endif + +#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \ + || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X)) +/* Duplicate S, returning an identical malloc'd string. */ +extern char *strdup (const char *__s) + __THROW __attribute_malloc__ __nonnull ((1)); +#endif + +/* Return a malloc'd copy of at most N bytes of STRING. The + resultant string is terminated even if no null terminator + appears before STRING[N]. */ +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X) +extern char *strndup (const char *__string, size_t __n) + __THROW __attribute_malloc__ __nonnull ((1)); +#endif + +#if defined __USE_GNU && defined __GNUC__ +/* Duplicate S, returning an identical alloca'd string. */ +# define strdupa(s) \ + (__extension__ \ + ({ \ + const char *__old = (s); \ + size_t __len = strlen (__old) + 1; \ + char *__new = (char *) __builtin_alloca (__len); \ + (char *) memcpy (__new, __old, __len); \ + })) + +/* Return an alloca'd copy of at most N bytes of string. */ +# define strndupa(s, n) \ + (__extension__ \ + ({ \ + const char *__old = (s); \ + size_t __len = strnlen (__old, (n)); \ + char *__new = (char *) __builtin_alloca (__len + 1); \ + __new[__len] = '\0'; \ + (char *) memcpy (__new, __old, __len); \ + })) +#endif + +/* Find the first occurrence of C in S. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strchr (char *__s, int __c) + __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); +extern const char *strchr (const char *__s, int __c) + __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strchr (char *__s, int __c) __THROW +{ + return __builtin_strchr (__s, __c); +} + +__extern_always_inline const char * +strchr (const char *__s, int __c) __THROW +{ + return __builtin_strchr (__s, __c); +} +# endif +} +#else +extern char *strchr (const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +#endif +/* Find the last occurrence of C in S. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strrchr (char *__s, int __c) + __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); +extern const char *strrchr (const char *__s, int __c) + __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strrchr (char *__s, int __c) __THROW +{ + return __builtin_strrchr (__s, __c); +} + +__extern_always_inline const char * +strrchr (const char *__s, int __c) __THROW +{ + return __builtin_strrchr (__s, __c); +} +# endif +} +#else +extern char *strrchr (const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + +#ifdef __USE_GNU +/* This function is similar to `strchr'. But it returns a pointer to + the closing NUL byte in case C is not found in S. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *strchrnul (char *__s, int __c) + __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1)); +extern "C++" const char *strchrnul (const char *__s, int __c) + __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1)); +# else +extern char *strchrnul (const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif +#endif + +/* Return the length of the initial segment of S which + consists entirely of characters not in REJECT. */ +extern size_t strcspn (const char *__s, const char *__reject) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Return the length of the initial segment of S which + consists entirely of characters in ACCEPT. */ +extern size_t strspn (const char *__s, const char *__accept) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Find the first occurrence in S of any character in ACCEPT. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strpbrk (char *__s, const char *__accept) + __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); +extern const char *strpbrk (const char *__s, const char *__accept) + __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strpbrk (char *__s, const char *__accept) __THROW +{ + return __builtin_strpbrk (__s, __accept); +} + +__extern_always_inline const char * +strpbrk (const char *__s, const char *__accept) __THROW +{ + return __builtin_strpbrk (__s, __accept); +} +# endif +} +#else +extern char *strpbrk (const char *__s, const char *__accept) + __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strstr (char *__haystack, const char *__needle) + __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); +extern const char *strstr (const char *__haystack, const char *__needle) + __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strstr (char *__haystack, const char *__needle) __THROW +{ + return __builtin_strstr (__haystack, __needle); +} + +__extern_always_inline const char * +strstr (const char *__haystack, const char *__needle) __THROW +{ + return __builtin_strstr (__haystack, __needle); +} +# endif +} +#else +extern char *strstr (const char *__haystack, const char *__needle) + __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif + + +/* Divide S into tokens separated by characters in DELIM. */ +extern char *strtok (char *__restrict __s, const char *__restrict __delim) + __THROW __nonnull ((2)); + +/* Divide S into tokens separated by characters in DELIM. Information + passed between calls are stored in SAVE_PTR. */ +extern char *__strtok_r (char *__restrict __s, + const char *__restrict __delim, + char **__restrict __save_ptr) + __THROW __nonnull ((2, 3)); +#ifdef __USE_POSIX +extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, + char **__restrict __save_ptr) + __THROW __nonnull ((2, 3)); +#endif + +#ifdef __USE_GNU +/* Similar to `strstr' but this function ignores the case of both strings. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *strcasestr (char *__haystack, const char *__needle) + __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); +extern "C++" const char *strcasestr (const char *__haystack, + const char *__needle) + __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); +# else +extern char *strcasestr (const char *__haystack, const char *__needle) + __THROW __attribute_pure__ __nonnull ((1, 2)); +# endif +#endif + +#ifdef __USE_GNU +/* Find the first occurrence of NEEDLE in HAYSTACK. + NEEDLE is NEEDLELEN bytes long; + HAYSTACK is HAYSTACKLEN bytes long. */ +extern void *memmem (const void *__haystack, size_t __haystacklen, + const void *__needle, size_t __needlelen) + __THROW __attribute_pure__ __nonnull ((1, 3)) + __attr_access ((__read_only__, 1, 2)) + __attr_access ((__read_only__, 3, 4)); + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +extern void *__mempcpy (void *__restrict __dest, + const void *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +extern void *mempcpy (void *__restrict __dest, + const void *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +#endif + + +/* Return the length of S. */ +extern size_t strlen (const char *__s) + __THROW __attribute_pure__ __nonnull ((1)); + +#ifdef __USE_XOPEN2K8 +/* Find the length of STRING, but scan at most MAXLEN characters. + If no '\0' terminator is found in that many characters, return MAXLEN. */ +extern size_t strnlen (const char *__string, size_t __maxlen) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + + +/* Return a string describing the meaning of the `errno' code in ERRNUM. */ +extern char *strerror (int __errnum) __THROW; +#ifdef __USE_XOPEN2K +/* Reentrant version of `strerror'. + There are 2 flavors of `strerror_r', GNU which returns the string + and may or may not use the supplied temporary buffer and POSIX one + which fills the string into the buffer. + To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L + without -D_GNU_SOURCE is needed, otherwise the GNU version is + preferred. */ +# if defined __USE_XOPEN2K && !defined __USE_GNU +/* Fill BUF with a string describing the meaning of the `errno' code in + ERRNUM. */ +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (strerror_r, + (int __errnum, char *__buf, size_t __buflen), + __xpg_strerror_r) __nonnull ((2)) + __attr_access ((__write_only__, 2, 3)); +# else +extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) + __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3)); +# define strerror_r __xpg_strerror_r +# endif +# else +/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be + used. */ +extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) + __THROW __nonnull ((2)) __wur __attr_access ((__write_only__, 2, 3)); +# endif + +# ifdef __USE_GNU +/* Return a string describing the meaning of tthe error in ERR. */ +extern const char *strerrordesc_np (int __err) __THROW; +/* Return a string with the error name in ERR. */ +extern const char *strerrorname_np (int __err) __THROW; +# endif +#endif + +#ifdef __USE_XOPEN2K8 +/* Translate error number to string according to the locale L. */ +extern char *strerror_l (int __errnum, locale_t __l) __THROW; +#endif + +#ifdef __USE_MISC +# include + +/* Set N bytes of S to 0. The compiler will not delete a call to this + function, even if S is dead after the call. */ +extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1)) + __fortified_attr_access (__write_only__, 1, 2); + +/* Return the next DELIM-delimited token from *STRINGP, + terminating it with a '\0', and update *STRINGP to point past it. */ +extern char *strsep (char **__restrict __stringp, + const char *__restrict __delim) + __THROW __nonnull ((1, 2)); +#endif + +#ifdef __USE_XOPEN2K8 +/* Return a string describing the meaning of the signal number in SIG. */ +extern char *strsignal (int __sig) __THROW; + +# ifdef __USE_GNU +/* Return an abbreviation string for the signal number SIG. */ +extern const char *sigabbrev_np (int __sig) __THROW; +/* Return a string describing the meaning of the signal number in SIG, + the result is not translated. */ +extern const char *sigdescr_np (int __sig) __THROW; +# endif + +/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src) + __THROW __nonnull ((1, 2)); +extern char *stpcpy (char *__restrict __dest, const char *__restrict __src) + __THROW __nonnull ((1, 2)); + +/* Copy no more than N characters of SRC to DEST, returning the address of + the last character written into DEST. */ +extern char *__stpncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +extern char *stpncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +#endif + +#ifdef __USE_GNU +/* Compare S1 and S2 as strings holding name & indices/version numbers. */ +extern int strverscmp (const char *__s1, const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Sautee STRING briskly. */ +extern char *strfry (char *__string) __THROW __nonnull ((1)); + +/* Frobnicate N bytes of S. */ +extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1)) + __attr_access ((__read_write__, 1, 2)); + +# ifndef basename +/* Return the file name within directory of FILENAME. We don't + declare the function if the `basename' macro is available (defined + in ) which makes the XPG version of this function + available. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *basename (char *__filename) + __THROW __asm ("basename") __nonnull ((1)); +extern "C++" const char *basename (const char *__filename) + __THROW __asm ("basename") __nonnull ((1)); +# else +extern char *basename (const char *__filename) __THROW __nonnull ((1)); +# endif +# endif +#endif + +#if __GNUC_PREREQ (3,4) +# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +/* Functions with security checks. */ +# include +# endif +#endif + +__END_DECLS + +#endif /* string.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..89cf4d0c8ec14552173c1c9c6b4704054dc45272 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@string.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h new file mode 100644 index 0000000000000000000000000000000000000000..a2a2efd4f4e208231036e921a645da49f3781dd8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h @@ -0,0 +1,148 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRINGS_H +#define _STRINGS_H 1 + +#include +#define __need_size_t +#include + +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_STRINGS_H_PROTO +#endif + +__BEGIN_DECLS + +#if defined __USE_MISC || !defined __USE_XOPEN2K8 +/* Compare N bytes of S1 and S2 (same as memcmp). */ +extern int bcmp (const void *__s1, const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ +extern void bcopy (const void *__src, void *__dest, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Set N bytes of S to 0. */ +extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); + +/* Find the first occurrence of C in S (same as strchr). */ +# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO +extern "C++" +{ +extern char *index (char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); +extern const char *index (const char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ +__extern_always_inline char * +index (char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} + +__extern_always_inline const char * +index (const char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} +# endif +} +# else +extern char *index (const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif + +/* Find the last occurrence of C in S (same as strrchr). */ +# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO +extern "C++" +{ +extern char *rindex (char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); +extern const char *rindex (const char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ +__extern_always_inline char * +rindex (char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} + +__extern_always_inline const char * +rindex (const char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} +# endif +} +# else +extern char *rindex (const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif +#endif + +#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI +/* Return the position of the first bit set in I, or 0 if none are set. + The least-significant bit is position 1, the most-significant 32. */ +extern int ffs (int __i) __THROW __attribute_const__; +#endif + +/* The following two functions are non-standard but necessary for non-32 bit + platforms. */ +# ifdef __USE_MISC +extern int ffsl (long int __l) __THROW __attribute_const__; +__extension__ extern int ffsll (long long int __ll) + __THROW __attribute_const__; +# endif + +/* Compare S1 and S2, ignoring case. */ +extern int strcasecmp (const char *__s1, const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +#ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extended locale interface (see locale.h). */ +# include + +/* Compare S1 and S2, ignoring case, using collation rules from LOC. */ +extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc) + __THROW __attribute_pure__ __nonnull ((1, 2, 3)); + +/* Compare no more than N chars of S1 and S2, ignoring case, using + collation rules from LOC. */ +extern int strncasecmp_l (const char *__s1, const char *__s2, + size_t __n, locale_t __loc) + __THROW __attribute_pure__ __nonnull ((1, 2, 4)); +#endif + +__END_DECLS + +#if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \ + && defined __fortify_function +/* Functions with security checks. */ +# if defined __USE_MISC || !defined __USE_XOPEN2K8 +# include +# endif +#endif + +#endif /* strings.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c73c0c9b2d94ffe4f27e0db6a1b6df2e0cf47e2c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@strings.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h new file mode 100644 index 0000000000000000000000000000000000000000..1c2b044a0d27da18709a95f1ccecdf556434b173 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h @@ -0,0 +1,705 @@ +/* Copyright (C) 1992-2022 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_CDEFS_H +#define _SYS_CDEFS_H 1 + +/* We are almost always included from features.h. */ +#ifndef _FEATURES_H +# include +#endif + +/* The GNU libc does not support any K&R compilers or the traditional mode + of ISO C compilers anymore. Check for some of the combinations not + supported anymore. */ +#if defined __GNUC__ && !defined __STDC__ +# error "You need a ISO C conforming compiler to use the glibc headers" +#endif + +/* Some user header file might have defined this before. */ +#undef __P +#undef __PMT + +/* Compilers that lack __has_attribute may object to + #if defined __has_attribute && __has_attribute (...) + even though they do not need to evaluate the right-hand side of the &&. + Similarly for __has_builtin, etc. */ +#if (defined __has_attribute \ + && (!defined __clang_minor__ \ + || 3 < __clang_major__ + (5 <= __clang_minor__))) +# define __glibc_has_attribute(attr) __has_attribute (attr) +#else +# define __glibc_has_attribute(attr) 0 +#endif +#ifdef __has_builtin +# define __glibc_has_builtin(name) __has_builtin (name) +#else +# define __glibc_has_builtin(name) 0 +#endif +#ifdef __has_extension +# define __glibc_has_extension(ext) __has_extension (ext) +#else +# define __glibc_has_extension(ext) 0 +#endif + +#if defined __GNUC__ || defined __clang__ + +/* All functions, except those with callbacks or those that + synchronize memory, are leaf functions. */ +# if __GNUC_PREREQ (4, 6) && !defined _LIBC +# define __LEAF , __leaf__ +# define __LEAF_ATTR __attribute__ ((__leaf__)) +# else +# define __LEAF +# define __LEAF_ATTR +# endif + +/* GCC can always grok prototypes. For C++ programs we add throw() + to help it optimize the function calls. But this only works with + gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions + as non-throwing using a function attribute since programs can use + the -fexceptions options for C code as well. */ +# if !defined __cplusplus \ + && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__)) +# define __THROW __attribute__ ((__nothrow__ __LEAF)) +# define __THROWNL __attribute__ ((__nothrow__)) +# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct +# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct +# else +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4) +# if __cplusplus >= 201103L +# define __THROW noexcept (true) +# else +# define __THROW throw () +# endif +# define __THROWNL __THROW +# define __NTH(fct) __LEAF_ATTR fct __THROW +# define __NTHNL(fct) fct __THROW +# else +# define __THROW +# define __THROWNL +# define __NTH(fct) fct +# define __NTHNL(fct) fct +# endif +# endif + +#else /* Not GCC or clang. */ + +# if (defined __cplusplus \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __inline inline +# else +# define __inline /* No inline functions. */ +# endif + +# define __THROW +# define __THROWNL +# define __NTH(fct) fct + +#endif /* GCC || clang. */ + +/* These two macros are not used in glibc anymore. They are kept here + only because some other projects expect the macros to be defined. */ +#define __P(args) args +#define __PMT(args) args + +/* For these things, GCC behaves the ANSI way normally, + and the non-ANSI way under -traditional. */ + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +/* This is not a typedef so `const __ptr_t' does the right thing. */ +#define __ptr_t void * + + +/* C++ needs to know that types and declarations are C, not C++. */ +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + + +/* Fortify support. */ +#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) +#define __bos0(ptr) __builtin_object_size (ptr, 0) + +/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ +#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ + || __GNUC_PREREQ (12, 0)) +# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) +# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) +#else +# define __glibc_objsize0(__o) __bos0 (__o) +# define __glibc_objsize(__o) __bos (__o) +#endif + +/* Compile time conditions to choose between the regular, _chk and _chk_warn + variants. These conditions should get evaluated to constant and optimized + away. */ + +#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) +#define __glibc_unsigned_or_positive(__l) \ + ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ + || (__builtin_constant_p (__l) && (__l) > 0)) + +/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ + condition can be folded to a constant and if it is true, or unknown (-1) */ +#define __glibc_safe_or_unknown_len(__l, __s, __osz) \ + ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1) \ + || (__glibc_unsigned_or_positive (__l) \ + && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ + (__s), (__osz))) \ + && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz)))) + +/* Conversely, we know at compile time that the length is unsafe if the + __L * __S <= __OBJSZ condition can be folded to a constant and if it is + false. */ +#define __glibc_unsafe_len(__l, __s, __osz) \ + (__glibc_unsigned_or_positive (__l) \ + && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ + __s, __osz)) \ + && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz)) + +/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be + declared. */ + +#define __glibc_fortify(f, __l, __s, __osz, ...) \ + (__glibc_safe_or_unknown_len (__l, __s, __osz) \ + ? __ ## f ## _alias (__VA_ARGS__) \ + : (__glibc_unsafe_len (__l, __s, __osz) \ + ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \ + : __ ## f ## _chk (__VA_ARGS__, __osz))) \ + +/* Fortify function f, where object size argument passed to f is the number of + elements and not total size. */ + +#define __glibc_fortify_n(f, __l, __s, __osz, ...) \ + (__glibc_safe_or_unknown_len (__l, __s, __osz) \ + ? __ ## f ## _alias (__VA_ARGS__) \ + : (__glibc_unsafe_len (__l, __s, __osz) \ + ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ + : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ + +#if __GNUC_PREREQ (4,3) +# define __warnattr(msg) __attribute__((__warning__ (msg))) +# define __errordecl(name, msg) \ + extern void name (void) __attribute__((__error__ (msg))) +#else +# define __warnattr(msg) +# define __errordecl(name, msg) extern void name (void) +#endif + +/* Support for flexible arrays. + Headers that should use flexible arrays only if they're "real" + (e.g. only if they won't affect sizeof()) should test + #if __glibc_c99_flexarr_available. */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif __GNUC_PREREQ (2,97) || defined __clang__ +/* GCC 2.97 and clang support C99 flexible array members as an extension, + even when in C89 mode or compiling C++ (any version). */ +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif defined __GNUC__ +/* Pre-2.97 GCC did not support C99 flexible arrays but did have + an equivalent extension with slightly different notation. */ +# define __flexarr [0] +# define __glibc_c99_flexarr_available 1 +#else +/* Some other non-C99 compiler. Approximate with [1]. */ +# define __flexarr [1] +# define __glibc_c99_flexarr_available 0 +#endif + + +/* __asm__ ("xyz") is used throughout the headers to rename functions + at the assembly language level. This is wrapped by the __REDIRECT + macro, in order to support compilers that can do this some other + way. When compilers don't support asm-names at all, we have to do + preprocessor tricks instead (which don't have exactly the right + semantics, but it's the best we can do). + + Example: + int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ + +#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4) + +# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) +# ifdef __cplusplus +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __THROW __asm__ (__ASMNAME (#alias)) +# define __REDIRECT_NTHNL(name, proto, alias) \ + name proto __THROWNL __asm__ (__ASMNAME (#alias)) +# else +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __asm__ (__ASMNAME (#alias)) __THROW +# define __REDIRECT_NTHNL(name, proto, alias) \ + name proto __asm__ (__ASMNAME (#alias)) __THROWNL +# endif +# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) +# define __ASMNAME2(prefix, cname) __STRING (prefix) cname + +/* +#elif __SOME_OTHER_COMPILER__ + +# define __REDIRECT(name, proto, alias) name proto; \ + _Pragma("let " #name " = " #alias) +*/ +#endif + +/* GCC and clang have various useful declarations that can be made with + the '__attribute__' syntax. All of the ways we use this do fine if + they are omitted for compilers that don't understand it. */ +#if !(defined __GNUC__ || defined __clang__) +# define __attribute__(xyz) /* Ignore */ +#endif + +/* At some point during the gcc 2.96 development the `malloc' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__) +# define __attribute_malloc__ __attribute__ ((__malloc__)) +#else +# define __attribute_malloc__ /* Ignore */ +#endif + +/* Tell the compiler which arguments to an allocation function + indicate the size of the allocation. */ +#if __GNUC_PREREQ (4, 3) +# define __attribute_alloc_size__(params) \ + __attribute__ ((__alloc_size__ params)) +#else +# define __attribute_alloc_size__(params) /* Ignore. */ +#endif + +/* Tell the compiler which argument to an allocation function + indicates the alignment of the allocation. */ +#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__) +# define __attribute_alloc_align__(param) \ + __attribute__ ((__alloc_align__ param)) +#else +# define __attribute_alloc_align__(param) /* Ignore. */ +#endif + +/* At some point during the gcc 2.96 development the `pure' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__) +# define __attribute_pure__ __attribute__ ((__pure__)) +#else +# define __attribute_pure__ /* Ignore */ +#endif + +/* This declaration tells the compiler that the value is constant. */ +#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__) +# define __attribute_const__ __attribute__ ((__const__)) +#else +# define __attribute_const__ /* Ignore */ +#endif + +#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__) +# define __attribute_maybe_unused__ __attribute__ ((__unused__)) +#else +# define __attribute_maybe_unused__ /* Ignore */ +#endif + +/* At some point during the gcc 3.1 development the `used' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__) +# define __attribute_used__ __attribute__ ((__used__)) +# define __attribute_noinline__ __attribute__ ((__noinline__)) +#else +# define __attribute_used__ __attribute__ ((__unused__)) +# define __attribute_noinline__ /* Ignore */ +#endif + +/* Since version 3.2, gcc allows marking deprecated functions. */ +#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__) +# define __attribute_deprecated__ __attribute__ ((__deprecated__)) +#else +# define __attribute_deprecated__ /* Ignore */ +#endif + +/* Since version 4.5, gcc also allows one to specify the message printed + when a deprecated function is used. clang claims to be gcc 4.2, but + may also support this feature. */ +#if __GNUC_PREREQ (4,5) \ + || __glibc_has_extension (__attribute_deprecated_with_message__) +# define __attribute_deprecated_msg__(msg) \ + __attribute__ ((__deprecated__ (msg))) +#else +# define __attribute_deprecated_msg__(msg) __attribute_deprecated__ +#endif + +/* At some point during the gcc 2.8 development the `format_arg' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. + If several `format_arg' attributes are given for the same function, in + gcc-3.0 and older, all but the last one are ignored. In newer gccs, + all designated arguments are considered. */ +#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__) +# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) +#else +# define __attribute_format_arg__(x) /* Ignore */ +#endif + +/* At some point during the gcc 2.97 development the `strfmon' format + attribute for functions was introduced. We don't want to use it + unconditionally (although this would be possible) since it + generates warnings. */ +#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__) +# define __attribute_format_strfmon__(a,b) \ + __attribute__ ((__format__ (__strfmon__, a, b))) +#else +# define __attribute_format_strfmon__(a,b) /* Ignore */ +#endif + +/* The nonnull function attribute marks pointer parameters that + must not be NULL. This has the name __nonnull in glibc, + and __attribute_nonnull__ in files shared with Gnulib to avoid + collision with a different __nonnull in DragonFlyBSD 5.9. */ +#ifndef __attribute_nonnull__ +# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__) +# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) +# else +# define __attribute_nonnull__(params) +# endif +#endif +#ifndef __nonnull +# define __nonnull(params) __attribute_nonnull__ (params) +#endif + +/* The returns_nonnull function attribute marks the return type of the function + as always being non-null. */ +#ifndef __returns_nonnull +# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__) +# define __returns_nonnull __attribute__ ((__returns_nonnull__)) +# else +# define __returns_nonnull +# endif +#endif + +/* If fortification mode, we warn about unused results of certain + function calls which can lead to problems. */ +#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__) +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0 +# define __wur __attribute_warn_unused_result__ +# endif +#else +# define __attribute_warn_unused_result__ /* empty */ +#endif +#ifndef __wur +# define __wur /* Ignore */ +#endif + +/* Forces a function to be always inlined. */ +#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__) +/* The Linux kernel defines __always_inline in stddef.h (283d7573), and + it conflicts with this definition. Therefore undefine it first to + allow either header to be included first. */ +# undef __always_inline +# define __always_inline __inline __attribute__ ((__always_inline__)) +#else +# undef __always_inline +# define __always_inline __inline +#endif + +/* Associate error messages with the source location of the call site rather + than with the source location inside the function. */ +#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__) +# define __attribute_artificial__ __attribute__ ((__artificial__)) +#else +# define __attribute_artificial__ /* Ignore */ +#endif + +/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ + or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions + older than 4.3 may define these macros and still not guarantee GNU inlining + semantics. + + clang++ identifies itself as gcc-4.2, but has support for GNU inlining + semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and + __GNUC_GNU_INLINE__ macro definitions. */ +#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \ + || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \ + || defined __GNUC_GNU_INLINE__))) +# if defined __GNUC_STDC_INLINE__ || defined __cplusplus +# define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) +# define __extern_always_inline \ + extern __always_inline __attribute__ ((__gnu_inline__)) +# else +# define __extern_inline extern __inline +# define __extern_always_inline extern __always_inline +# endif +#endif + +#ifdef __extern_always_inline +# define __fortify_function __extern_always_inline __attribute_artificial__ +#endif + +/* GCC 4.3 and above allow passing all anonymous arguments of an + __extern_always_inline function to some other vararg function. */ +#if __GNUC_PREREQ (4,3) +# define __va_arg_pack() __builtin_va_arg_pack () +# define __va_arg_pack_len() __builtin_va_arg_pack_len () +#endif + +/* It is possible to compile containing GCC extensions even if GCC is + run in pedantic mode if the uses are carefully marked using the + `__extension__' keyword. But this is not generally available before + version 2.8. */ +#if !(__GNUC_PREREQ (2,8) || defined __clang__) +# define __extension__ /* Ignore */ +#endif + +/* __restrict is known in EGCS 1.2 and above, and in clang. + It works also in C++ mode (outside of arrays), but only when spelled + as '__restrict', not 'restrict'. */ +#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3) +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict restrict +# else +# define __restrict /* Ignore */ +# endif +#endif + +/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is + array_name[restrict] + GCC 3.1 and clang support this. + This syntax is not usable in C++ mode. */ +#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus +# define __restrict_arr __restrict +#else +# ifdef __GNUC__ +# define __restrict_arr /* Not supported in old GCC. */ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict_arr restrict +# else +/* Some other non-C99 compiler. */ +# define __restrict_arr /* Not supported. */ +# endif +# endif +#endif + +#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect) +# define __glibc_unlikely(cond) __builtin_expect ((cond), 0) +# define __glibc_likely(cond) __builtin_expect ((cond), 1) +#else +# define __glibc_unlikely(cond) (cond) +# define __glibc_likely(cond) (cond) +#endif + +#if (!defined _Noreturn \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && !(__GNUC_PREREQ (4,7) \ + || (3 < __clang_major__ + (5 <= __clang_minor__)))) +# if __GNUC_PREREQ (2,8) +# define _Noreturn __attribute__ ((__noreturn__)) +# else +# define _Noreturn +# endif +#endif + +#if __GNUC_PREREQ (8, 0) +/* Describes a char array whose address can safely be passed as the first + argument to strncpy and strncat, as the char array is not necessarily + a NUL-terminated string. */ +# define __attribute_nonstring__ __attribute__ ((__nonstring__)) +#else +# define __attribute_nonstring__ +#endif + +/* Undefine (also defined in libc-symbols.h). */ +#undef __attribute_copy__ +#if __GNUC_PREREQ (9, 0) +/* Copies attributes from the declaration or type referenced by + the argument. */ +# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg))) +#else +# define __attribute_copy__(arg) +#endif + +#if (!defined _Static_assert && !defined __cplusplus \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \ + || defined __STRICT_ANSI__)) +# define _Static_assert(expr, diagnostic) \ + extern int (*__Static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + +/* Gnulib avoids including these, as they don't work on non-glibc or + older glibc platforms. */ +#ifndef __GNULIB_CDEFS +# include +# include +#endif + +#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# ifdef __REDIRECT + +/* Alias name defined automatically. */ +# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir +# define __LDBL_REDIR_DECL(name) \ + extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined automatically, with leading underscores. */ +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name \ + __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined manually. */ +# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1 +# define __LDBL_REDIR1_DECL(name, alias) \ + extern __typeof (name) name __asm (__ASMNAME (#alias)); + +# define __LDBL_REDIR1_NTH(name, proto, alias) \ + __REDIRECT_NTH (name, proto, alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128) + +/* Unused. */ +# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl +# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth + +# else +_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform"); +# endif +#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH +# define __LDBL_COMPAT 1 +# ifdef __REDIRECT +# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias) +# define __LDBL_REDIR(name, proto) \ + __LDBL_REDIR1 (name, proto, __nldbl_##name) +# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias) +# define __LDBL_REDIR_NTH(name, proto) \ + __LDBL_REDIR1_NTH (name, proto, __nldbl_##name) +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name)); +# define __LDBL_REDIR1_DECL(name, alias) \ + extern __typeof (name) name __asm (__ASMNAME (#alias)); +# define __LDBL_REDIR_DECL(name) \ + extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name)); +# define __REDIRECT_LDBL(name, proto, alias) \ + __LDBL_REDIR1 (name, proto, __nldbl_##alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) +# endif +#endif +#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \ + || !defined __REDIRECT +# define __LDBL_REDIR1(name, proto, alias) name proto +# define __LDBL_REDIR(name, proto) name proto +# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW +# define __LDBL_REDIR_NTH(name, proto) name proto __THROW +# define __LDBL_REDIR2_DECL(name) +# define __LDBL_REDIR_DECL(name) +# ifdef __REDIRECT +# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __REDIRECT_NTH (name, proto, alias) +# endif +#endif + +/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is + intended for use in preprocessor macros. + + Note: MESSAGE must be a _single_ string; concatenation of string + literals is not supported. */ +#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5) +# define __glibc_macro_warning1(message) _Pragma (#message) +# define __glibc_macro_warning(message) \ + __glibc_macro_warning1 (GCC warning message) +#else +# define __glibc_macro_warning(msg) +#endif + +/* Generic selection (ISO C11) is a C-only feature, available in GCC + since version 4.9. Previous versions do not provide generic + selection, even though they might set __STDC_VERSION__ to 201112L, + when in -std=c11 mode. Thus, we must check for !defined __GNUC__ + when testing __STDC_VERSION__ for generic selection support. + On the other hand, Clang also defines __GNUC__, so a clang-specific + check is required to enable the use of generic selection. */ +#if !defined __cplusplus \ + && (__GNUC_PREREQ (4, 9) \ + || __glibc_has_extension (c_generic_selections) \ + || (!defined __GNUC__ && defined __STDC_VERSION__ \ + && __STDC_VERSION__ >= 201112L)) +# define __HAVE_GENERIC_SELECTION 1 +#else +# define __HAVE_GENERIC_SELECTION 0 +#endif + +#if __GNUC_PREREQ (10, 0) +/* Designates a 1-based positional argument ref-index of pointer type + that can be used to access size-index elements of the pointed-to + array according to access mode, or at least one element when + size-index is not provided: + access (access-mode, [, ]) */ +# define __attr_access(x) __attribute__ ((__access__ x)) +/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may + use the access attribute to get object sizes from function definition + arguments, so we can't use them on functions we fortify. Drop the object + size hints for such functions. */ +# if __USE_FORTIFY_LEVEL == 3 +# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o))) +# else +# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s)) +# endif +# if __GNUC_PREREQ (11, 0) +# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno))) +# else +# define __attr_access_none(argno) +# endif +#else +# define __fortified_attr_access(a, o, s) +# define __attr_access(x) +# define __attr_access_none(argno) +#endif + +#if __GNUC_PREREQ (11, 0) +/* Designates dealloc as a function to call to deallocate objects + allocated by the declared function. */ +# define __attr_dealloc(dealloc, argno) \ + __attribute__ ((__malloc__ (dealloc, argno))) +# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1) +#else +# define __attr_dealloc(dealloc, argno) +# define __attr_dealloc_free +#endif + +/* Specify that a function such as setjmp or vfork may return + twice. */ +#if __GNUC_PREREQ (4, 1) +# define __attribute_returns_twice__ __attribute__ ((__returns_twice__)) +#else +# define __attribute_returns_twice__ /* Ignore. */ +#endif + +#endif /* sys/cdefs.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..2d6d38f831a7bb721046cc00bfc8a0e6591b2a18 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@cdefs.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h new file mode 100644 index 0000000000000000000000000000000000000000..7a27bd9c8efee78f77bb09e232a4c1fca7d8c3eb --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h @@ -0,0 +1,155 @@ +/* `fd_set' type and related macros, and `select'/`pselect' declarations. + Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H 1 + +#include + +/* Get definition of needed basic types. */ +#include + +/* Get __FD_* definitions. */ +#include + +/* Get sigset_t. */ +#include + +/* Get definition of timer specification structures. */ +#include +#include +#ifdef __USE_XOPEN2K +# include +#endif + +#ifndef __suseconds_t_defined +typedef __suseconds_t suseconds_t; +# define __suseconds_t_defined +#endif + + +/* The fd_set member is required to be an array of longs. */ +typedef long int __fd_mask; + +/* Some versions of define this macros. */ +#undef __NFDBITS +/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ +#define __NFDBITS (8 * (int) sizeof (__fd_mask)) +#define __FD_ELT(d) ((d) / __NFDBITS) +#define __FD_MASK(d) ((__fd_mask) (1UL << ((d) % __NFDBITS))) + +/* fd_set for select and pselect. */ +typedef struct + { + /* XPG4.2 requires this member name. Otherwise avoid the name + from the global namespace. */ +#ifdef __USE_XOPEN + __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS]; +# define __FDS_BITS(set) ((set)->fds_bits) +#else + __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS]; +# define __FDS_BITS(set) ((set)->__fds_bits) +#endif + } fd_set; + +/* Maximum number of file descriptors in `fd_set'. */ +#define FD_SETSIZE __FD_SETSIZE + +#ifdef __USE_MISC +/* Sometimes the fd_set member is assumed to have this type. */ +typedef __fd_mask fd_mask; + +/* Number of bits per word of `fd_set' (some code assumes this is 32). */ +# define NFDBITS __NFDBITS +#endif + + +/* Access macros for `fd_set'. */ +#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp) +#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp) +#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp) +#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp) + + +__BEGIN_DECLS + +/* Check the first NFDS descriptors each in READFDS (if not NULL) for read + readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS + (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out + after waiting the interval specified therein. Returns the number of ready + descriptors, or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +#ifndef __USE_TIME_BITS64 +extern int select (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout); +#else +# ifdef __REDIRECT +extern int __REDIRECT (select, + (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout), + __select64); +# else +# define select __select64 +# endif +#endif + +#ifdef __USE_XOPEN2K +/* Same as above only that the TIMEOUT value is given with higher + resolution and a sigmask which is been set temporarily. This version + should be used. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_TIME_BITS64 +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); +# else +# ifdef __REDIRECT +extern int __REDIRECT (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), + __pselect64); +# else +# define pselect __pselect64 +# endif +# endif +#endif + + +/* Define some inlines helping to catch common problems. */ +#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__ +# include +#endif + +__END_DECLS + +#endif /* sys/select.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..72293c048b3545c7d0883812a6cf83341ddf961c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@select.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h new file mode 100644 index 0000000000000000000000000000000000000000..191d6116a1f1ec5a73e9fcebb1379d4d0c12441a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h @@ -0,0 +1,33 @@ +/* Support for single-thread optimizations. + Copyright (C) 2020-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_SINGLE_THREADED_H +#define _SYS_SINGLE_THREADED_H + +#include + +__BEGIN_DECLS + +/* If this variable is non-zero, then the current thread is the only + thread in the process image. If it is zero, the process might be + multi-threaded. */ +extern char __libc_single_threaded; + +__END_DECLS + +#endif /* _SYS_SINGLE_THREADED_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..440d75092444bd176311251d8e96de6d5f8a7681 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@single_threaded.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h new file mode 100644 index 0000000000000000000000000000000000000000..bb76babbaf21596667d9840b60bf743771a21555 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h @@ -0,0 +1,232 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * POSIX Standard: 2.6 Primitive System Data Types + */ + +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H 1 + +#include + +__BEGIN_DECLS + +#include + +#ifdef __USE_MISC +# ifndef __u_char_defined +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; +# define __u_char_defined +# endif +typedef __loff_t loff_t; +#endif + +#ifndef __ino_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __ino_t ino_t; +# else +typedef __ino64_t ino_t; +# endif +# define __ino_t_defined +#endif +#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined +typedef __ino64_t ino64_t; +# define __ino64_t_defined +#endif + +#ifndef __dev_t_defined +typedef __dev_t dev_t; +# define __dev_t_defined +#endif + +#ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +#endif + +#ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +#endif + +#ifndef __nlink_t_defined +typedef __nlink_t nlink_t; +# define __nlink_t_defined +#endif + +#ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +#endif + +#ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +#endif +#if defined __USE_LARGEFILE64 && !defined __off64_t_defined +typedef __off64_t off64_t; +# define __off64_t_defined +#endif + +#ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif + +#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \ + && !defined __id_t_defined +typedef __id_t id_t; +# define __id_t_defined +#endif + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +#ifdef __USE_MISC +# ifndef __daddr_t_defined +typedef __daddr_t daddr_t; +typedef __caddr_t caddr_t; +# define __daddr_t_defined +# endif +#endif + +#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined +typedef __key_t key_t; +# define __key_t_defined +#endif + +#if defined __USE_XOPEN || defined __USE_XOPEN2K8 +# include +#endif +#include +#include +#include + +#ifdef __USE_XOPEN +# ifndef __useconds_t_defined +typedef __useconds_t useconds_t; +# define __useconds_t_defined +# endif +# ifndef __suseconds_t_defined +typedef __suseconds_t suseconds_t; +# define __suseconds_t_defined +# endif +#endif + +#define __need_size_t +#include + +#ifdef __USE_MISC +/* Old compatibility names for C types. */ +typedef unsigned long int ulong; +typedef unsigned short int ushort; +typedef unsigned int uint; +#endif + +/* These size-specific names are used by some of the inet code. */ + +#include + +/* These were defined by ISO C without the first `_'. */ +typedef __uint8_t u_int8_t; +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; +typedef __uint64_t u_int64_t; + +#if __GNUC_PREREQ (2, 7) +typedef int register_t __attribute__ ((__mode__ (__word__))); +#else +typedef int register_t; +#endif + +/* Some code from BIND tests this macro to see if the types above are + defined. */ +#define __BIT_TYPES_DEFINED__ 1 + + +#ifdef __USE_MISC +/* In BSD is expected to define BYTE_ORDER. */ +# include + +/* It also defines `fd_set' and the FD_* macros for `select'. */ +# include +#endif /* Use misc. */ + + +#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \ + && !defined __blksize_t_defined +typedef __blksize_t blksize_t; +# define __blksize_t_defined +#endif + +/* Types from the Large File Support interface. */ +#ifndef __USE_FILE_OFFSET64 +# ifndef __blkcnt_t_defined +typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */ +# define __blkcnt_t_defined +# endif +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#else +# ifndef __blkcnt_t_defined +typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */ +# define __blkcnt_t_defined +# endif +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#endif + +#ifdef __USE_LARGEFILE64 +typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */ +typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */ +typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */ +#endif + + +/* Now add the thread types. */ +#if defined __USE_POSIX199506 || defined __USE_UNIX98 +# include +#endif + +__END_DECLS + +#endif /* sys/types.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d0d595782b7af75d898c8beb9da90e3380c23207 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@types.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h new file mode 100644 index 0000000000000000000000000000000000000000..81db73c2b58e8f5a1073f932e08044238ac1ae3a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h @@ -0,0 +1,262 @@ +/* Copyright (C) 2001-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H 1 + +#include + +#include +#include +#include + + +#ifdef __USE_MISC +# define __ctx(fld) fld +#else +# define __ctx(fld) __ ## fld +#endif + +#ifdef __x86_64__ + +/* Type for general register. */ +__extension__ typedef long long int greg_t; + +/* Number of general registers. */ +#define __NGREG 23 +#ifdef __USE_MISC +# define NGREG __NGREG +#endif + +/* Container for all general registers. */ +typedef greg_t gregset_t[__NGREG]; + +#ifdef __USE_GNU +/* Number of each register in the `gregset_t' array. */ +enum +{ + REG_R8 = 0, +# define REG_R8 REG_R8 + REG_R9, +# define REG_R9 REG_R9 + REG_R10, +# define REG_R10 REG_R10 + REG_R11, +# define REG_R11 REG_R11 + REG_R12, +# define REG_R12 REG_R12 + REG_R13, +# define REG_R13 REG_R13 + REG_R14, +# define REG_R14 REG_R14 + REG_R15, +# define REG_R15 REG_R15 + REG_RDI, +# define REG_RDI REG_RDI + REG_RSI, +# define REG_RSI REG_RSI + REG_RBP, +# define REG_RBP REG_RBP + REG_RBX, +# define REG_RBX REG_RBX + REG_RDX, +# define REG_RDX REG_RDX + REG_RAX, +# define REG_RAX REG_RAX + REG_RCX, +# define REG_RCX REG_RCX + REG_RSP, +# define REG_RSP REG_RSP + REG_RIP, +# define REG_RIP REG_RIP + REG_EFL, +# define REG_EFL REG_EFL + REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */ +# define REG_CSGSFS REG_CSGSFS + REG_ERR, +# define REG_ERR REG_ERR + REG_TRAPNO, +# define REG_TRAPNO REG_TRAPNO + REG_OLDMASK, +# define REG_OLDMASK REG_OLDMASK + REG_CR2 +# define REG_CR2 REG_CR2 +}; +#endif + +struct _libc_fpxreg +{ + unsigned short int __ctx(significand)[4]; + unsigned short int __ctx(exponent); + unsigned short int __glibc_reserved1[3]; +}; + +struct _libc_xmmreg +{ + __uint32_t __ctx(element)[4]; +}; + +struct _libc_fpstate +{ + /* 64-bit FXSAVE format. */ + __uint16_t __ctx(cwd); + __uint16_t __ctx(swd); + __uint16_t __ctx(ftw); + __uint16_t __ctx(fop); + __uint64_t __ctx(rip); + __uint64_t __ctx(rdp); + __uint32_t __ctx(mxcsr); + __uint32_t __ctx(mxcr_mask); + struct _libc_fpxreg _st[8]; + struct _libc_xmmreg _xmm[16]; + __uint32_t __glibc_reserved1[24]; +}; + +/* Structure to describe FPU registers. */ +typedef struct _libc_fpstate *fpregset_t; + +/* Context to describe whole processor state. */ +typedef struct + { + gregset_t __ctx(gregs); + /* Note that fpregs is a pointer. */ + fpregset_t __ctx(fpregs); + __extension__ unsigned long long __reserved1 [8]; +} mcontext_t; + +/* Userlevel context. */ +typedef struct ucontext_t + { + unsigned long int __ctx(uc_flags); + struct ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + sigset_t uc_sigmask; + struct _libc_fpstate __fpregs_mem; + __extension__ unsigned long long int __ssp[4]; + } ucontext_t; + +#else /* !__x86_64__ */ + +/* Type for general register. */ +typedef int greg_t; + +/* Number of general registers. */ +#define __NGREG 19 +#ifdef __USE_MISC +# define NGREG __NGREG +#endif + +/* Container for all general registers. */ +typedef greg_t gregset_t[__NGREG]; + +#ifdef __USE_GNU +/* Number of each register is the `gregset_t' array. */ +enum +{ + REG_GS = 0, +# define REG_GS REG_GS + REG_FS, +# define REG_FS REG_FS + REG_ES, +# define REG_ES REG_ES + REG_DS, +# define REG_DS REG_DS + REG_EDI, +# define REG_EDI REG_EDI + REG_ESI, +# define REG_ESI REG_ESI + REG_EBP, +# define REG_EBP REG_EBP + REG_ESP, +# define REG_ESP REG_ESP + REG_EBX, +# define REG_EBX REG_EBX + REG_EDX, +# define REG_EDX REG_EDX + REG_ECX, +# define REG_ECX REG_ECX + REG_EAX, +# define REG_EAX REG_EAX + REG_TRAPNO, +# define REG_TRAPNO REG_TRAPNO + REG_ERR, +# define REG_ERR REG_ERR + REG_EIP, +# define REG_EIP REG_EIP + REG_CS, +# define REG_CS REG_CS + REG_EFL, +# define REG_EFL REG_EFL + REG_UESP, +# define REG_UESP REG_UESP + REG_SS +# define REG_SS REG_SS +}; +#endif + +/* Definitions taken from the kernel headers. */ +struct _libc_fpreg +{ + unsigned short int __ctx(significand)[4]; + unsigned short int __ctx(exponent); +}; + +struct _libc_fpstate +{ + unsigned long int __ctx(cw); + unsigned long int __ctx(sw); + unsigned long int __ctx(tag); + unsigned long int __ctx(ipoff); + unsigned long int __ctx(cssel); + unsigned long int __ctx(dataoff); + unsigned long int __ctx(datasel); + struct _libc_fpreg _st[8]; + unsigned long int __ctx(status); +}; + +/* Structure to describe FPU registers. */ +typedef struct _libc_fpstate *fpregset_t; + +/* Context to describe whole processor state. */ +typedef struct + { + gregset_t __ctx(gregs); + /* Due to Linux's history we have to use a pointer here. The SysV/i386 + ABI requires a struct with the values. */ + fpregset_t __ctx(fpregs); + unsigned long int __ctx(oldmask); + unsigned long int __ctx(cr2); + } mcontext_t; + +/* Userlevel context. */ +typedef struct ucontext_t + { + unsigned long int __ctx(uc_flags); + struct ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + sigset_t uc_sigmask; + struct _libc_fpstate __fpregs_mem; + unsigned long int __ssp[4]; + } ucontext_t; + +#endif /* !__x86_64__ */ + +#undef __ctx + +#endif /* sys/ucontext.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..09c5b475005da4d3bc87d1bee652aec1bfe85c4a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@sys@ucontext.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h new file mode 100644 index 0000000000000000000000000000000000000000..847ac3f8c0f6ea86b12e7ae7ae9b25c1bb6b32cf --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h @@ -0,0 +1,442 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.23 Date and time + */ + +#ifndef _TIME_H +#define _TIME_H 1 + +#include + +#define __need_size_t +#define __need_NULL +#include + +/* This defines CLOCKS_PER_SEC, which is the number of processor clock + ticks per second, and possibly a number of other constants. */ +#include + +/* Many of the typedefs and structs whose official home is this header + may also need to be defined by other headers. */ +#include +#include +#include + +#if defined __USE_POSIX199309 || defined __USE_ISOC11 +# include +#endif + +#ifdef __USE_POSIX199309 +# include +# include +# include +struct sigevent; +#endif + +#ifdef __USE_XOPEN2K +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif + +#ifdef __USE_XOPEN2K8 +# include +#endif + +#ifdef __USE_ISOC11 +/* Time base values for timespec_get. */ +# define TIME_UTC 1 +#endif + +__BEGIN_DECLS + +/* Time used by the program so far (user time + system time). + The result / CLOCKS_PER_SEC is program time in seconds. */ +extern clock_t clock (void) __THROW; + +#ifndef __USE_TIME_BITS64 +/* Return the current time and put it in *TIMER if TIMER is not NULL. */ +extern time_t time (time_t *__timer) __THROW; + +/* Return the difference between TIME1 and TIME0. */ +extern double difftime (time_t __time1, time_t __time0) + __THROW __attribute__ ((__const__)); + +/* Return the `time_t' representation of TP and normalize TP. */ +extern time_t mktime (struct tm *__tp) __THROW; +#else +# ifdef __REDIRECT_NTH +extern time_t __REDIRECT_NTH (time, (time_t *__timer), __time64); +extern double __REDIRECT_NTH (difftime, (time_t __time1, time_t __time0), + __difftime64) __attribute__ ((__const__)); +extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64); +# else +# define time __time64 +# define difftime __difftime64 +# define mktime __mktime64 +# endif +#endif + +/* Format TP into S according to FORMAT. + Write no more than MAXSIZE characters and return the number + of characters written, or 0 if it would exceed MAXSIZE. */ +extern size_t strftime (char *__restrict __s, size_t __maxsize, + const char *__restrict __format, + const struct tm *__restrict __tp) __THROW; + +#ifdef __USE_XOPEN +/* Parse S according to FORMAT and store binary time information in TP. + The return value is a pointer to the first unparsed character in S. */ +extern char *strptime (const char *__restrict __s, + const char *__restrict __fmt, struct tm *__tp) + __THROW; +#endif + +#ifdef __USE_XOPEN2K8 +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ + +extern size_t strftime_l (char *__restrict __s, size_t __maxsize, + const char *__restrict __format, + const struct tm *__restrict __tp, + locale_t __loc) __THROW; +#endif + +#ifdef __USE_GNU +extern char *strptime_l (const char *__restrict __s, + const char *__restrict __fmt, struct tm *__tp, + locale_t __loc) __THROW; +#endif + + +#ifndef __USE_TIME_BITS64 +/* Return the `struct tm' representation of *TIMER + in Universal Coordinated Time (aka Greenwich Mean Time). */ +extern struct tm *gmtime (const time_t *__timer) __THROW; + +/* Return the `struct tm' representation + of *TIMER in the local timezone. */ +extern struct tm *localtime (const time_t *__timer) __THROW; + +#else +# ifdef __REDIRECT_NTH +extern struct tm*__REDIRECT_NTH (gmtime, (const time_t *__timer), __gmtime64); +extern struct tm *__REDIRECT_NTH (localtime, (const time_t *__timer), + __localtime64); +# else +# define gmtime __gmtime64 +# define localtime __localtime64 +# endif +#endif + + +#if defined __USE_POSIX || __GLIBC_USE (ISOC2X) +# ifndef __USE_TIME_BITS64 +/* Return the `struct tm' representation of *TIMER in UTC, + using *TP to store the result. */ +extern struct tm *gmtime_r (const time_t *__restrict __timer, + struct tm *__restrict __tp) __THROW; + +/* Return the `struct tm' representation of *TIMER in local time, + using *TP to store the result. */ +extern struct tm *localtime_r (const time_t *__restrict __timer, + struct tm *__restrict __tp) __THROW; +# else +# ifdef __REDIRECT_NTH +extern struct tm*__REDIRECT_NTH (gmtime_r, (const time_t *__restrict __timer, + struct tm *__restrict __tp), + __gmtime64_r); + +extern struct tm*__REDIRECT_NTH (localtime_r, (const time_t *__restrict __t, + struct tm *__restrict __tp), + __localtime64_r); +# else +# define gmtime_r __gmtime64_r +# define localtime_r __localtime_r +# endif +# endif +#endif /* POSIX || C2X */ + +/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n" + that is the representation of TP in this format. */ +extern char *asctime (const struct tm *__tp) __THROW; + +/* Equivalent to `asctime (localtime (timer))'. */ +#ifndef __USE_TIME_BITS64 +extern char *ctime (const time_t *__timer) __THROW; +#else +# ifdef __REDIRECT_NTH +extern char *__REDIRECT_NTH (ctime, (const time_t *__timer), __ctime64); +# else +# define ctime __ctime64 +# endif +#endif + +#ifdef __USE_POSIX +/* Reentrant versions of the above functions. */ + +/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n" + that is the representation of TP in this format. */ +extern char *asctime_r (const struct tm *__restrict __tp, + char *__restrict __buf) __THROW; + +/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */ +#ifndef __USE_TIME_BITS64 +extern char *ctime_r (const time_t *__restrict __timer, + char *__restrict __buf) __THROW; +#else +# ifdef __REDIRECT_NTH +extern char *__REDIRECT_NTH (ctime_r, (const time_t *__restrict __timer, + char *__restrict __buf), __ctime64_r); +# else +# define ctime_r __ctime64_r +# endif +#endif + +#endif /* POSIX */ + + +/* Defined in localtime.c. */ +extern char *__tzname[2]; /* Current timezone names. */ +extern int __daylight; /* If daylight-saving time is ever in use. */ +extern long int __timezone; /* Seconds west of UTC. */ + + +#ifdef __USE_POSIX +/* Same as above. */ +extern char *tzname[2]; + +/* Set time conversion information from the TZ environment variable. + If TZ is not defined, a locale-dependent default is used. */ +extern void tzset (void) __THROW; +#endif + +#if defined __USE_MISC || defined __USE_XOPEN +extern int daylight; +extern long int timezone; +#endif + + +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +#define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) + + +#ifdef __USE_MISC +/* Miscellaneous functions many Unices inherited from the public domain + localtime package. These are included only for compatibility. */ + +#ifndef __USE_TIME_BITS64 +/* Like `mktime', but for TP represents Universal Time, not local time. */ +extern time_t timegm (struct tm *__tp) __THROW; +/* Another name for `mktime'. */ +extern time_t timelocal (struct tm *__tp) __THROW; +#else +# ifdef __REDIRECT_NTH +extern time_t __REDIRECT_NTH (timegm, (struct tm *__tp), __timegm64); +extern time_t __REDIRECT_NTH (timelocal, (struct tm *__tp), __mktime64); +# else +# define timegm __timegm64 +# endif +#endif + +/* Return the number of days in YEAR. */ +extern int dysize (int __year) __THROW __attribute__ ((__const__)); +#endif + + +#ifdef __USE_POSIX199309 +# ifndef __USE_TIME_BITS64 +/* Pause execution for a number of nanoseconds. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int nanosleep (const struct timespec *__requested_time, + struct timespec *__remaining); + +/* Get resolution of clock CLOCK_ID. */ +extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW; + +/* Get current value of clock CLOCK_ID and store it in TP. */ +extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW; + +/* Set clock CLOCK_ID to value TP. */ +extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) + __THROW; +# else +# ifdef __REDIRECT +extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time, + struct timespec *__remaining), + __nanosleep64); +extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id, + struct timespec *__res), + __clock_getres64); +extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct + timespec *__tp), __clock_gettime64); +extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct + timespec *__tp), __clock_settime64); +# else +# define nanosleep __nanosleep64 +# define clock_getres __clock_getres64 +# define clock_gettime __clock_gettime64 +# define clock_settime __clock_settime64 +# endif +# endif + + +# ifdef __USE_XOPEN2K +/* High-resolution sleep with the specified clock. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_TIME_BITS64 +extern int clock_nanosleep (clockid_t __clock_id, int __flags, + const struct timespec *__req, + struct timespec *__rem); +# else +# ifdef __REDIRECT +extern int __REDIRECT (clock_nanosleep, (clockid_t __clock_id, int __flags, + const struct timespec *__req, + struct timespec *__rem), + __clock_nanosleep_time64); +# else +# define clock_nanosleep __clock_nanosleep_time64 +# endif +# endif + +/* Return clock ID for CPU-time clock. */ +extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW; +# endif + + +/* Create new per-process timer using CLOCK_ID. */ +extern int timer_create (clockid_t __clock_id, + struct sigevent *__restrict __evp, + timer_t *__restrict __timerid) __THROW; + +/* Delete timer TIMERID. */ +extern int timer_delete (timer_t __timerid) __THROW; + +/* Set timer TIMERID to VALUE, returning old value in OVALUE. */ +# ifndef __USE_TIME_BITS64 +extern int timer_settime (timer_t __timerid, int __flags, + const struct itimerspec *__restrict __value, + struct itimerspec *__restrict __ovalue) __THROW; + +/* Get current value of timer TIMERID and store it in VALUE. */ +extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) + __THROW; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (timer_settime, (timer_t __timerid, int __flags, + const struct itimerspec *__restrict __value, + struct itimerspec *__restrict __ovalue), + __timer_settime64); + +extern int __REDIRECT_NTH (timer_gettime, (timer_t __timerid, + struct itimerspec *__value), + __timer_gettime64); +# else +# define timer_settime __timer_settime64 +# define timer_gettime __timer_gettime64 +# endif +# endif + +/* Get expiration overrun for timer TIMERID. */ +extern int timer_getoverrun (timer_t __timerid) __THROW; +#endif + + +#ifdef __USE_ISOC11 +# ifndef __USE_TIME_BITS64 +/* Set TS to calendar time based in time base BASE. */ +extern int timespec_get (struct timespec *__ts, int __base) + __THROW __nonnull ((1)); +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (timespec_get, (struct timespec *__ts, int __base), + __timespec_get64) __nonnull ((1)); +# else +# define timespec_get __timespec_get64 +# endif +# endif +#endif + + +#if __GLIBC_USE (ISOC2X) +# ifndef __USE_TIME_BITS64 +/* Set TS to resolution of time base BASE. */ +extern int timespec_getres (struct timespec *__ts, int __base) + __THROW; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (timespec_getres, (struct timespec *__ts, + int __base), + __timespec_getres64); +# else +# define timespec_getres __timespec_getres64 +# endif +# endif +#endif + + +#ifdef __USE_XOPEN_EXTENDED +/* Set to one of the following values to indicate an error. + 1 the DATEMSK environment variable is null or undefined, + 2 the template file cannot be opened for reading, + 3 failed to get file status information, + 4 the template file is not a regular file, + 5 an error is encountered while reading the template file, + 6 memory allication failed (not enough memory available), + 7 there is no line in the template that matches the input, + 8 invalid input specification Example: February 31 or a time is + specified that can not be represented in a time_t (representing + the time in seconds since 00:00:00 UTC, January 1, 1970) */ +extern int getdate_err; + +/* Parse the given string as a date specification and return a value + representing the value. The templates from the file identified by + the environment variable DATEMSK are used. In case of an error + `getdate_err' is set. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct tm *getdate (const char *__string); +#endif + +#ifdef __USE_GNU +/* Since `getdate' is not reentrant because of the use of `getdate_err' + and the static buffer to return the result in, we provide a thread-safe + variant. The functionality is the same. The result is returned in + the buffer pointed to by RESBUFP and in case of an error the return + value is != 0 with the same values as given above for `getdate_err'. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getdate_r (const char *__restrict __string, + struct tm *__restrict __resbufp); +#endif + +__END_DECLS + +#endif /* time.h. */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..59dfc9a328cb1fbab50c68c5af4504d7f97a5f34 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@time.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h new file mode 100644 index 0000000000000000000000000000000000000000..051cdcbeb5082cc7e27ed08398da1c685f6297e4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h @@ -0,0 +1,67 @@ +/* Copyright (C) 2011-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C11 Standard: 7.28 + * Unicode utilities + */ + +#ifndef _UCHAR_H +#define _UCHAR_H 1 + +#include + +#define __need_size_t +#include + +#include +#include + +#ifndef __USE_ISOCXX11 +/* Define the 16-bit and 32-bit character types. */ +typedef __uint_least16_t char16_t; +typedef __uint_least32_t char32_t; +#endif + + +__BEGIN_DECLS + +/* Write char16_t representation of multibyte character pointed + to by S to PC16. */ +extern size_t mbrtoc16 (char16_t *__restrict __pc16, + const char *__restrict __s, size_t __n, + mbstate_t *__restrict __p) __THROW; + +/* Write multibyte representation of char16_t C16 to S. */ +extern size_t c16rtomb (char *__restrict __s, char16_t __c16, + mbstate_t *__restrict __ps) __THROW; + + + +/* Write char32_t representation of multibyte character pointed + to by S to PC32. */ +extern size_t mbrtoc32 (char32_t *__restrict __pc32, + const char *__restrict __s, size_t __n, + mbstate_t *__restrict __p) __THROW; + +/* Write multibyte representation of char32_t C32 to S. */ +extern size_t c32rtomb (char *__restrict __s, char32_t __c32, + mbstate_t *__restrict __ps) __THROW; + +__END_DECLS + +#endif /* uchar.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0217f13edf13d6fd472a550fb2fe4bfb5799f84f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@uchar.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h new file mode 100644 index 0000000000000000000000000000000000000000..764d914cea1d22ed1a9d0d60b00d9c97f4560a0f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h @@ -0,0 +1,1222 @@ +/* Copyright (C) 1991-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * POSIX Standard: 2.10 Symbolic Constants + */ + +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +#include + +__BEGIN_DECLS + +/* These may be used to determine what facilities are present at compile time. + Their values can be obtained at run time from `sysconf'. */ + +#ifdef __USE_XOPEN2K8 +/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. */ +# define _POSIX_VERSION 200809L +#elif defined __USE_XOPEN2K +/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */ +# define _POSIX_VERSION 200112L +#elif defined __USE_POSIX199506 +/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995. */ +# define _POSIX_VERSION 199506L +#elif defined __USE_POSIX199309 +/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993. */ +# define _POSIX_VERSION 199309L +#else +/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990. */ +# define _POSIX_VERSION 199009L +#endif + +/* These are not #ifdef __USE_POSIX2 because they are + in the theoretically application-owned namespace. */ + +#ifdef __USE_XOPEN2K8 +# define __POSIX2_THIS_VERSION 200809L +/* The utilities on GNU systems also correspond to this version. */ +#elif defined __USE_XOPEN2K +/* The utilities on GNU systems also correspond to this version. */ +# define __POSIX2_THIS_VERSION 200112L +#elif defined __USE_POSIX199506 +/* The utilities on GNU systems also correspond to this version. */ +# define __POSIX2_THIS_VERSION 199506L +#else +/* The utilities on GNU systems also correspond to this version. */ +# define __POSIX2_THIS_VERSION 199209L +#endif + +/* The utilities on GNU systems also correspond to this version. */ +#define _POSIX2_VERSION __POSIX2_THIS_VERSION + +/* This symbol was required until the 2001 edition of POSIX. */ +#define _POSIX2_C_VERSION __POSIX2_THIS_VERSION + +/* If defined, the implementation supports the + C Language Bindings Option. */ +#define _POSIX2_C_BIND __POSIX2_THIS_VERSION + +/* If defined, the implementation supports the + C Language Development Utilities Option. */ +#define _POSIX2_C_DEV __POSIX2_THIS_VERSION + +/* If defined, the implementation supports the + Software Development Utilities Option. */ +#define _POSIX2_SW_DEV __POSIX2_THIS_VERSION + +/* If defined, the implementation supports the + creation of locales with the localedef utility. */ +#define _POSIX2_LOCALEDEF __POSIX2_THIS_VERSION + +/* X/Open version number to which the library conforms. It is selectable. */ +#ifdef __USE_XOPEN2K8 +# define _XOPEN_VERSION 700 +#elif defined __USE_XOPEN2K +# define _XOPEN_VERSION 600 +#elif defined __USE_UNIX98 +# define _XOPEN_VERSION 500 +#else +# define _XOPEN_VERSION 4 +#endif + +/* Commands and utilities from XPG4 are available. */ +#define _XOPEN_XCU_VERSION 4 + +/* We are compatible with the old published standards as well. */ +#define _XOPEN_XPG2 1 +#define _XOPEN_XPG3 1 +#define _XOPEN_XPG4 1 + +/* The X/Open Unix extensions are available. */ +#define _XOPEN_UNIX 1 + +/* The enhanced internationalization capabilities according to XPG4.2 + are present. */ +#define _XOPEN_ENH_I18N 1 + +/* The legacy interfaces are also available. */ +#define _XOPEN_LEGACY 1 + + +/* Get values of POSIX options: + + If these symbols are defined, the corresponding features are + always available. If not, they may be available sometimes. + The current values can be obtained with `sysconf'. + + _POSIX_JOB_CONTROL Job control is supported. + _POSIX_SAVED_IDS Processes have a saved set-user-ID + and a saved set-group-ID. + _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. + _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. + _POSIX_TIMERS POSIX.4 clocks and timers are supported. + _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. + _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. + _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. + _POSIX_FSYNC The fsync function is present. + _POSIX_MAPPED_FILES Mapping of files to memory is supported. + _POSIX_MEMLOCK Locking of all memory is supported. + _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. + _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. + _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. + _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. + _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. + _POSIX_THREADS POSIX.1c pthreads are supported. + _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. + _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. + _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. + _POSIX_THREAD_PRIORITY_SCHEDULING + POSIX.1c thread execution scheduling supported. + _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. + _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. + _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. + _POSIX_PII Protocol-independent interfaces are supported. + _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. + _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. + _POSIX_PII_INTERNET Internet family of protocols supported. + _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. + _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. + _POSIX_PII_OSI ISO/OSI family of protocols supported. + _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. + _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. + _POSIX_POLL Implementation supports `poll' function. + _POSIX_SELECT Implementation supports `select' and `pselect'. + + _XOPEN_REALTIME X/Open realtime support is available. + _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. + _XOPEN_SHM Shared memory interface according to XPG4.2. + + _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit + int, long, pointer, and off_t types. + _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit + int, long, and pointer and off_t with at least + 64 bits. + _XBS5_LP64_OFF64 Implementation provides environment with 32-bit + int, and 64-bit long, pointer, and off_t types. + _XBS5_LPBIG_OFFBIG Implementation provides environment with at + least 32 bits int and long, pointer, and off_t + with at least 64 bits. + + If any of these symbols is defined as -1, the corresponding option is not + true for any file. If any is defined as other than -1, the corresponding + option is true for all files. If a symbol is not defined at all, the value + for a specific file can be obtained from `pathconf' and `fpathconf'. + + _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change + the owner of a file. `chown' can only be used + to change the group ID of a file to a group of + which the calling process is a member. + _POSIX_NO_TRUNC Pathname components longer than + NAME_MAX generate an error. + _POSIX_VDISABLE If defined, if the value of an element of the + `c_cc' member of `struct termios' is + _POSIX_VDISABLE, no character will have the + effect associated with that element. + _POSIX_SYNC_IO Synchronous I/O may be performed. + _POSIX_ASYNC_IO Asynchronous I/O may be performed. + _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. + + Support for the Large File Support interface is not generally available. + If it is available the following constants are defined to one. + _LFS64_LARGEFILE Low-level I/O supports large files. + _LFS64_STDIO Standard I/O supports large files. + */ + +#include + +/* Get the environment definitions from Unix98. */ +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +# include +#endif + +/* Standard file descriptors. */ +#define STDIN_FILENO 0 /* Standard input. */ +#define STDOUT_FILENO 1 /* Standard output. */ +#define STDERR_FILENO 2 /* Standard error output. */ + + +/* All functions that are not declared anywhere else. */ + +#include + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +#define __need_size_t +#define __need_NULL +#include + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +/* The Single Unix specification says that some more types are + available here. */ +# ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +# endif + +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif + +# ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +# endif +# if defined __USE_LARGEFILE64 && !defined __off64_t_defined +typedef __off64_t off64_t; +# define __off64_t_defined +# endif + +# ifndef __useconds_t_defined +typedef __useconds_t useconds_t; +# define __useconds_t_defined +# endif + +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif /* X/Open */ + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K +# ifndef __intptr_t_defined +typedef __intptr_t intptr_t; +# define __intptr_t_defined +# endif +#endif + +#if defined __USE_MISC || defined __USE_XOPEN +# ifndef __socklen_t_defined +typedef __socklen_t socklen_t; +# define __socklen_t_defined +# endif +#endif + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ + +/* Test for access to NAME using the real UID and real GID. */ +extern int access (const char *__name, int __type) __THROW __nonnull ((1)); + +#ifdef __USE_GNU +/* Test for access to NAME using the effective UID and GID + (as normal file operations use). */ +extern int euidaccess (const char *__name, int __type) + __THROW __nonnull ((1)); + +/* An alias for `euidaccess', used by some other systems. */ +extern int eaccess (const char *__name, int __type) + __THROW __nonnull ((1)); + +/* Execute program relative to a directory file descriptor. */ +extern int execveat (int __fd, const char *__path, char *const __argv[], + char *const __envp[], int __flags) + __THROW __nonnull ((2, 3)); +#endif + +#ifdef __USE_ATFILE +/* Test for access to FILE relative to the directory FD is open on. + If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', + otherwise use real IDs like `access'. */ +extern int faccessat (int __fd, const char *__file, int __type, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use GNU. */ + + +/* Values for the WHENCE argument to lseek. */ +#ifndef _STDIO_H /* has the same definitions. */ +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Seek from end of file. */ +# ifdef __USE_GNU +# define SEEK_DATA 3 /* Seek to next data. */ +# define SEEK_HOLE 4 /* Seek to next hole. */ +# endif +#endif + +#if defined __USE_MISC && !defined L_SET +/* Old BSD names for the same constants; just for compatibility. */ +# define L_SET SEEK_SET +# define L_INCR SEEK_CUR +# define L_XTND SEEK_END +#endif + + +/* Move FD's file position to OFFSET bytes from the + beginning of the file (if WHENCE is SEEK_SET), + the current position (if WHENCE is SEEK_CUR), + or the end of the file (if WHENCE is SEEK_END). + Return the new file position. */ +#ifndef __USE_FILE_OFFSET64 +extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; +#else +# ifdef __REDIRECT_NTH +extern __off64_t __REDIRECT_NTH (lseek, + (int __fd, __off64_t __offset, int __whence), + lseek64); +# else +# define lseek lseek64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) + __THROW; +#endif + +/* Close the file descriptor FD. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int close (int __fd); + +#ifdef __USE_MISC +/* Close all open file descriptors greater than or equal to LOWFD. + Negative LOWFD is clamped to 0. */ +extern void closefrom (int __lowfd) __THROW; +#endif + +/* Read NBYTES into BUF from FD. Return the + number read, -1 for errors or 0 for EOF. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur + __fortified_attr_access (__write_only__, 2, 3); + +/* Write N bytes of BUF to FD. Return the number written, or -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur + __attr_access ((__read_only__, 2, 3)); + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 +# ifndef __USE_FILE_OFFSET64 +/* Read NBYTES into BUF from FD at the given position OFFSET without + changing the file pointer. Return the number read, -1 for errors + or 0 for EOF. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, + __off_t __offset) __wur + __fortified_attr_access (__write_only__, 2, 3); + +/* Write N bytes of BUF to FD at the given position OFFSET without + changing the file pointer. Return the number written, or -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, + __off_t __offset) __wur + __attr_access ((__read_only__, 2, 3)); + +# else +# ifdef __REDIRECT +extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset), + pread64) __wur + __fortified_attr_access (__write_only__, 2, 3); +extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf, + size_t __nbytes, __off64_t __offset), + pwrite64) __wur + __attr_access ((__read_only__, 2, 3)); +# else +# define pread pread64 +# define pwrite pwrite64 +# endif +# endif + +# ifdef __USE_LARGEFILE64 +/* Read NBYTES into BUF from FD at the given position OFFSET without + changing the file pointer. Return the number read, -1 for errors + or 0 for EOF. */ +extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset) __wur + __fortified_attr_access (__write_only__, 2, 3); +/* Write N bytes of BUF to FD at the given position OFFSET without + changing the file pointer. Return the number written, or -1. */ +extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n, + __off64_t __offset) __wur + __attr_access ((__read_only__, 2, 3)); +# endif +#endif + +/* Create a one-way communication channel (pipe). + If successful, two file descriptors are stored in PIPEDES; + bytes written on PIPEDES[1] can be read from PIPEDES[0]. + Returns 0 if successful, -1 if not. */ +extern int pipe (int __pipedes[2]) __THROW __wur; + +#ifdef __USE_GNU +/* Same as pipe but apply flags passed in FLAGS to the new file + descriptors. */ +extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur; +#endif + +/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. + If SECONDS is zero, any currently scheduled alarm will be cancelled. + The function returns the number of seconds remaining until the last + alarm scheduled would have signaled, or zero if there wasn't one. + There is no return value to indicate an error, but you can set `errno' + to 0 and check its value after calling `alarm', and this might tell you. + The signal may come late due to processor scheduling. */ +extern unsigned int alarm (unsigned int __seconds) __THROW; + +/* Make the process sleep for SECONDS seconds, or until a signal arrives + and is not ignored. The function returns the number of seconds less + than SECONDS which it actually slept (thus zero if it slept the full time). + If a signal handler does a `longjmp' or modifies the handling of the + SIGALRM signal while inside `sleep' call, the handling of the SIGALRM + signal afterwards is undefined. There is no return value to indicate + error, but if `sleep' returns SECONDS, it probably didn't work. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern unsigned int sleep (unsigned int __seconds); + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC +/* Set an alarm to go off (generating a SIGALRM signal) in VALUE + microseconds. If INTERVAL is nonzero, when the alarm goes off, the + timer is reset to go off every INTERVAL microseconds thereafter. + Returns the number of microseconds remaining before the alarm. */ +extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval) + __THROW; + +/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked + or ignored. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int usleep (__useconds_t __useconds); +#endif + + +/* Suspend the process until a signal arrives. + This always returns -1 and sets `errno' to EINTR. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pause (void); + + +/* Change the owner and group of FILE. */ +extern int chown (const char *__file, __uid_t __owner, __gid_t __group) + __THROW __nonnull ((1)) __wur; + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Change the owner and group of the file that FD is open on. */ +extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur; + + +/* Change owner and group of FILE, if it is a symbolic + link the ownership of the symbolic link is changed. */ +extern int lchown (const char *__file, __uid_t __owner, __gid_t __group) + __THROW __nonnull ((1)) __wur; + +#endif /* Use X/Open Unix. */ + +#ifdef __USE_ATFILE +/* Change the owner and group of FILE relative to the directory FD is open + on. */ +extern int fchownat (int __fd, const char *__file, __uid_t __owner, + __gid_t __group, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use GNU. */ + +/* Change the process's working directory to PATH. */ +extern int chdir (const char *__path) __THROW __nonnull ((1)) __wur; + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Change the process's working directory to the one FD is open on. */ +extern int fchdir (int __fd) __THROW __wur; +#endif + +/* Get the pathname of the current working directory, + and put it in SIZE bytes of BUF. Returns NULL if the + directory couldn't be determined or SIZE was too small. + If successful, returns BUF. In GNU, if BUF is NULL, + an array is allocated with `malloc'; the array is SIZE + bytes long, unless SIZE == 0, in which case it is as + big as necessary. */ +extern char *getcwd (char *__buf, size_t __size) __THROW __wur; + +#ifdef __USE_GNU +/* Return a malloc'd string containing the current directory name. + If the environment variable `PWD' is set, and its value is correct, + that value is used. */ +extern char *get_current_dir_name (void) __THROW; +#endif + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC +/* Put the absolute pathname of the current working directory in BUF. + If successful, return BUF. If not, put an error message in + BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ +extern char *getwd (char *__buf) + __THROW __nonnull ((1)) __attribute_deprecated__ __wur + __attr_access ((__write_only__, 1)); +#endif + + +/* Duplicate FD, returning a new file descriptor on the same file. */ +extern int dup (int __fd) __THROW __wur; + +/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ +extern int dup2 (int __fd, int __fd2) __THROW; + +#ifdef __USE_GNU +/* Duplicate FD to FD2, closing FD2 and making it open on the same + file while setting flags according to FLAGS. */ +extern int dup3 (int __fd, int __fd2, int __flags) __THROW; +#endif + +/* NULL-terminated array of "NAME=VALUE" environment variables. */ +extern char **__environ; +#ifdef __USE_GNU +extern char **environ; +#endif + + +/* Replace the current process, executing PATH with arguments ARGV and + environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ +extern int execve (const char *__path, char *const __argv[], + char *const __envp[]) __THROW __nonnull ((1, 2)); + +#ifdef __USE_XOPEN2K8 +/* Execute the file FD refers to, overlaying the running program image. + ARGV and ENVP are passed to the new program, as for `execve'. */ +extern int fexecve (int __fd, char *const __argv[], char *const __envp[]) + __THROW __nonnull ((2)); +#endif + + +/* Execute PATH with arguments ARGV and environment from `environ'. */ +extern int execv (const char *__path, char *const __argv[]) + __THROW __nonnull ((1, 2)); + +/* Execute PATH with all arguments after PATH until a NULL pointer, + and the argument after that for environment. */ +extern int execle (const char *__path, const char *__arg, ...) + __THROW __nonnull ((1, 2)); + +/* Execute PATH with all arguments after PATH until + a NULL pointer and environment from `environ'. */ +extern int execl (const char *__path, const char *__arg, ...) + __THROW __nonnull ((1, 2)); + +/* Execute FILE, searching in the `PATH' environment variable if it contains + no slashes, with arguments ARGV and environment from `environ'. */ +extern int execvp (const char *__file, char *const __argv[]) + __THROW __nonnull ((1, 2)); + +/* Execute FILE, searching in the `PATH' environment variable if + it contains no slashes, with all arguments after FILE until a + NULL pointer and environment from `environ'. */ +extern int execlp (const char *__file, const char *__arg, ...) + __THROW __nonnull ((1, 2)); + +#ifdef __USE_GNU +/* Execute FILE, searching in the `PATH' environment variable if it contains + no slashes, with arguments ARGV and environment from `environ'. */ +extern int execvpe (const char *__file, char *const __argv[], + char *const __envp[]) + __THROW __nonnull ((1, 2)); +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN +/* Add INC to priority of the current process. */ +extern int nice (int __inc) __THROW __wur; +#endif + + +/* Terminate program execution with the low-order 8 bits of STATUS. */ +extern void _exit (int __status) __attribute__ ((__noreturn__)); + + +/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; + the `_SC_*' symbols for the NAME argument to `sysconf'; + and the `_CS_*' symbols for the NAME argument to `confstr'. */ +#include + +/* Get file-specific configuration information about PATH. */ +extern long int pathconf (const char *__path, int __name) + __THROW __nonnull ((1)); + +/* Get file-specific configuration about descriptor FD. */ +extern long int fpathconf (int __fd, int __name) __THROW; + +/* Get the value of the system variable NAME. */ +extern long int sysconf (int __name) __THROW; + +#ifdef __USE_POSIX2 +/* Get the value of the string-valued system variable NAME. */ +extern size_t confstr (int __name, char *__buf, size_t __len) __THROW + __fortified_attr_access (__write_only__, 2, 3); +#endif + + +/* Get the process ID of the calling process. */ +extern __pid_t getpid (void) __THROW; + +/* Get the process ID of the calling process's parent. */ +extern __pid_t getppid (void) __THROW; + +/* Get the process group ID of the calling process. */ +extern __pid_t getpgrp (void) __THROW; + +/* Get the process group ID of process PID. */ +extern __pid_t __getpgid (__pid_t __pid) __THROW; +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +extern __pid_t getpgid (__pid_t __pid) __THROW; +#endif + + +/* Set the process group ID of the process matching PID to PGID. + If PID is zero, the current process's process group ID is set. + If PGID is zero, the process ID of the process is used. */ +extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW; + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Both System V and BSD have `setpgrp' functions, but with different + calling conventions. The BSD function is the same as POSIX.1 `setpgid' + (above). The System V function takes no arguments and puts the calling + process in its on group like `setpgid (0, 0)'. + + New programs should always use `setpgid' instead. + + GNU provides the POSIX.1 function. */ + +/* Set the process group ID of the calling process to its own PID. + This is exactly the same as `setpgid (0, 0)'. */ +extern int setpgrp (void) __THROW; + +#endif /* Use misc or X/Open. */ + +/* Create a new session with the calling process as its leader. + The process group IDs of the session and the calling process + are set to the process ID of the calling process, which is returned. */ +extern __pid_t setsid (void) __THROW; + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Return the session ID of the given process. */ +extern __pid_t getsid (__pid_t __pid) __THROW; +#endif + +/* Get the real user ID of the calling process. */ +extern __uid_t getuid (void) __THROW; + +/* Get the effective user ID of the calling process. */ +extern __uid_t geteuid (void) __THROW; + +/* Get the real group ID of the calling process. */ +extern __gid_t getgid (void) __THROW; + +/* Get the effective group ID of the calling process. */ +extern __gid_t getegid (void) __THROW; + +/* If SIZE is zero, return the number of supplementary groups + the calling process is in. Otherwise, fill in the group IDs + of its supplementary groups in LIST and return the number written. */ +extern int getgroups (int __size, __gid_t __list[]) __THROW __wur + __fortified_attr_access (__write_only__, 2, 1); +#ifdef __USE_GNU +/* Return nonzero iff the calling process is in group GID. */ +extern int group_member (__gid_t __gid) __THROW; +#endif + +/* Set the user ID of the calling process to UID. + If the calling process is the super-user, set the real + and effective user IDs, and the saved set-user-ID to UID; + if not, the effective user ID is set to UID. */ +extern int setuid (__uid_t __uid) __THROW __wur; + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Set the real user ID of the calling process to RUID, + and the effective user ID of the calling process to EUID. */ +extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW __wur; +#endif + +#ifdef __USE_XOPEN2K +/* Set the effective user ID of the calling process to UID. */ +extern int seteuid (__uid_t __uid) __THROW __wur; +#endif /* Use POSIX.1-2001. */ + +/* Set the group ID of the calling process to GID. + If the calling process is the super-user, set the real + and effective group IDs, and the saved set-group-ID to GID; + if not, the effective group ID is set to GID. */ +extern int setgid (__gid_t __gid) __THROW __wur; + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Set the real group ID of the calling process to RGID, + and the effective group ID of the calling process to EGID. */ +extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW __wur; +#endif + +#ifdef __USE_XOPEN2K +/* Set the effective group ID of the calling process to GID. */ +extern int setegid (__gid_t __gid) __THROW __wur; +#endif /* Use POSIX.1-2001. */ + +#ifdef __USE_GNU +/* Fetch the real user ID, effective user ID, and saved-set user ID, + of the calling process. */ +extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid) + __THROW; + +/* Fetch the real group ID, effective group ID, and saved-set group ID, + of the calling process. */ +extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid) + __THROW; + +/* Set the real user ID, effective user ID, and saved-set user ID, + of the calling process to RUID, EUID, and SUID, respectively. */ +extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid) + __THROW __wur; + +/* Set the real group ID, effective group ID, and saved-set group ID, + of the calling process to RGID, EGID, and SGID, respectively. */ +extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid) + __THROW __wur; +#endif + + +/* Clone the calling process, creating an exact copy. + Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ +extern __pid_t fork (void) __THROWNL; + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC +/* Clone the calling process, but without copying the whole address space. + The calling process is suspended until the new process exits or is + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ +extern __pid_t vfork (void) __THROW; +#endif /* Use misc or XPG < 7. */ + +#ifdef __USE_GNU +/* This is similar to fork, however it does not run the atfork handlers + neither reinitialize any internal locks in multithread case. + Different than fork, _Fork is async-signal-safe. */ +extern __pid_t _Fork (void) __THROW; +#endif + + +/* Return the pathname of the terminal FD is open on, or NULL on errors. + The returned storage is good only until the next call to this function. */ +extern char *ttyname (int __fd) __THROW; + +/* Store at most BUFLEN characters of the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +extern int ttyname_r (int __fd, char *__buf, size_t __buflen) + __THROW __nonnull ((2)) __wur + __fortified_attr_access (__write_only__, 2, 3); + +/* Return 1 if FD is a valid descriptor associated + with a terminal, zero if not. */ +extern int isatty (int __fd) __THROW; + +#ifdef __USE_MISC +/* Return the index into the active-logins file (utmp) for + the controlling terminal. */ +extern int ttyslot (void) __THROW; +#endif + + +/* Make a link to FROM named TO. */ +extern int link (const char *__from, const char *__to) + __THROW __nonnull ((1, 2)) __wur; + +#ifdef __USE_ATFILE +/* Like link but relative paths in TO and FROM are interpreted relative + to FROMFD and TOFD respectively. */ +extern int linkat (int __fromfd, const char *__from, int __tofd, + const char *__to, int __flags) + __THROW __nonnull ((2, 4)) __wur; +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K +/* Make a symbolic link to FROM named TO. */ +extern int symlink (const char *__from, const char *__to) + __THROW __nonnull ((1, 2)) __wur; + +/* Read the contents of the symbolic link PATH into no more than + LEN bytes of BUF. The contents are not null-terminated. + Returns the number of characters read, or -1 for errors. */ +extern ssize_t readlink (const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((1, 2)) __wur + __fortified_attr_access (__write_only__, 2, 3); + +#endif /* Use POSIX.1-2001. */ + +#ifdef __USE_ATFILE +/* Like symlink but a relative path in TO is interpreted relative to TOFD. */ +extern int symlinkat (const char *__from, int __tofd, + const char *__to) __THROW __nonnull ((1, 3)) __wur; + +/* Like readlink but a relative PATH is interpreted relative to FD. */ +extern ssize_t readlinkat (int __fd, const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((2, 3)) __wur + __fortified_attr_access (__write_only__, 3, 4); +#endif + +/* Remove the link NAME. */ +extern int unlink (const char *__name) __THROW __nonnull ((1)); + +#ifdef __USE_ATFILE +/* Remove the link NAME relative to FD. */ +extern int unlinkat (int __fd, const char *__name, int __flag) + __THROW __nonnull ((2)); +#endif + +/* Remove the directory PATH. */ +extern int rmdir (const char *__path) __THROW __nonnull ((1)); + + +/* Return the foreground process group ID of FD. */ +extern __pid_t tcgetpgrp (int __fd) __THROW; + +/* Set the foreground process group ID of FD set PGRP_ID. */ +extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW; + + +/* Return the login name of the user. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern char *getlogin (void); +#ifdef __USE_POSIX199506 +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occurred, return the error + code. Otherwise return 0. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1)) + __fortified_attr_access (__write_only__, 1, 2); +#endif + +#ifdef __USE_MISC +/* Set the login name returned by `getlogin'. */ +extern int setlogin (const char *__name) __THROW __nonnull ((1)); +#endif + + +#ifdef __USE_POSIX2 +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. */ +# include +#endif + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K +/* Put the name of the current host in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ +extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1)) + __fortified_attr_access (__write_only__, 1, 2); +#endif + + +#if defined __USE_MISC +/* Set the name of the current host to NAME, which is LEN bytes long. + This call is restricted to the super-user. */ +extern int sethostname (const char *__name, size_t __len) + __THROW __nonnull ((1)) __wur __attr_access ((__read_only__, 1, 2)); + +/* Set the current machine's Internet number to ID. + This call is restricted to the super-user. */ +extern int sethostid (long int __id) __THROW __wur; + + +/* Get and set the NIS (aka YP) domain name, if any. + Called just like `gethostname' and `sethostname'. + The NIS domain name is usually the empty string when not using NIS. */ +extern int getdomainname (char *__name, size_t __len) + __THROW __nonnull ((1)) __wur + __fortified_attr_access (__write_only__, 1, 2); +extern int setdomainname (const char *__name, size_t __len) + __THROW __nonnull ((1)) __wur __attr_access ((__read_only__, 1, 2)); + +/* Revoke access permissions to all processes currently communicating + with the control terminal, and then send a SIGHUP signal to the process + group of the control terminal. */ +extern int vhangup (void) __THROW; + +/* Revoke the access of all descriptors currently open on FILE. */ +extern int revoke (const char *__file) __THROW __nonnull ((1)) __wur; + + +/* Enable statistical profiling, writing samples of the PC into at most + SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling + is enabled, the system examines the user PC and increments + SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, + disable profiling. Returns zero on success, -1 on error. */ +extern int profil (unsigned short int *__sample_buffer, size_t __size, + size_t __offset, unsigned int __scale) + __THROW __nonnull ((1)); + + +/* Turn accounting on if NAME is an existing file. The system will then write + a record for each process as it terminates, to this file. If NAME is NULL, + turn accounting off. This call is restricted to the super-user. */ +extern int acct (const char *__name) __THROW; + + +/* Successive calls return the shells listed in `/etc/shells'. */ +extern char *getusershell (void) __THROW; +extern void endusershell (void) __THROW; /* Discard cached info. */ +extern void setusershell (void) __THROW; /* Rewind and re-read the file. */ + + +/* Put the program in the background, and dissociate from the controlling + terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, + redirects stdin, stdout, and stderr to /dev/null. */ +extern int daemon (int __nochdir, int __noclose) __THROW __wur; +#endif /* Use misc. */ + + +#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +/* Make PATH be the root directory (the starting point for absolute paths). + This call is restricted to the super-user. */ +extern int chroot (const char *__path) __THROW __nonnull ((1)) __wur; + +/* Prompt with PROMPT and read a string from the terminal without echoing. + Uses /dev/tty if possible; otherwise stderr and stdin. */ +extern char *getpass (const char *__prompt) __nonnull ((1)); +#endif /* Use misc || X/Open. */ + + +/* Make all changes done to FD actually appear on disk. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int fsync (int __fd); + + +#ifdef __USE_GNU +/* Make all changes done to all files on the file system associated + with FD actually appear on disk. */ +extern int syncfs (int __fd) __THROW; +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED + +/* Return identifier for the current host. */ +extern long int gethostid (void); + +/* Make all changes done to all files actually appear on disk. */ +extern void sync (void) __THROW; + + +# if defined __USE_MISC || !defined __USE_XOPEN2K +/* Return the number of bytes in a page. This is the system's page size, + which is not necessarily the same as the hardware page size. */ +extern int getpagesize (void) __THROW __attribute__ ((__const__)); + + +/* Return the maximum number of file descriptors + the current process could possibly have. */ +extern int getdtablesize (void) __THROW; +# endif + +#endif /* Use misc || X/Open Unix. */ + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 + +/* Truncate FILE to LENGTH bytes. */ +# ifndef __USE_FILE_OFFSET64 +extern int truncate (const char *__file, __off_t __length) + __THROW __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (truncate, + (const char *__file, __off64_t __length), + truncate64) __nonnull ((1)) __wur; +# else +# define truncate truncate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int truncate64 (const char *__file, __off64_t __length) + __THROW __nonnull ((1)) __wur; +# endif + +#endif /* Use X/Open Unix || POSIX 2008. */ + +#if defined __USE_POSIX199309 \ + || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K + +/* Truncate the file FD is open on to LENGTH bytes. */ +# ifndef __USE_FILE_OFFSET64 +extern int ftruncate (int __fd, __off_t __length) __THROW __wur; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length), + ftruncate64) __wur; +# else +# define ftruncate ftruncate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur; +# endif + +#endif /* Use POSIX.1b || X/Open Unix || XPG6. */ + + +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ + || defined __USE_MISC + +/* Set the end of accessible data space (aka "the break") to ADDR. + Returns zero on success and -1 for errors (with errno set). */ +extern int brk (void *__addr) __THROW __wur; + +/* Increase or decrease the end of accessible data space by DELTA bytes. + If successful, returns the address the previous end of data space + (i.e. the beginning of the new space, if DELTA > 0); + returns (void *) -1 for errors (with errno set). */ +extern void *sbrk (intptr_t __delta) __THROW; +#endif + + +#ifdef __USE_MISC +/* Invoke `system call' number SYSNO, passing it the remaining arguments. + This is completely system-dependent, and not often useful. + + In Unix, `syscall' sets `errno' for all errors and most calls return -1 + for errors; in many systems you cannot pass arguments or get return + values for all system calls (`pipe', `fork', and `getppid' typically + among them). + + In Mach, all system calls take normal arguments and always return an + error code (zero for success). */ +extern long int syscall (long int __sysno, ...) __THROW; + +#endif /* Use misc. */ + + +#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK +/* NOTE: These declarations also appear in ; be sure to keep both + files consistent. Some systems have them there and some here, and some + software depends on the macros being defined without including both. */ + +/* `lockf' is a simpler interface to the locking facilities of `fcntl'. + LEN is always relative to the current file position. + The CMD argument is one of the following. + + This function is a cancellation point and therefore not marked with + __THROW. */ + +# define F_ULOCK 0 /* Unlock a previously locked region. */ +# define F_LOCK 1 /* Lock a region for exclusive use. */ +# define F_TLOCK 2 /* Test and lock a region for exclusive use. */ +# define F_TEST 3 /* Test a region for other processes locks. */ + +# ifndef __USE_FILE_OFFSET64 +extern int lockf (int __fd, int __cmd, __off_t __len) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), + lockf64) __wur; +# else +# define lockf lockf64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur; +# endif +#endif /* Use misc and F_LOCK not already defined. */ + + +#ifdef __USE_GNU + +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno' + set to EINTR. */ + +# define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) + +/* Copy LENGTH bytes from INFD to OUTFD. */ +ssize_t copy_file_range (int __infd, __off64_t *__pinoff, + int __outfd, __off64_t *__poutoff, + size_t __length, unsigned int __flags); +#endif /* __USE_GNU */ + +#if defined __USE_POSIX199309 || defined __USE_UNIX98 +/* Synchronize at least the data part of a file with the underlying + media. */ +extern int fdatasync (int __fildes); +#endif /* Use POSIX199309 */ + +#ifdef __USE_MISC +/* One-way hash PHRASE, returning a string suitable for storage in the + user database. SALT selects the one-way function to use, and + ensures that no two users' hashes are the same, even if they use + the same passphrase. The return value points to static storage + which will be overwritten by the next call to crypt. */ +extern char *crypt (const char *__key, const char *__salt) + __THROW __nonnull ((1, 2)); +#endif + +#ifdef __USE_XOPEN +/* Swab pairs bytes in the first N bytes of the area pointed to by + FROM and copy the result to TO. The value of TO must not be in the + range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM + is without partner. */ +extern void swab (const void *__restrict __from, void *__restrict __to, + ssize_t __n) __THROW __nonnull ((1, 2)) + __attr_access ((__read_only__, 1, 3)) + __attr_access ((__write_only__, 2, 3)); +#endif + + +/* Prior to Issue 6, the Single Unix Specification required these + prototypes to appear in this header. They are also found in + . */ +#if defined __USE_XOPEN && !defined __USE_XOPEN2K +/* Return the name of the controlling terminal. */ +extern char *ctermid (char *__s) __THROW; + +/* Return the name of the current user. */ +extern char *cuserid (char *__s); +#endif + + +/* Unix98 requires this function to be declared here. In other + standards it is in . */ +#if defined __USE_UNIX98 && !defined __USE_XOPEN2K +extern int pthread_atfork (void (*__prepare) (void), + void (*__parent) (void), + void (*__child) (void)) __THROW; +#endif + +#ifdef __USE_MISC +/* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on + success or -1 on error. */ +int getentropy (void *__buffer, size_t __length) __wur + __attr_access ((__write_only__, 1, 2)); +#endif + +#ifdef __USE_GNU +/* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS + are define by the CLOSE_RANGE prefix. This function behaves like close + on the range and gaps where the file descriptor is invalid or errors + encountered while closing file descriptors are ignored. Returns 0 on + successor or -1 for failure (and sets errno accordingly). */ +extern int close_range (unsigned int __fd, unsigned int __max_fd, + int __flags) __THROW; +#endif + +/* Define some macros helping to catch buffer overflows. */ +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +# include +#endif + +/* System-specific extensions. */ +#include + +__END_DECLS + +#endif /* unistd.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d1eb6a90801beb6357369442e34f7fafb211b818 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@unistd.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h new file mode 100644 index 0000000000000000000000000000000000000000..c1321c75186ad1ed8f4d148cfff27be2354310ea --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h @@ -0,0 +1,884 @@ +/* Copyright (C) 1995-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.24 + * Extended multibyte and wide character utilities + */ + +#ifndef _WCHAR_H +#define _WCHAR_H 1 + +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include + +/* Gather machine dependent type support. */ +#include + +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#include + +#define __need___va_list +#include + +#include +#include +#include +#include + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +# include +#endif +#ifdef __USE_XOPEN2K8 +# include +#endif + +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_WCHAR_H_PROTO +#endif + +#ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +#endif + +#ifndef WEOF +# define WEOF (0xffffffffu) +#endif + +/* All versions of XPG prior to the publication of ISO C99 required + the bulk of 's declarations to appear in this header + (because did not exist prior to C99). In POSIX.1-2001 + those declarations were marked as XSI extensions; in -2008 they + were additionally marked as obsolescent. _GNU_SOURCE mode + anticipates the removal of these declarations in the next revision + of POSIX. */ +#if (defined __USE_XOPEN && !defined __USE_GNU \ + && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI)) +# include +#endif + +__BEGIN_DECLS + +/* This incomplete type is defined in but needed here because + of `wcsftime'. */ +struct tm; + + +/* Copy SRC to DEST. */ +extern wchar_t *wcscpy (wchar_t *__restrict __dest, + const wchar_t *__restrict __src) + __THROW __nonnull ((1, 2)); + +/* Copy no more than N wide-characters of SRC to DEST. */ +extern wchar_t *wcsncpy (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Append SRC onto DEST. */ +extern wchar_t *wcscat (wchar_t *__restrict __dest, + const wchar_t *__restrict __src) + __THROW __nonnull ((1, 2)); +/* Append no more than N wide-characters of SRC onto DEST. */ +extern wchar_t *wcsncat (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Compare S1 and S2. */ +extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Compare N wide-characters of S1 and S2. */ +extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +#ifdef __USE_XOPEN2K8 +/* Compare S1 and S2, ignoring case. */ +extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW; + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2, + size_t __n) __THROW; + +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ +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; +#endif + +/* Compare S1 and S2, both interpreted as appropriate to the + LC_COLLATE category of the current locale. */ +extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; +/* Transform S2 into array pointed to by S1 such that if wcscmp is + applied to two transformed strings the result is the as applying + `wcscoll' to the original strings. */ +extern size_t wcsxfrm (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, size_t __n) __THROW; + +#ifdef __USE_XOPEN2K8 +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ + +/* Compare S1 and S2, both interpreted as appropriate to the + LC_COLLATE category of the given locale. */ +extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2, + locale_t __loc) __THROW; + +/* Transform S2 into array pointed to by S1 such that if wcscmp is + applied to two transformed strings the result is the as applying + `wcscoll' to the original strings. */ +extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, + size_t __n, locale_t __loc) __THROW; + +/* Duplicate S, returning an identical malloc'd string. */ +extern wchar_t *wcsdup (const wchar_t *__s) __THROW + __attribute_malloc__ __attr_dealloc_free; +#endif + +/* Find the first occurrence of WC in WCS. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcschr") __attribute_pure__; +extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcschr") __attribute_pure__; +#else +extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; +#endif +/* Find the last occurrence of WC in WCS. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcsrchr") __attribute_pure__; +extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcsrchr") __attribute_pure__; +#else +extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; +#endif + +#ifdef __USE_GNU +/* This function is similar to `wcschr'. But it returns a pointer to + the closing NUL wide character in case C is not found in S. */ +extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc) + __THROW __attribute_pure__; +#endif + +/* Return the length of the initial segmet of WCS which + consists entirely of wide characters not in REJECT. */ +extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject) + __THROW __attribute_pure__; +/* Return the length of the initial segmet of WCS which + consists entirely of wide characters in ACCEPT. */ +extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept) + __THROW __attribute_pure__; +/* Find the first occurrence in WCS of any character in ACCEPT. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept) + __THROW __asm ("wcspbrk") __attribute_pure__; +extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs, + const wchar_t *__accept) + __THROW __asm ("wcspbrk") __attribute_pure__; +#else +extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept) + __THROW __attribute_pure__; +#endif +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle) + __THROW __asm ("wcsstr") __attribute_pure__; +extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack, + const wchar_t *__needle) + __THROW __asm ("wcsstr") __attribute_pure__; +#else +extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle) + __THROW __attribute_pure__; +#endif + +/* Divide WCS into tokens separated by characters in DELIM. */ +extern wchar_t *wcstok (wchar_t *__restrict __s, + const wchar_t *__restrict __delim, + wchar_t **__restrict __ptr) __THROW; + +/* Return the number of wide characters in S. */ +extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__; + +#ifdef __USE_XOPEN +/* Another name for `wcsstr' from XPG4. */ +# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle) + __THROW __asm ("wcswcs") __attribute_pure__; +extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack, + const wchar_t *__needle) + __THROW __asm ("wcswcs") __attribute_pure__; +# else +extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle) + __THROW __attribute_pure__; +# endif +#endif + +#ifdef __USE_XOPEN2K8 +/* Return the number of wide characters in S, but at most MAXLEN. */ +extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen) + __THROW __attribute_pure__; +#endif + + +/* Search N wide characters of S for C. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) + __THROW __asm ("wmemchr") __attribute_pure__; +extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, + size_t __n) + __THROW __asm ("wmemchr") __attribute_pure__; +#else +extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) + __THROW __attribute_pure__; +#endif + +/* Compare N wide characters of S1 and S2. */ +extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) + __THROW __attribute_pure__; + +/* Copy N wide characters of SRC to DEST. */ +extern wchar_t *wmemcpy (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, size_t __n) __THROW; + +/* Copy N wide characters of SRC to DEST, guaranteeing + correct behavior for overlapping strings. */ +extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n) + __THROW; + +/* Set N wide characters of S to C. */ +extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; + +#ifdef __USE_GNU +/* Copy N wide characters of SRC to DEST and return pointer to following + wide character. */ +extern wchar_t *wmempcpy (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, size_t __n) + __THROW; +#endif + + +/* Determine whether C constitutes a valid (one-byte) multibyte + character. */ +extern wint_t btowc (int __c) __THROW; + +/* Determine whether C corresponds to a member of the extended + character set whose multibyte representation is a single byte. */ +extern int wctob (wint_t __c) __THROW; + +/* Determine whether PS points to an object representing the initial + state. */ +extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__; + +/* Write wide character representation of multibyte character pointed + to by S to PWC. */ +extern size_t mbrtowc (wchar_t *__restrict __pwc, + const char *__restrict __s, size_t __n, + mbstate_t *__restrict __p) __THROW; + +/* Write multibyte representation of wide character WC to S. */ +extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, + mbstate_t *__restrict __ps) __THROW; + +/* Return number of bytes in multibyte character pointed to by S. */ +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; + +#ifdef __USE_EXTERN_INLINES +/* Define inline function as optimization. */ + +/* We can use the BTOWC and WCTOB optimizations since we know that all + locales must use ASCII encoding for the values in the ASCII range + and because the wchar_t encoding is always ISO 10646. */ +extern wint_t __btowc_alias (int __c) __asm ("btowc"); +__extern_inline wint_t +__NTH (btowc (int __c)) +{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f' + ? (wint_t) __c : __btowc_alias (__c)); } + +extern int __wctob_alias (wint_t __c) __asm ("wctob"); +__extern_inline int +__NTH (wctob (wint_t __wc)) +{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f' + ? (int) __wc : __wctob_alias (__wc)); } + +__extern_inline size_t +__NTH (mbrlen (const char *__restrict __s, size_t __n, + mbstate_t *__restrict __ps)) +{ return (__ps != NULL + ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); } +#endif + +/* Write wide character representation of multibyte character string + SRC to DST. */ +extern size_t mbsrtowcs (wchar_t *__restrict __dst, + const char **__restrict __src, size_t __len, + mbstate_t *__restrict __ps) __THROW; + +/* Write multibyte character representation of wide character string + SRC to DST. */ +extern size_t wcsrtombs (char *__restrict __dst, + const wchar_t **__restrict __src, size_t __len, + mbstate_t *__restrict __ps) __THROW; + + +#ifdef __USE_XOPEN2K8 +/* Write wide character representation of at most NMC bytes of the + multibyte character string SRC to DST. */ +extern size_t mbsnrtowcs (wchar_t *__restrict __dst, + const char **__restrict __src, size_t __nmc, + size_t __len, mbstate_t *__restrict __ps) __THROW; + +/* Write multibyte character representation of at most NWC characters + from the wide character string SRC to DST. */ +extern size_t wcsnrtombs (char *__restrict __dst, + const wchar_t **__restrict __src, + size_t __nwc, size_t __len, + mbstate_t *__restrict __ps) __THROW; +#endif /* use POSIX 2008 */ + + +/* The following functions are extensions found in X/Open CAE. */ +#ifdef __USE_XOPEN +/* Determine number of column positions required for C. */ +extern int wcwidth (wchar_t __c) __THROW; + +/* Determine number of column positions required for first N wide + characters (or fewer if S ends before this) in S. */ +extern int wcswidth (const wchar_t *__s, size_t __n) __THROW; +#endif /* Use X/Open. */ + + +/* Convert initial portion of the wide string NPTR to `double' + representation. */ +extern double wcstod (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; + +#ifdef __USE_ISOC99 +/* Likewise for `float' and `long double' sizes of floating-point numbers. */ +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; +#endif /* C99 */ + +/* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */ + +#if __HAVE_FLOAT16 && defined __USE_GNU +extern _Float16 wcstof16 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT32 && defined __USE_GNU +extern _Float32 wcstof32 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT64 && defined __USE_GNU +extern _Float64 wcstof64 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT128 && defined __USE_GNU +extern _Float128 wcstof128 (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT32X && defined __USE_GNU +extern _Float32x wcstof32x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT64X && defined __USE_GNU +extern _Float64x wcstof64x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + +#if __HAVE_FLOAT128X && defined __USE_GNU +extern _Float128x wcstof128x (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif + + +/* Convert initial portion of wide string NPTR to `long int' + representation. */ +extern long int wcstol (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long int' + representation. */ +extern unsigned long int wcstoul (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +#ifdef __USE_ISOC99 +/* Convert initial portion of wide string NPTR to `long long int' + representation. */ +__extension__ +extern long long int wcstoll (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long long int' + representation. */ +__extension__ +extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base) __THROW; +#endif /* ISO C99. */ + +#ifdef __USE_GNU +/* Convert initial portion of wide string NPTR to `long long int' + representation. */ +__extension__ +extern long long int wcstoq (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long long int' + representation. */ +__extension__ +extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base) __THROW; +#endif /* Use GNU. */ + +#ifdef __USE_GNU +/* Parallel versions of the functions above which take the locale to + use as an additional parameter. These are GNU extensions inspired + by the POSIX.1-2008 extended locale API. */ +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; + +# if __HAVE_FLOAT16 +extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT32 +extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT64 +extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT128 +extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT32X +extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT64X +extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif + +# if __HAVE_FLOAT128X +extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + locale_t __loc) __THROW; +# endif +#endif /* use GNU */ + + +#ifdef __USE_XOPEN2K8 +/* Copy SRC to DEST, returning the address of the terminating L'\0' in + DEST. */ +extern wchar_t *wcpcpy (wchar_t *__restrict __dest, + const wchar_t *__restrict __src) __THROW; + +/* Copy no more than N characters of SRC to DEST, returning the address of + the last character written into DEST. */ +extern wchar_t *wcpncpy (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, size_t __n) + __THROW; +#endif + + +/* Wide character I/O functions. */ + +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) +# ifndef __attr_dealloc_fclose +# if defined __has_builtin +# if __has_builtin (__builtin_fclose) +/* If the attribute macro hasn't been defined yet (by ) and + fclose is a built-in, use it. */ +# define __attr_dealloc_fclose __attr_dealloc (__builtin_fclose, 1) +# endif +# endif +# endif +# ifndef __attr_dealloc_fclose +# define __attr_dealloc_fclose /* empty */ +# endif + +/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces + a wide character string. */ +extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW + __attribute_malloc__ __attr_dealloc_fclose; +#endif + +#if defined __USE_ISOC95 || defined __USE_UNIX98 + +/* Select orientation for stream. */ +extern int fwide (__FILE *__fp, int __mode) __THROW; + + +/* Write formatted output to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fwprintf (__FILE *__restrict __stream, + const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; +/* Write formatted output to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int wprintf (const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */; +/* Write formatted output of at most N characters to S. */ +extern int swprintf (wchar_t *__restrict __s, size_t __n, + const wchar_t *__restrict __format, ...) + __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */; + +/* Write formatted output to S from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfwprintf (__FILE *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; +/* Write formatted output to stdout from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vwprintf (const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */; +/* Write formatted output of at most N character to S from argument + list ARG. */ +extern int vswprintf (wchar_t *__restrict __s, size_t __n, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) + __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */; + + +/* Read formatted input from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fwscanf (__FILE *__restrict __stream, + const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +/* Read formatted input from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int wscanf (const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; +/* Read formatted input from S. */ +extern int swscanf (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, ...) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; + +/* For historical reasons, the C99-compliant versions of the scanf + functions are at alternative names. When __LDBL_COMPAT or + __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in + bits/wchar-ldbl.h. */ +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \ + && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 +# ifdef __REDIRECT +extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream, + const wchar_t *__restrict __format, ...), + __isoc99_fwscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...), + __isoc99_wscanf) + /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; +extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, + ...), __isoc99_swscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +# else +extern int __isoc99_fwscanf (__FILE *__restrict __stream, + const wchar_t *__restrict __format, ...); +extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...); +extern int __isoc99_swscanf (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, ...) + __THROW; +# define fwscanf __isoc99_fwscanf +# define wscanf __isoc99_wscanf +# define swscanf __isoc99_swscanf +# endif +# endif + +#endif /* Use ISO C95, C99 and Unix98. */ + +#ifdef __USE_ISOC99 +/* Read formatted input from S into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfwscanf (__FILE *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +/* Read formatted input from stdin into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vwscanf (const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; +/* Read formatted input from S into argument list ARG. */ +extern int vswscanf (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; + +/* Same redirection as above for the v*wscanf family. */ +# if !__GLIBC_USE (DEPRECATED_SCANF) \ + && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \ + && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 +# ifdef __REDIRECT +extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vfwscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vwscanf) + /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; +extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg), __isoc99_vswscanf) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +# else +extern int __isoc99_vfwscanf (__FILE *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg); +extern int __isoc99_vwscanf (const wchar_t *__restrict __format, + __gnuc_va_list __arg); +extern int __isoc99_vswscanf (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) __THROW; +# define vfwscanf __isoc99_vfwscanf +# define vwscanf __isoc99_vwscanf +# define vswscanf __isoc99_vswscanf +# endif +# endif + +#endif /* Use ISO C99. */ + + +/* Read a character from STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t fgetwc (__FILE *__stream); +extern wint_t getwc (__FILE *__stream); + +/* Read a character from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern wint_t getwchar (void); + + +/* Write a character to STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t fputwc (wchar_t __wc, __FILE *__stream); +extern wint_t putwc (wchar_t __wc, __FILE *__stream); + +/* Write a character to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern wint_t putwchar (wchar_t __wc); + + +/* Get a newline-terminated wide character string of finite length + from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n, + __FILE *__restrict __stream); + +/* Write a string to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fputws (const wchar_t *__restrict __ws, + __FILE *__restrict __stream); + + +/* Push a character back onto the input buffer of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern wint_t ungetwc (wint_t __wc, __FILE *__stream); + + +#ifdef __USE_GNU +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern wint_t getwc_unlocked (__FILE *__stream); +extern wint_t getwchar_unlocked (void); + +/* This is the wide character version of a GNU extension. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wint_t fgetwc_unlocked (__FILE *__stream); + +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream); + +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream); +extern wint_t putwchar_unlocked (wchar_t __wc); + + +/* This function does the same as `fgetws' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n, + __FILE *__restrict __stream); + +/* This function does the same as `fputws' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputws_unlocked (const wchar_t *__restrict __ws, + __FILE *__restrict __stream); +#endif + + +/* Format TP into S according to FORMAT. + Write no more than MAXSIZE wide characters and return the number + of wide characters written, or 0 if it would exceed MAXSIZE. */ +extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, + const wchar_t *__restrict __format, + const struct tm *__restrict __tp) __THROW; + +# ifdef __USE_GNU +/* Similar to `wcsftime' but takes the information from + the provided locale and not the global locale. */ +extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, + const wchar_t *__restrict __format, + const struct tm *__restrict __tp, + locale_t __loc) __THROW; +# endif + +/* Define some macros helping to catch buffer overflows. */ +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +/* Declare all functions from bits/wchar2-decl.h first. */ +# include +#endif + +/* The following headers provide asm redirections. These redirections must + appear before the first usage of these functions, e.g. in bits/wchar.h. */ +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# include +#endif + +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function +/* Now include the function definitions and redirects too. */ +# include +#endif + +__END_DECLS + +#endif /* wchar.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8d6817917ad67c445f8564457b9b8d0371b3e64d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wchar.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h new file mode 100644 index 0000000000000000000000000000000000000000..7e87fd3bf984e7c4e68665e5ee57c6d5fd20ed49 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h @@ -0,0 +1,148 @@ +/* Copyright (C) 1996-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * ISO C99 Standard: 7.25 + * Wide character classification and mapping utilities + */ + +#ifndef _WCTYPE_H +#define _WCTYPE_H 1 + +#include +#include +#include + +/* Constant expression of type `wint_t' whose value does not correspond + to any member of the extended character set. */ +#ifndef WEOF +# define WEOF (0xffffffffu) +#endif + +/* Some definitions from this header also appear in in + Unix98 mode. */ +#include + +/* + * Extensible wide-character mapping functions: 7.15.3.2. + */ + +__BEGIN_DECLS + +/* Scalar type that can hold values which represent locale-specific + character mappings. */ +typedef const __int32_t *wctrans_t; + +/* Construct value that describes a mapping between wide characters + identified by the string argument PROPERTY. */ +extern wctrans_t wctrans (const char *__property) __THROW; + +/* Map the wide character WC using the mapping described by DESC. */ +extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; + +# ifdef __USE_XOPEN2K8 +/* POSIX.1-2008 extended locale interface (see locale.h). */ +# include + +/* Test for any wide character for which `iswalpha' or `iswdigit' is + true. */ +extern int iswalnum_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character for which `iswupper' or 'iswlower' is + true, or any wide character that is one of a locale-specific set of + wide-characters for which none of `iswcntrl', `iswdigit', + `iswpunct', or `iswspace' is true. */ +extern int iswalpha_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any control wide character. */ +extern int iswcntrl_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a decimal-digit + character. */ +extern int iswdigit_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character for which `iswprint' is true and + `iswspace' is false. */ +extern int iswgraph_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a lowercase letter + or is one of a locale-specific set of wide characters for which + none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswlower_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any printing wide character. */ +extern int iswprint_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any printing wide character that is one of a + locale-specific et of wide characters for which neither `iswspace' + nor `iswalnum' is true. */ +extern int iswpunct_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a locale-specific + set of wide characters for which none of `iswalnum', `iswgraph', or + `iswpunct' is true. */ +extern int iswspace_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to an uppercase letter + or is one of a locale-specific set of wide character for which none + of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswupper_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a hexadecimal-digit + character equivalent to that performed be the functions described + in the previous subclause. */ +extern int iswxdigit_l (wint_t __wc, locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a standard blank + wide character or a locale-specific set of wide characters for + which `iswalnum' is false. */ +extern int iswblank_l (wint_t __wc, locale_t __locale) __THROW; + +/* Construct value that describes a class of wide characters identified + by the string argument PROPERTY. */ +extern wctype_t wctype_l (const char *__property, locale_t __locale) + __THROW; + +/* Determine whether the wide-character WC has the property described by + DESC. */ +extern int iswctype_l (wint_t __wc, wctype_t __desc, locale_t __locale) + __THROW; + +/* + * Wide-character case-mapping functions. + */ + +/* Converts an uppercase letter to the corresponding lowercase letter. */ +extern wint_t towlower_l (wint_t __wc, locale_t __locale) __THROW; + +/* Converts an lowercase letter to the corresponding uppercase letter. */ +extern wint_t towupper_l (wint_t __wc, locale_t __locale) __THROW; + +/* Construct value that describes a mapping between wide characters + identified by the string argument PROPERTY. */ +extern wctrans_t wctrans_l (const char *__property, locale_t __locale) + __THROW; + +/* Map the wide character WC using the mapping described by DESC. */ +extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc, + locale_t __locale) __THROW; + +# endif /* Use POSIX 2008. */ + +__END_DECLS + +#endif /* wctype.h */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8fdc06f0c68cbbafe8b55e3fcbabd92590143b02 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@1zsc48wwlplpkzms83m7zr94xnfalq2q-glibc-2.35-224-dev@include@wctype.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h new file mode 100644 index 0000000000000000000000000000000000000000..9653140bff92dd2ee5a261a66dfe6c5687c3e956 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0d3deb118c780cf106e905129115af8b8826d269 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno-base.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h new file mode 100644 index 0000000000000000000000000000000000000000..cf9c51ac49f97efd8d5aed07cf4fca2d9a368515 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ + +/* + * This error code is special: arch syscall entry code will return + * -ENOSYS if users try to call a syscall that doesn't exist. To keep + * failures of syscalls that really do exist distinguishable from + * failures due to attempts to use a nonexistent syscall, syscall + * implementations should refrain from returning -ENOSYS. + */ +#define ENOSYS 38 /* Invalid system call number */ + +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#define ERFKILL 132 /* Operation not possible due to RF-kill */ + +#define EHWPOISON 133 /* Memory page has hardware error */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..2948241b92119492da6d2652ed7ef56ef6bd00e6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm-generic@errno.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h new file mode 100644 index 0000000000000000000000000000000000000000..4c82b503d92ffabcc6eb558a50ae5d6dba8a5f7c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h @@ -0,0 +1 @@ +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..05854122d0e543f1dc006b484ba3d3ea3f89a567 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@asm@errno.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h new file mode 100644 index 0000000000000000000000000000000000000000..af78ebfec7dd0204045780f22e3f8dc36f527e27 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_CLOSE_RANGE_H +#define _LINUX_CLOSE_RANGE_H + +/* Unshare the file descriptor table before closing file descriptors. */ +#define CLOSE_RANGE_UNSHARE (1U << 1) + +/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */ +#define CLOSE_RANGE_CLOEXEC (1U << 2) + +#endif /* _LINUX_CLOSE_RANGE_H */ + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4b5cf90fc1f3a3c163419d9861dc28928a24977a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@close_range.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h new file mode 100644 index 0000000000000000000000000000000000000000..70f2bd34e3354bc551ae6d0481f752c642ad6a40 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h @@ -0,0 +1 @@ +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c0e1a80726230e0b8e2c6bf822920c0b650d7ca2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@errno.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h new file mode 100644 index 0000000000000000000000000000000000000000..c3547f07605c9e2ca28e4ced0fbba545b55d21a6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_LIMITS_H +#define _LINUX_LIMITS_H + +#define NR_OPEN 1024 + +#define NGROUPS_MAX 65536 /* supplemental group IDs are available */ +#define ARG_MAX 131072 /* # bytes of args + environ for exec() */ +#define LINK_MAX 127 /* # links a file may have */ +#define MAX_CANON 255 /* size of the canonical input queue */ +#define MAX_INPUT 255 /* size of the type-ahead buffer */ +#define NAME_MAX 255 /* # chars in a file name */ +#define PATH_MAX 4096 /* # chars in a path name including nul */ +#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ +#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ +#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ +#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ + +#define RTSIG_MAX 32 + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8e64a66aa1c6e360318fd2462cdbf6490ec7ea3e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@fa0byasfkms4k570jm47b7sb9lkrj73v-linux-headers-6.2@include@linux@limits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm new file mode 100644 index 0000000000000000000000000000000000000000..e2cfd7ca662f849bf00c92bf229d628ad313d41b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm @@ -0,0 +1,85 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/algorithm + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ALGORITHM +#define _GLIBCXX_ALGORITHM 1 + +#pragma GCC system_header + +#include +#include +#if __cplusplus > 201703L +# include +#endif + +#if __cplusplus > 201402L +// Parallel STL algorithms +# if _PSTL_EXECUTION_POLICIES_DEFINED +// If has already been included, pull in implementations +# include +# else +// Otherwise just pull in forward declarations +# include +# define _PSTL_ALGORITHM_FORWARD_DECLARED 1 +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +#endif // C++17 + +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif /* _GLIBCXX_ALGORITHM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm.blob new file mode 100644 index 0000000000000000000000000000000000000000..1bb24a8b483be87eaf482935762e7bf7d58dafba Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@algorithm.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array new file mode 100644 index 0000000000000000000000000000000000000000..e45143fb329964418b8d6e30153de3c5dd0edba6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array @@ -0,0 +1,499 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/array + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ARRAY +#define _GLIBCXX_ARRAY 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +#include +#include +#include +#include // std::begin, std::end etc. +#include // std::index_sequence, std::tuple_size +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct __array_traits + { + typedef _Tp _Type[_Nm]; + typedef __is_swappable<_Tp> _Is_swappable; + typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable; + + static constexpr _Tp& + _S_ref(const _Type& __t, std::size_t __n) noexcept + { return const_cast<_Tp&>(__t[__n]); } + + static constexpr _Tp* + _S_ptr(const _Type& __t) noexcept + { return const_cast<_Tp*>(__t); } + }; + + template + struct __array_traits<_Tp, 0> + { + struct _Type { }; + typedef true_type _Is_swappable; + typedef true_type _Is_nothrow_swappable; + + static constexpr _Tp& + _S_ref(const _Type&, std::size_t) noexcept + { return *static_cast<_Tp*>(nullptr); } + + static constexpr _Tp* + _S_ptr(const _Type&) noexcept + { return nullptr; } + }; + + /** + * @brief A standard container for storing a fixed size sequence of elements. + * + * @ingroup sequences + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. + * + * Sets support random access iterators. + * + * @tparam Tp Type of element. Required to be a complete type. + * @tparam Nm Number of elements. + */ + template + struct array + { + 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 value_type* iterator; + typedef const value_type* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // Support for zero-sized arrays mandatory. + typedef __array_traits<_Tp, _Nm> _AT_Type; + typename _AT_Type::_Type _M_elems; + + // No explicit construct/copy/destroy for aggregate type. + + // DR 776. + _GLIBCXX20_CONSTEXPR void + fill(const value_type& __u) + { std::fill_n(begin(), size(), __u); } + + _GLIBCXX20_CONSTEXPR void + swap(array& __other) + noexcept(_AT_Type::_Is_nothrow_swappable::value) + { std::swap_ranges(begin(), end(), __other.begin()); } + + // Iterators. + [[__gnu__::__const__, __nodiscard__]] + _GLIBCXX17_CONSTEXPR iterator + begin() noexcept + { return iterator(data()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_iterator + begin() const noexcept + { return const_iterator(data()); } + + [[__gnu__::__const__, __nodiscard__]] + _GLIBCXX17_CONSTEXPR iterator + end() noexcept + { return iterator(data() + _Nm); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_iterator + end() const noexcept + { return const_iterator(data() + _Nm); } + + [[__gnu__::__const__, __nodiscard__]] + _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin() noexcept + { return reverse_iterator(end()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rbegin() const noexcept + { return const_reverse_iterator(end()); } + + [[__gnu__::__const__, __nodiscard__]] + _GLIBCXX17_CONSTEXPR reverse_iterator + rend() noexcept + { return reverse_iterator(begin()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rend() const noexcept + { return const_reverse_iterator(begin()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_iterator + cbegin() const noexcept + { return const_iterator(data()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_iterator + cend() const noexcept + { return const_iterator(data() + _Nm); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } + + // Capacity. + [[__gnu__::__const__, __nodiscard__]] + constexpr size_type + size() const noexcept { return _Nm; } + + [[__gnu__::__const__, __nodiscard__]] + constexpr size_type + max_size() const noexcept { return _Nm; } + + [[__gnu__::__const__, __nodiscard__]] + constexpr bool + empty() const noexcept { return size() == 0; } + + // Element access. + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR reference + operator[](size_type __n) noexcept + { + __glibcxx_requires_subscript(__n); + return _AT_Type::_S_ref(_M_elems, __n); + } + + [[__nodiscard__]] + constexpr const_reference + operator[](size_type __n) const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_subscript(__n); +#endif + return _AT_Type::_S_ref(_M_elems, __n); + } + + _GLIBCXX17_CONSTEXPR reference + at(size_type __n) + { + if (__n >= _Nm) + std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " + ">= _Nm (which is %zu)"), + __n, _Nm); + return _AT_Type::_S_ref(_M_elems, __n); + } + + constexpr const_reference + at(size_type __n) const + { + // Result of conditional expression must be an lvalue so use + // boolean ? lvalue : (throw-expr, lvalue) + return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n) + : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " + ">= _Nm (which is %zu)"), + __n, _Nm), + _AT_Type::_S_ref(_M_elems, 0)); + } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR reference + front() noexcept + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + [[__nodiscard__]] + constexpr const_reference + front() const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_nonempty(); +#endif + return _AT_Type::_S_ref(_M_elems, 0); + } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR reference + back() noexcept + { + __glibcxx_requires_nonempty(); + return _Nm ? *(end() - 1) : *end(); + } + + [[__nodiscard__]] + constexpr const_reference + back() const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_nonempty(); +#endif + return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) + : _AT_Type::_S_ref(_M_elems, 0); + } + + [[__gnu__::__const__, __nodiscard__]] + _GLIBCXX17_CONSTEXPR pointer + data() noexcept + { return _AT_Type::_S_ptr(_M_elems); } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR const_pointer + data() const noexcept + { return _AT_Type::_S_ptr(_M_elems); } + }; + +#if __cpp_deduction_guides >= 201606 + template + array(_Tp, _Up...) + -> array && ...), _Tp>, + 1 + sizeof...(_Up)>; +#endif + + // Array comparisons. + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return std::equal(__one.begin(), __one.end(), __two.begin()); } + +#if __cpp_lib_three_way_comparison && __cpp_lib_concepts + template + [[nodiscard]] + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value) + if (!std::__is_constant_evaluated()) + { + constexpr size_t __n = _Nm * sizeof(_Tp); + return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0; + } + + for (size_t __i = 0; __i < _Nm; ++__i) + { + auto __c = __detail::__synth3way(__a[__i], __b[__i]); + if (__c != 0) + return __c; + } + return strong_ordering::equal; + } +#else + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + return std::lexicographical_compare(__a.begin(), __a.end(), + __b.begin(), __b.end()); + } + + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template + [[__nodiscard__]] + _GLIBCXX20_CONSTEXPR + inline bool + operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one < __two); } +#endif // three_way_comparison && concepts + + // Specialized algorithms. + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if< + __array_traits<_Tp, _Nm>::_Is_swappable::value + >::type +#else + void +#endif + swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) + noexcept(noexcept(__one.swap(__two))) + { __one.swap(__two); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if< + !__array_traits<_Tp, _Nm>::_Is_swappable::value>::type + swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; +#endif + + template + [[__nodiscard__]] + constexpr _Tp& + get(array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); + } + + template + [[__nodiscard__]] + constexpr _Tp&& + get(array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(std::get<_Int>(__arr)); + } + + template + [[__nodiscard__]] + constexpr const _Tp& + get(const array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); + } + + template + [[__nodiscard__]] + constexpr const _Tp&& + get(const array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(std::get<_Int>(__arr)); + } + +#if __cplusplus > 201703L +#define __cpp_lib_to_array 201907L + + template + constexpr array, sizeof...(_Idx)> + __to_array(_Tp (&__a)[sizeof...(_Idx)], index_sequence<_Idx...>) + { + if constexpr (_Move) + return {{std::move(__a[_Idx])...}}; + else + return {{__a[_Idx]...}}; + } + + template + [[nodiscard]] + constexpr array, _Nm> + to_array(_Tp (&__a)[_Nm]) + noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) + { + static_assert(!is_array_v<_Tp>); + static_assert(is_constructible_v<_Tp, _Tp&>); + if constexpr (is_constructible_v<_Tp, _Tp&>) + return __to_array(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } + + template + [[nodiscard]] + constexpr array, _Nm> + to_array(_Tp (&&__a)[_Nm]) + noexcept(is_nothrow_move_constructible_v<_Tp>) + { + static_assert(!is_array_v<_Tp>); + static_assert(is_move_constructible_v<_Tp>); + if constexpr (is_move_constructible_v<_Tp>) + return __to_array<1>(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } +#endif // C++20 + + // Tuple interface to class template array. + + /// Partial specialization for std::array + template + struct tuple_size> + : public integral_constant { }; + + /// Partial specialization for std::array + template + struct tuple_element<_Ind, array<_Tp, _Nm>> + { + static_assert(_Ind < _Nm, "array index is in range"); + using type = _Tp; + }; + +#if __cplusplus >= 201703L + template + inline constexpr size_t tuple_size_v> = _Nm; + + template + inline constexpr size_t tuple_size_v> = _Nm; +#endif + + template + struct __is_tuple_like_impl> : true_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_ARRAY diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array.blob new file mode 100644 index 0000000000000000000000000000000000000000..8364a03e39ee6ac6604a30233c48ed39ca17e995 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@array.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic new file mode 100644 index 0000000000000000000000000000000000000000..cf5d730933468095fdae93168e034d4f7e874b01 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic @@ -0,0 +1,1654 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/atomic + * This is a Standard C++ Library header. + */ + +// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl. +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html + +#ifndef _GLIBCXX_ATOMIC +#define _GLIBCXX_ATOMIC 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup atomics + * @{ + */ + +#if __cplusplus >= 201703L +# define __cpp_lib_atomic_is_always_lock_free 201603L +#endif + + template + struct atomic; + + /// atomic + // NB: No operators or fetch-operations for this type. + template<> + struct atomic + { + using value_type = bool; + + private: + __atomic_base _M_base; + + public: + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(bool __i) noexcept : _M_base(__i) { } + + bool + operator=(bool __i) noexcept + { return _M_base.operator=(__i); } + + bool + operator=(bool __i) volatile noexcept + { return _M_base.operator=(__i); } + + operator bool() const noexcept + { return _M_base.load(); } + + operator bool() const volatile noexcept + { return _M_base.load(); } + + bool + is_lock_free() const noexcept { return _M_base.is_lock_free(); } + + bool + is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_BOOL_LOCK_FREE == 2; +#endif + + void + store(bool __i, memory_order __m = memory_order_seq_cst) noexcept + { _M_base.store(__i, __m); } + + void + store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept + { _M_base.store(__i, __m); } + + bool + load(memory_order __m = memory_order_seq_cst) const noexcept + { return _M_base.load(__m); } + + bool + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return _M_base.load(__m); } + + bool + exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.exchange(__i, __m); } + + bool + exchange(bool __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.exchange(__i, __m); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m); } + +#if __cpp_lib_atomic_wait + void + wait(bool __old, memory_order __m = memory_order_seq_cst) const noexcept + { _M_base.wait(__old, __m); } + + // TODO add const volatile overload + + void + notify_one() noexcept + { _M_base.notify_one(); } + + void + notify_all() noexcept + { _M_base.notify_all(); } +#endif // __cpp_lib_atomic_wait + }; + +#if __cplusplus <= 201703L +# define _GLIBCXX20_INIT(I) +#else +# define _GLIBCXX20_INIT(I) = I +#endif + + /** + * @brief Generic atomic type, primary class template. + * + * @tparam _Tp Type to be made atomic, must be trivially copyable. + */ + template + struct atomic + { + using value_type = _Tp; + + private: + // Align 1/2/4/8/16-byte types to at least their size. + static constexpr int _S_min_alignment + = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16 + ? 0 : sizeof(_Tp); + + static constexpr int _S_alignment + = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp); + + alignas(_S_alignment) _Tp _M_i _GLIBCXX20_INIT(_Tp()); + + static_assert(__is_trivially_copyable(_Tp), + "std::atomic requires a trivially copyable type"); + + static_assert(sizeof(_Tp) > 0, + "Incomplete or zero-sized types are not supported"); + +#if __cplusplus > 201703L + static_assert(is_copy_constructible_v<_Tp>); + static_assert(is_move_constructible_v<_Tp>); + static_assert(is_copy_assignable_v<_Tp>); + static_assert(is_move_assignable_v<_Tp>); +#endif + + public: + atomic() = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(_Tp __i) noexcept : _M_i(__i) { } + + operator _Tp() const noexcept + { return load(); } + + operator _Tp() const volatile noexcept + { return load(); } + + _Tp + operator=(_Tp __i) noexcept + { store(__i); return __i; } + + _Tp + operator=(_Tp __i) volatile noexcept + { store(__i); return __i; } + + bool + is_lock_free() const noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + bool + is_lock_free() const volatile noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_M_i), 0); +#endif + + void + store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept + { + __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + } + + void + store(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept + { + __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); + return *__ptr; + } + + _Tp + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); + return *__ptr; + } + + _Tp + exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __ptr, int(__m)); + return *__ptr; + } + + _Tp + exchange(_Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __ptr, int(__m)); + return *__ptr; + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); + + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + true, int(__s), int(__f)); + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); + + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + true, int(__s), int(__f)); + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) noexcept + { return compare_exchange_weak(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return compare_exchange_weak(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); + + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + false, int(__s), int(__f)); + } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); + + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + false, int(__s), int(__f)); + } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) noexcept + { return compare_exchange_strong(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return compare_exchange_strong(__e, __i, __m, + __cmpexch_failure_order(__m)); } + +#if __cpp_lib_atomic_wait + void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { + std::__atomic_wait_address_v(&_M_i, __old, + [__m, this] { return this->load(__m); }); + } + + // TODO add const volatile overload + + void + notify_one() noexcept + { std::__atomic_notify_address(&_M_i, false); } + + void + notify_all() noexcept + { std::__atomic_notify_address(&_M_i, true); } +#endif // __cpp_lib_atomic_wait + + }; +#undef _GLIBCXX20_INIT + + /// Partial specialization for pointer types. + template + struct atomic<_Tp*> + { + using value_type = _Tp*; + using difference_type = ptrdiff_t; + + typedef _Tp* __pointer_type; + typedef __atomic_base<_Tp*> __base_type; + __base_type _M_b; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { } + + operator __pointer_type() const noexcept + { return __pointer_type(_M_b); } + + operator __pointer_type() const volatile noexcept + { return __pointer_type(_M_b); } + + __pointer_type + operator=(__pointer_type __p) noexcept + { return _M_b.operator=(__p); } + + __pointer_type + operator=(__pointer_type __p) volatile noexcept + { return _M_b.operator=(__p); } + + __pointer_type + operator++(int) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b++; + } + + __pointer_type + operator++(int) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b++; + } + + __pointer_type + operator--(int) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b--; + } + + __pointer_type + operator--(int) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b--; + } + + __pointer_type + operator++() noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return ++_M_b; + } + + __pointer_type + operator++() volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return ++_M_b; + } + + __pointer_type + operator--() noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return --_M_b; + } + + __pointer_type + operator--() volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return --_M_b; + } + + __pointer_type + operator+=(ptrdiff_t __d) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator+=(__d); + } + + __pointer_type + operator+=(ptrdiff_t __d) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator+=(__d); + } + + __pointer_type + operator-=(ptrdiff_t __d) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator-=(__d); + } + + __pointer_type + operator-=(ptrdiff_t __d) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator-=(__d); + } + + bool + is_lock_free() const noexcept + { return _M_b.is_lock_free(); } + + bool + is_lock_free() const volatile noexcept + { return _M_b.is_lock_free(); } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free + = ATOMIC_POINTER_LOCK_FREE == 2; +#endif + + void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_b.store(__p, __m); } + + void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_b.store(__p, __m); } + + __pointer_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { return _M_b.load(__m); } + + __pointer_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return _M_b.load(__m); } + + __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_b.exchange(__p, __m); } + + __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_b.exchange(__p, __m); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, memory_order __m2) noexcept + { return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_weak(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_weak(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, memory_order __m2) noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) noexcept + { + return _M_b.compare_exchange_strong(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return _M_b.compare_exchange_strong(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + +#if __cpp_lib_atomic_wait + void + wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) const noexcept + { _M_b.wait(__old, __m); } + + // TODO add const volatile overload + + void + notify_one() noexcept + { _M_b.notify_one(); } + + void + notify_all() noexcept + { _M_b.notify_all(); } +#endif // __cpp_lib_atomic_wait + + __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_add(__d, __m); + } + + __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_add(__d, __m); + } + + __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_sub(__d, __m); + } + + __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_sub(__d, __m); + } + }; + + + /// Explicit specialization for char. + template<> + struct atomic : __atomic_base + { + typedef char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for signed char. + template<> + struct atomic : __atomic_base + { + typedef signed char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept= default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned char. + template<> + struct atomic : __atomic_base + { + typedef unsigned char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept= default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for short. + template<> + struct atomic : __atomic_base + { + typedef short __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned short. + template<> + struct atomic : __atomic_base + { + typedef unsigned short __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for int. + template<> + struct atomic : __atomic_base + { + typedef int __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned int. + template<> + struct atomic : __atomic_base + { + typedef unsigned int __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for long. + template<> + struct atomic : __atomic_base + { + typedef long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned long. + template<> + struct atomic : __atomic_base + { + typedef unsigned long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for long long. + template<> + struct atomic : __atomic_base + { + typedef long long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned long long. + template<> + struct atomic : __atomic_base + { + typedef unsigned long long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for wchar_t. + template<> + struct atomic : __atomic_base + { + typedef wchar_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2; +#endif + }; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// Explicit specialization for char8_t. + template<> + struct atomic : __atomic_base + { + typedef char8_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus > 201402L + static constexpr bool is_always_lock_free + = ATOMIC_CHAR8_T_LOCK_FREE == 2; +#endif + }; +#endif + + /// Explicit specialization for char16_t. + template<> + struct atomic : __atomic_base + { + typedef char16_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free + = ATOMIC_CHAR16_T_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for char32_t. + template<> + struct atomic : __atomic_base + { + typedef char32_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free + = ATOMIC_CHAR32_T_LOCK_FREE == 2; +#endif + }; + + + /// atomic_bool + typedef atomic atomic_bool; + + /// atomic_char + typedef atomic atomic_char; + + /// atomic_schar + typedef atomic atomic_schar; + + /// atomic_uchar + typedef atomic atomic_uchar; + + /// atomic_short + typedef atomic atomic_short; + + /// atomic_ushort + typedef atomic atomic_ushort; + + /// atomic_int + typedef atomic atomic_int; + + /// atomic_uint + typedef atomic atomic_uint; + + /// atomic_long + typedef atomic atomic_long; + + /// atomic_ulong + typedef atomic atomic_ulong; + + /// atomic_llong + typedef atomic atomic_llong; + + /// atomic_ullong + typedef atomic atomic_ullong; + + /// atomic_wchar_t + typedef atomic atomic_wchar_t; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// atomic_char8_t + typedef atomic atomic_char8_t; +#endif + + /// atomic_char16_t + typedef atomic atomic_char16_t; + + /// atomic_char32_t + typedef atomic atomic_char32_t; + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2441. Exact-width atomic typedefs should be provided + + /// atomic_int8_t + typedef atomic atomic_int8_t; + + /// atomic_uint8_t + typedef atomic atomic_uint8_t; + + /// atomic_int16_t + typedef atomic atomic_int16_t; + + /// atomic_uint16_t + typedef atomic atomic_uint16_t; + + /// atomic_int32_t + typedef atomic atomic_int32_t; + + /// atomic_uint32_t + typedef atomic atomic_uint32_t; + + /// atomic_int64_t + typedef atomic atomic_int64_t; + + /// atomic_uint64_t + typedef atomic atomic_uint64_t; + + + /// atomic_int_least8_t + typedef atomic atomic_int_least8_t; + + /// atomic_uint_least8_t + typedef atomic atomic_uint_least8_t; + + /// atomic_int_least16_t + typedef atomic atomic_int_least16_t; + + /// atomic_uint_least16_t + typedef atomic atomic_uint_least16_t; + + /// atomic_int_least32_t + typedef atomic atomic_int_least32_t; + + /// atomic_uint_least32_t + typedef atomic atomic_uint_least32_t; + + /// atomic_int_least64_t + typedef atomic atomic_int_least64_t; + + /// atomic_uint_least64_t + typedef atomic atomic_uint_least64_t; + + + /// atomic_int_fast8_t + typedef atomic atomic_int_fast8_t; + + /// atomic_uint_fast8_t + typedef atomic atomic_uint_fast8_t; + + /// atomic_int_fast16_t + typedef atomic atomic_int_fast16_t; + + /// atomic_uint_fast16_t + typedef atomic atomic_uint_fast16_t; + + /// atomic_int_fast32_t + typedef atomic atomic_int_fast32_t; + + /// atomic_uint_fast32_t + typedef atomic atomic_uint_fast32_t; + + /// atomic_int_fast64_t + typedef atomic atomic_int_fast64_t; + + /// atomic_uint_fast64_t + typedef atomic atomic_uint_fast64_t; +#endif + + + /// atomic_intptr_t + typedef atomic atomic_intptr_t; + + /// atomic_uintptr_t + typedef atomic atomic_uintptr_t; + + /// atomic_size_t + typedef atomic atomic_size_t; + + /// atomic_ptrdiff_t + typedef atomic atomic_ptrdiff_t; + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + /// atomic_intmax_t + typedef atomic atomic_intmax_t; + + /// atomic_uintmax_t + typedef atomic atomic_uintmax_t; +#endif + + // Function definitions, atomic_flag operations. + inline bool + atomic_flag_test_and_set_explicit(atomic_flag* __a, + memory_order __m) noexcept + { return __a->test_and_set(__m); } + + inline bool + atomic_flag_test_and_set_explicit(volatile atomic_flag* __a, + memory_order __m) noexcept + { return __a->test_and_set(__m); } + + inline void + atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept + { __a->clear(__m); } + + inline void + atomic_flag_clear_explicit(volatile atomic_flag* __a, + memory_order __m) noexcept + { __a->clear(__m); } + + inline bool + atomic_flag_test_and_set(atomic_flag* __a) noexcept + { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } + + inline bool + atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept + { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } + + inline void + atomic_flag_clear(atomic_flag* __a) noexcept + { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } + + inline void + atomic_flag_clear(volatile atomic_flag* __a) noexcept + { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3220. P0558 broke conforming C++14 uses of atomic shared_ptr + template + using __atomic_val_t = __type_identity_t<_Tp>; + template + using __atomic_diff_t = typename atomic<_Tp>::difference_type; + + // [atomics.nonmembers] Non-member functions. + // Function templates generally applicable to atomic types. + template + inline bool + atomic_is_lock_free(const atomic<_ITp>* __a) noexcept + { return __a->is_lock_free(); } + + template + inline bool + atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept + { return __a->is_lock_free(); } + + template + inline void + atomic_init(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { __a->store(__i, memory_order_relaxed); } + + template + inline void + atomic_init(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { __a->store(__i, memory_order_relaxed); } + + template + inline void + atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { __a->store(__i, __m); } + + template + inline void + atomic_store_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { __a->store(__i, __m); } + + template + inline _ITp + atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept + { return __a->load(__m); } + + template + inline _ITp + atomic_load_explicit(const volatile atomic<_ITp>* __a, + memory_order __m) noexcept + { return __a->load(__m); } + + template + inline _ITp + atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->exchange(__i, __m); } + + template + inline _ITp + atomic_exchange_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->exchange(__i, __m); } + + template + inline bool + atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } + + + template + inline void + atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { atomic_store_explicit(__a, __i, memory_order_seq_cst); } + + template + inline void + atomic_store(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { atomic_store_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_load(const atomic<_ITp>* __a) noexcept + { return atomic_load_explicit(__a, memory_order_seq_cst); } + + template + inline _ITp + atomic_load(const volatile atomic<_ITp>* __a) noexcept + { return atomic_load_explicit(__a, memory_order_seq_cst); } + + template + inline _ITp + atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_exchange(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } + + template + inline bool + atomic_compare_exchange_weak(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_strong(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_strong(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + +#if __cpp_lib_atomic_wait + template + inline void + atomic_wait(const atomic<_Tp>* __a, + typename std::atomic<_Tp>::value_type __old) noexcept + { __a->wait(__old); } + + template + inline void + atomic_wait_explicit(const atomic<_Tp>* __a, + typename std::atomic<_Tp>::value_type __old, + std::memory_order __m) noexcept + { __a->wait(__old, __m); } + + template + inline void + atomic_notify_one(atomic<_Tp>* __a) noexcept + { __a->notify_one(); } + + template + inline void + atomic_notify_all(atomic<_Tp>* __a) noexcept + { __a->notify_all(); } +#endif // __cpp_lib_atomic_wait + + // Function templates for atomic_integral and atomic_pointer operations only. + // Some operations (and, or, xor) are only available for atomic integrals, + // which is implemented by taking a parameter of type __atomic_base<_ITp>*. + + template + inline _ITp + atomic_fetch_add_explicit(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_add(__i, __m); } + + template + inline _ITp + atomic_fetch_add_explicit(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_add(__i, __m); } + + template + inline _ITp + atomic_fetch_sub_explicit(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_sub(__i, __m); } + + template + inline _ITp + atomic_fetch_sub_explicit(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_sub(__i, __m); } + + template + inline _ITp + atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_and(__i, __m); } + + template + inline _ITp + atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_and(__i, __m); } + + template + inline _ITp + atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_or(__i, __m); } + + template + inline _ITp + atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_or(__i, __m); } + + template + inline _ITp + atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_xor(__i, __m); } + + template + inline _ITp + atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_xor(__i, __m); } + + template + inline _ITp + atomic_fetch_add(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_add(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_sub(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_sub(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_and(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_and(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_or(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_or(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_xor(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } + +#if __cplusplus > 201703L +#define __cpp_lib_atomic_float 201711L + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(float __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(double __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(long double __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + +#define __cpp_lib_atomic_ref 201806L + + /// Class template to provide atomic operations on a non-atomic variable. + template + struct atomic_ref : __atomic_ref<_Tp> + { + explicit + atomic_ref(_Tp& __t) noexcept : __atomic_ref<_Tp>(__t) + { } + + atomic_ref& operator=(const atomic_ref&) = delete; + + atomic_ref(const atomic_ref&) = default; + + using __atomic_ref<_Tp>::operator=; + }; + +#endif // C++2a + + /// @} group atomics + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_ATOMIC diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic.blob new file mode 100644 index 0000000000000000000000000000000000000000..c5d3ff0d565b8872ffe69f81db938249e26db894 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@atomic.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h new file mode 100644 index 0000000000000000000000000000000000000000..8725504d4c92303fbe8e1782e10d393d760c7703 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h @@ -0,0 +1,337 @@ +// auto_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file backward/auto_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _BACKWARD_AUTO_PTR_H +#define _BACKWARD_AUTO_PTR_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * A wrapper class to provide auto_ptr with reference semantics. + * For example, an auto_ptr can be assigned (or constructed from) + * the result of a function which returns an auto_ptr by value. + * + * All the auto_ptr_ref stuff should happen behind the scenes. + */ + template + struct auto_ptr_ref + { + _Tp1* _M_ptr; + + explicit + auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { } + } _GLIBCXX11_DEPRECATED; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /** + * @brief A simple smart pointer providing strict ownership semantics. + * + * The Standard says: + *
+   *  An @c auto_ptr owns the object it holds a pointer to.  Copying
+   *  an @c auto_ptr copies the pointer and transfers ownership to the
+   *  destination.  If more than one @c auto_ptr owns the same object
+   *  at the same time the behavior of the program is undefined.
+   *
+   *  The uses of @c auto_ptr include providing temporary
+   *  exception-safety for dynamically allocated memory, passing
+   *  ownership of dynamically allocated memory to a function, and
+   *  returning dynamically allocated memory from a function.  @c
+   *  auto_ptr does not meet the CopyConstructible and Assignable
+   *  requirements for Standard Library container elements and thus
+   *  instantiating a Standard Library container with an @c auto_ptr
+   *  results in undefined behavior.
+   *  
+ * Quoted from [20.4.5]/3. + * + * Good examples of what can and cannot be done with auto_ptr can + * be found in the libstdc++ testsuite. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * 127. auto_ptr<> conversion issues + * These resolutions have all been incorporated. + */ + template + class auto_ptr + { + private: + _Tp* _M_ptr; + + public: + /// The pointed-to type. + typedef _Tp element_type; + + /** + * @brief An %auto_ptr is usually constructed from a raw pointer. + * @param __p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a __p. + */ + explicit + auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { } + + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param __a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. + */ + auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { } + + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param __a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a + * pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. + */ + template + auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { } + + /** + * @brief %auto_ptr assignment operator. + * @param __a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. The object that this one @e + * used to own and track has been deleted. + */ + auto_ptr& + operator=(auto_ptr& __a) throw() + { + reset(__a.release()); + return *this; + } + + /** + * @brief %auto_ptr assignment operator. + * @param __a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. The object that this one @e + * used to own and track has been deleted. + */ + template + auto_ptr& + operator=(auto_ptr<_Tp1>& __a) throw() + { + reset(__a.release()); + return *this; + } + + /** + * When the %auto_ptr goes out of scope, the object it owns is + * deleted. If it no longer owns anything (i.e., @c get() is + * @c NULL), then this has no effect. + * + * The C++ standard says there is supposed to be an empty throw + * specification here, but omitting it is standard conforming. Its + * presence can be detected only if _Tp::~_Tp() throws, but this is + * prohibited. [17.4.3.6]/2 + */ + ~auto_ptr() { delete _M_ptr; } + + /** + * @brief Smart pointer dereferencing. + * + * If this %auto_ptr no longer owns anything, then this + * operation will crash. (For a smart pointer, no longer owns + * anything is the same as being a null pointer, and you know + * what happens when you dereference one of those...) + */ + element_type& + operator*() const throw() + { + __glibcxx_assert(_M_ptr != 0); + return *_M_ptr; + } + + /** + * @brief Smart pointer dereferencing. + * + * This returns the pointer itself, which the language then will + * automatically cause to be dereferenced. + */ + element_type* + operator->() const throw() + { + __glibcxx_assert(_M_ptr != 0); + return _M_ptr; + } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts + * a raw pointer. + * + * @note This %auto_ptr still owns the memory. + */ + element_type* + get() const throw() { return _M_ptr; } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts + * a raw pointer. + * + * @note This %auto_ptr no longer owns the memory. When this object + * goes out of scope, nothing will happen. + */ + element_type* + release() throw() + { + element_type* __tmp = _M_ptr; + _M_ptr = 0; + return __tmp; + } + + /** + * @brief Forcibly deletes the managed object. + * @param __p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a __p. The + * previous object has been deleted. + */ + void + reset(element_type* __p = 0) throw() + { + if (__p != _M_ptr) + { + delete _M_ptr; + _M_ptr = __p; + } + } + + /** + * @brief Automatic conversions + * + * These operations are supposed to convert an %auto_ptr into and from + * an auto_ptr_ref automatically as needed. This would allow + * constructs such as + * @code + * auto_ptr func_returning_auto_ptr(.....); + * ... + * auto_ptr ptr = func_returning_auto_ptr(.....); + * @endcode + * + * But it doesn't work, and won't be fixed. For further details see + * http://cplusplus.github.io/LWG/lwg-closed.html#463 + */ + auto_ptr(auto_ptr_ref __ref) throw() + : _M_ptr(__ref._M_ptr) { } + + auto_ptr& + operator=(auto_ptr_ref __ref) throw() + { + if (__ref._M_ptr != this->get()) + { + delete _M_ptr; + _M_ptr = __ref._M_ptr; + } + return *this; + } + + template + operator auto_ptr_ref<_Tp1>() throw() + { return auto_ptr_ref<_Tp1>(this->release()); } + + template + operator auto_ptr<_Tp1>() throw() + { return auto_ptr<_Tp1>(this->release()); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::unique_ptr"); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 541. shared_ptr template assignment and void + template<> + class auto_ptr + { + public: + typedef void element_type; + } _GLIBCXX11_DEPRECATED; + +#if __cplusplus >= 201103L + template<_Lock_policy _Lp> + template + inline + __shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r) + : _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get())) + { __r.release(); } + + template + template + inline + __shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Tp1>&& __r) + : _M_ptr(__r.get()), _M_refcount() + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + static_assert( sizeof(_Tp1) > 0, "incomplete type" ); + _Tp1* __tmp = __r.get(); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__tmp); + } + + template + template + inline + shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r) + : __shared_ptr<_Tp>(std::move(__r)) { } + + template + template + inline + unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept + : _M_t(__u.release(), deleter_type()) { } +#endif + +#pragma GCC diagnostic pop + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _BACKWARD_AUTO_PTR_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..43bf903859fe40e1b1e4d6f221f3389ecdd7cc61 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@auto_ptr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h new file mode 100644 index 0000000000000000000000000000000000000000..5eac6c0881d16dbf6006051ce4a165fe0ce9825c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h @@ -0,0 +1,184 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file backward/binders.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _BACKWARD_BINDERS_H +#define _BACKWARD_BINDERS_H 1 + +// Suppress deprecated warning for this file. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 20.3.6 binders + /** @defgroup binders Binder Classes + * @ingroup functors + * + * Binders turn functions/functors with two arguments into functors + * with a single argument, storing an argument to be applied later. + * For example, a variable @c B of type @c binder1st is constructed + * from a functor @c f and an argument @c x. Later, B's @c + * operator() is called with a single argument @c y. The return + * value is the value of @c f(x,y). @c B can be @a called with + * various arguments (y1, y2, ...) and will in turn call @c + * f(x,y1), @c f(x,y2), ... + * + * The function @c bind1st is provided to save some typing. It takes the + * function and an argument as parameters, and returns an instance of + * @c binder1st. + * + * The type @c binder2nd and its creator function @c bind2nd do the same + * thing, but the stored argument is passed as the second parameter instead + * of the first, e.g., @c bind2nd(std::minus(),1.3) will create a + * functor whose @c operator() accepts a floating-point number, subtracts + * 1.3 from it, and returns the result. (If @c bind1st had been used, + * the functor would perform 1.3 - x instead. + * + * Creator-wrapper functions like @c bind1st are intended to be used in + * calling algorithms. Their return values will be temporary objects. + * (The goal is to not require you to type names like + * @c std::binder1st> for declaring a variable to hold the + * return value from @c bind1st(std::plus(),5). + * + * These become more useful when combined with the composition functions. + * + * These functions are deprecated in C++11 and can be replaced by + * @c std::bind (or @c std::tr1::bind) which is more powerful and flexible, + * supporting functions with any number of arguments. Uses of @c bind1st + * can be replaced by @c std::bind(f, x, std::placeholders::_1) and + * @c bind2nd by @c std::bind(f, std::placeholders::_1, x). + * @{ + */ + /// One of the @link binders binder functors@endlink. + template + class binder1st + : public unary_function + { + protected: + _Operation op; + typename _Operation::first_argument_type value; + + public: + binder1st(const _Operation& __x, + const typename _Operation::first_argument_type& __y) + : op(__x), value(__y) { } + + typename _Operation::result_type + operator()(const typename _Operation::second_argument_type& __x) const + { return op(value, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 109. Missing binders for non-const sequence elements + typename _Operation::result_type + operator()(typename _Operation::second_argument_type& __x) const + { return op(value, __x); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind"); + + /// One of the @link binders binder functors@endlink. + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::bind") + 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)); + } + + /// One of the @link binders binder functors@endlink. + template + class binder2nd + : public unary_function + { + protected: + _Operation op; + typename _Operation::second_argument_type value; + + public: + binder2nd(const _Operation& __x, + const typename _Operation::second_argument_type& __y) + : op(__x), value(__y) { } + + typename _Operation::result_type + operator()(const typename _Operation::first_argument_type& __x) const + { return op(__x, value); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 109. Missing binders for non-const sequence elements + typename _Operation::result_type + operator()(typename _Operation::first_argument_type& __x) const + { return op(__x, value); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind"); + + /// One of the @link binders binder functors@endlink. + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::bind") + 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)); + } + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#pragma GCC diagnostic pop + +#endif /* _BACKWARD_BINDERS_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0b72b1f1556d579d24af31c8a83fa06262df00b0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@backward@binders.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit new file mode 100644 index 0000000000000000000000000000000000000000..ef19d649e32ded777c8622dd10e77b12ba208b3b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit @@ -0,0 +1,480 @@ +// -*- C++ -*- + +// Copyright (C) 2018-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bit + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BIT +#define _GLIBCXX_BIT 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include + +#if _GLIBCXX_HOSTED +# include +#else +# include +/// @cond undocumented +namespace __gnu_cxx +{ + template + struct __int_traits + { + static constexpr int __digits = std::numeric_limits<_Tp>::digits; + static constexpr _Tp __max = std::numeric_limits<_Tp>::max(); + }; +} +/// @endcond +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup bit_manip Bit manipulation + * @ingroup numerics + * + * Utilities for examining and manipulating individual bits. + * + * @{ + */ + +#if __cplusplus > 201703l && __has_builtin(__builtin_bit_cast) +#define __cpp_lib_bit_cast 201806L + + /// Create a value of type `To` from the bits of `from`. + /** + * @tparam _To A trivially-copyable type. + * @param __from A trivially-copyable object of the same size as `_To`. + * @return An object of type `_To`. + * @since C++20 + */ + template + [[nodiscard]] + constexpr _To + bit_cast(const _From& __from) noexcept +#ifdef __cpp_concepts + requires (sizeof(_To) == sizeof(_From)) + && __is_trivially_copyable(_To) && __is_trivially_copyable(_From) +#endif + { + return __builtin_bit_cast(_To, __from); + } +#endif + +#if __cplusplus > 202002L +#define __cpp_lib_byteswap 202110L + + /// Reverse order of bytes in the object representation of `value`. + /** + * @tparam _Tp An integral type. + * @param __value An object of integer type. + * @return An object of the same type, with the bytes reversed. + * @since C++23 + */ + template + [[nodiscard]] + constexpr enable_if_t::value, _Tp> + byteswap(_Tp __value) noexcept + { + if constexpr (sizeof(_Tp) == 1) + return __value; +#if __cpp_if_consteval >= 202106L && __CHAR_BIT__ == 8 + if !consteval + { + if constexpr (sizeof(_Tp) == 2) + return __builtin_bswap16(__value); + if constexpr (sizeof(_Tp) == 4) + return __builtin_bswap32(__value); + if constexpr (sizeof(_Tp) == 8) + return __builtin_bswap64(__value); + if constexpr (sizeof(_Tp) == 16) +#if __has_builtin(__builtin_bswap128) + return __builtin_bswap128(__value); +#else + return (__builtin_bswap64(__value >> 64) + | (static_cast<_Tp>(__builtin_bswap64(__value)) << 64)); +#endif + } +#endif + + // Fallback implementation that handles even __int24 etc. + using _Up = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; + size_t __diff = __CHAR_BIT__ * (sizeof(_Tp) - 1); + _Up __mask1 = static_cast(~0); + _Up __mask2 = __mask1 << __diff; + _Up __val = __value; + for (size_t __i = 0; __i < sizeof(_Tp) / 2; ++__i) + { + _Up __byte1 = __val & __mask1; + _Up __byte2 = __val & __mask2; + __val = (__val ^ __byte1 ^ __byte2 + ^ (__byte1 << __diff) ^ (__byte2 >> __diff)); + __mask1 <<= __CHAR_BIT__; + __mask2 >>= __CHAR_BIT__; + __diff -= 2 * __CHAR_BIT__; + } + return __val; + } +#endif + + /// @cond undoc + + template + constexpr _Tp + __rotl(_Tp __x, int __s) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0) + { + // Variant for power of two _Nd which the compiler can + // easily pattern match. + constexpr unsigned __uNd = _Nd; + const unsigned __r = __s; + return (__x << (__r % __uNd)) | (__x >> ((-__r) % __uNd)); + } + const int __r = __s % _Nd; + if (__r == 0) + return __x; + else if (__r > 0) + return (__x << __r) | (__x >> ((_Nd - __r) % _Nd)); + else + return (__x >> -__r) | (__x << ((_Nd + __r) % _Nd)); // rotr(x, -r) + } + + template + constexpr _Tp + __rotr(_Tp __x, int __s) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0) + { + // Variant for power of two _Nd which the compiler can + // easily pattern match. + constexpr unsigned __uNd = _Nd; + const unsigned __r = __s; + return (__x >> (__r % __uNd)) | (__x << ((-__r) % __uNd)); + } + const int __r = __s % _Nd; + if (__r == 0) + return __x; + else if (__r > 0) + return (__x >> __r) | (__x << ((_Nd - __r) % _Nd)); + else + return (__x << -__r) | (__x >> ((_Nd + __r) % _Nd)); // rotl(x, -r) + } + + template + constexpr int + __countl_zero(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + if (__x == 0) + return _Nd; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + { + constexpr int __diff = _Nd_u - _Nd; + return __builtin_clz(__x) - __diff; + } + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + { + constexpr int __diff = _Nd_ul - _Nd; + return __builtin_clzl(__x) - __diff; + } + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + { + constexpr int __diff = _Nd_ull - _Nd; + return __builtin_clzll(__x) - __diff; + } + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + unsigned long long __high = __x >> _Nd_ull; + if (__high != 0) + { + constexpr int __diff = (2 * _Nd_ull) - _Nd; + return __builtin_clzll(__high) - __diff; + } + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + return (_Nd - _Nd_ull) + __builtin_clzll(__low); + } + } + + template + constexpr int + __countl_one(_Tp __x) noexcept + { + return std::__countl_zero<_Tp>((_Tp)~__x); + } + + template + constexpr int + __countr_zero(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + if (__x == 0) + return _Nd; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + return __builtin_ctz(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + return __builtin_ctzl(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + return __builtin_ctzll(__x); + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + if (__low != 0) + return __builtin_ctzll(__low); + unsigned long long __high = __x >> _Nd_ull; + return __builtin_ctzll(__high) + _Nd_ull; + } + } + + template + constexpr int + __countr_one(_Tp __x) noexcept + { + return std::__countr_zero((_Tp)~__x); + } + + template + constexpr int + __popcount(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + return __builtin_popcount(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + return __builtin_popcountl(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + return __builtin_popcountll(__x); + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + unsigned long long __high = __x >> _Nd_ull; + return __builtin_popcountll(__low) + __builtin_popcountll(__high); + } + } + + template + constexpr bool + __has_single_bit(_Tp __x) noexcept + { return std::__popcount(__x) == 1; } + + template + constexpr _Tp + __bit_ceil(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + if (__x == 0 || __x == 1) + return 1; + auto __shift_exponent = _Nd - std::__countl_zero((_Tp)(__x - 1u)); + // If the shift exponent equals _Nd then the correct result is not + // representable as a value of _Tp, and so the result is undefined. + // Want that undefined behaviour to be detected in constant expressions, + // by UBSan, and by debug assertions. + if (!std::__is_constant_evaluated()) + { + __glibcxx_assert( __shift_exponent != __int_traits<_Tp>::__digits ); + } + + using __promoted_type = decltype(__x << 1); + if _GLIBCXX17_CONSTEXPR (!is_same<__promoted_type, _Tp>::value) + { + // If __x undergoes integral promotion then shifting by _Nd is + // not undefined. In order to make the shift undefined, so that + // it is diagnosed in constant expressions and by UBsan, we also + // need to "promote" the shift exponent to be too large for the + // promoted type. + const int __extra_exp = sizeof(__promoted_type) / sizeof(_Tp) / 2; + __shift_exponent |= (__shift_exponent & _Nd) << __extra_exp; + } + return (_Tp)1u << __shift_exponent; + } + + template + constexpr _Tp + __bit_floor(_Tp __x) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if (__x == 0) + return 0; + return (_Tp)1u << (_Nd - std::__countl_zero((_Tp)(__x >> 1))); + } + + template + constexpr _Tp + __bit_width(_Tp __x) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + return _Nd - std::__countl_zero(__x); + } + + /// @endcond + +#if __cplusplus > 201703L + +#define __cpp_lib_bitops 201907L + + /// @cond undoc + template + using _If_is_unsigned_integer + = enable_if_t<__is_unsigned_integer<_Tp>::value, _Up>; + /// @endcond + + // [bit.rot], rotating + + /// Rotate `x` to the left by `s` bits. + template + [[nodiscard]] constexpr _If_is_unsigned_integer<_Tp> + rotl(_Tp __x, int __s) noexcept + { return std::__rotl(__x, __s); } + + /// Rotate `x` to the right by `s` bits. + template + [[nodiscard]] constexpr _If_is_unsigned_integer<_Tp> + rotr(_Tp __x, int __s) noexcept + { return std::__rotr(__x, __s); } + + // [bit.count], counting + + /// The number of contiguous zero bits, starting from the highest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countl_zero(_Tp __x) noexcept + { return std::__countl_zero(__x); } + + /// The number of contiguous one bits, starting from the highest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countl_one(_Tp __x) noexcept + { return std::__countl_one(__x); } + + /// The number of contiguous zero bits, starting from the lowest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countr_zero(_Tp __x) noexcept + { return std::__countr_zero(__x); } + + /// The number of contiguous one bits, starting from the lowest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countr_one(_Tp __x) noexcept + { return std::__countr_one(__x); } + + /// The number of bits set in `x`. + template + constexpr _If_is_unsigned_integer<_Tp, int> + popcount(_Tp __x) noexcept + { return std::__popcount(__x); } + + // [bit.pow.two], integral powers of 2 + +#define __cpp_lib_int_pow2 202002L + + /// True if `x` is a power of two, false otherwise. + template + constexpr _If_is_unsigned_integer<_Tp, bool> + has_single_bit(_Tp __x) noexcept + { return std::__has_single_bit(__x); } + + /// The smallest power-of-two not less than `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_ceil(_Tp __x) noexcept + { return std::__bit_ceil(__x); } + + /// The largest power-of-two not greater than `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_floor(_Tp __x) noexcept + { return std::__bit_floor(__x); } + + /// The smallest integer greater than the base-2 logarithm of `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_width(_Tp __x) noexcept + { return std::__bit_width(__x); } + +#define __cpp_lib_endian 201907L + + /// Byte order constants + /** + * The platform endianness can be checked by comparing `std::endian::native` + * to one of `std::endian::big` or `std::endian::little`. + * + * @since C++20 + */ + enum class endian + { + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ + }; +#endif // C++2a + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 +#endif // _GLIBCXX_BIT diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit.blob new file mode 100644 index 0000000000000000000000000000000000000000..6e6c8262a2700c0fd92ea8e0c69f2ebe5a63ba42 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bit.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h new file mode 100644 index 0000000000000000000000000000000000000000..5271a90b50154e98446bd206e3085880aac1926d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h @@ -0,0 +1,967 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/algorithmfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _GLIBCXX_ALGORITHMFWD_H +#define _GLIBCXX_ALGORITHMFWD_H 1 + +#pragma GCC system_header + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /* + adjacent_find + all_of (C++11) + any_of (C++11) + binary_search + clamp (C++17) + copy + copy_backward + copy_if (C++11) + copy_n (C++11) + count + count_if + equal + equal_range + fill + fill_n + find + find_end + find_first_of + find_if + find_if_not (C++11) + for_each + generate + generate_n + includes + inplace_merge + is_heap (C++11) + is_heap_until (C++11) + is_partitioned (C++11) + is_sorted (C++11) + is_sorted_until (C++11) + iter_swap + lexicographical_compare + lower_bound + make_heap + max + max_element + merge + min + min_element + minmax (C++11) + minmax_element (C++11) + mismatch + next_permutation + none_of (C++11) + nth_element + partial_sort + partial_sort_copy + partition + partition_copy (C++11) + partition_point (C++11) + pop_heap + prev_permutation + push_heap + random_shuffle + remove + remove_copy + remove_copy_if + remove_if + replace + replace_copy + replace_copy_if + replace_if + reverse + reverse_copy + rotate + rotate_copy + search + search_n + set_difference + set_intersection + set_symmetric_difference + set_union + shuffle (C++11) + sort + sort_heap + stable_partition + stable_sort + swap + swap_ranges + transform + unique + unique_copy + upper_bound + */ + + /** + * @defgroup algorithms Algorithms + * + * Components for performing algorithmic operations. Includes + * non-modifying sequence, modifying (mutating) sequence, sorting, + * searching, merge, partition, heap, set, minima, maxima, and + * permutation operations. + */ + + /** + * @defgroup mutating_algorithms Mutating + * @ingroup algorithms + */ + + /** + * @defgroup non_mutating_algorithms Non-Mutating + * @ingroup algorithms + */ + + /** + * @defgroup sorting_algorithms Sorting + * @ingroup algorithms + */ + + /** + * @defgroup set_algorithms Set Operations + * @ingroup sorting_algorithms + * + * These algorithms are common set operations performed on sequences + * that are already sorted. The number of comparisons will be + * linear. + */ + + /** + * @defgroup binary_search_algorithms Binary Search + * @ingroup sorting_algorithms + * + * These algorithms are variations of a classic binary search, and + * all assume that the sequence being searched is already sorted. + * + * The number of comparisons will be logarithmic (and as few as + * possible). The number of steps through the sequence will be + * logarithmic for random-access iterators (e.g., pointers), and + * linear otherwise. + * + * The LWG has passed Defect Report 270, which notes: The + * proposed resolution reinterprets binary search. Instead of + * thinking about searching for a value in a sorted range, we view + * that as an important special case of a more general algorithm: + * searching for the partition point in a partitioned range. We + * also add a guarantee that the old wording did not: we ensure that + * the upper bound is no earlier than the lower bound, that the pair + * returned by equal_range is a valid range, and that the first part + * of that pair is the lower bound. + * + * The actual effect of the first sentence is that a comparison + * functor passed by the user doesn't necessarily need to induce a + * strict weak ordering relation. Rather, it partitions the range. + */ + + // adjacent_find + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_algorithms 201806L +#endif + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + all_of(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + any_of(_IIter, _IIter, _Predicate); +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_FIter, _FIter, const _Tp&, _Compare); + +#if __cplusplus > 201402L + template + _GLIBCXX14_CONSTEXPR + const _Tp& + clamp(const _Tp&, const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + clamp(const _Tp&, const _Tp&, const _Tp&, _Compare); +#endif + + template + _GLIBCXX20_CONSTEXPR + _OIter + copy(_IIter, _IIter, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _BIter2 + copy_backward(_BIter1, _BIter1, _BIter2); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + _OIter + copy_if(_IIter, _IIter, _OIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + copy_n(_IIter, _Size, _OIter); +#endif + + // count + // count_if + + template + _GLIBCXX20_CONSTEXPR + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + fill(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + fill_n(_OIter, _Size, const _Tp&); + + // find + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + // find_first_of + // find_if + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + _IIter + find_if_not(_IIter, _IIter, _Predicate); +#endif + + // for_each + // generate + // generate_n + + template + _GLIBCXX20_CONSTEXPR + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + template + void + inplace_merge(_BIter, _BIter, _BIter); + + template + void + inplace_merge(_BIter, _BIter, _BIter, _Compare); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + is_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + bool + is_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + is_heap_until(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + is_heap_until(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + bool + is_partitioned(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + is_permutation(_FIter1, _FIter1, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + bool + is_sorted(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + bool + is_sorted(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _FIter + is_sorted_until(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + is_sorted_until(_FIter, _FIter, _Compare); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + iter_swap(_FIter1, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter + lower_bound(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + lower_bound(_FIter, _FIter, const _Tp&, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + make_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + make_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + max(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + max(const _Tp&, const _Tp&, _Compare); + + // max_element + // merge + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + min(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + min(const _Tp&, const _Tp&, _Compare); + + // min_element + +#if __cplusplus >= 201103L + template + _GLIBCXX14_CONSTEXPR + pair + minmax(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + pair + minmax(const _Tp&, const _Tp&, _Compare); + + template + _GLIBCXX14_CONSTEXPR + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _Tp + min(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + _Tp + min(initializer_list<_Tp>, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _Tp + max(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + _Tp + max(initializer_list<_Tp>, _Compare); + + template + _GLIBCXX14_CONSTEXPR + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>, _Compare); +#endif + + // mismatch + + template + _GLIBCXX20_CONSTEXPR + bool + next_permutation(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + bool + next_permutation(_BIter, _BIter, _Compare); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + none_of(_IIter, _IIter, _Predicate); +#endif + + // nth_element + // partial_sort + + template + _GLIBCXX20_CONSTEXPR + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare); + + // partition + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + pair<_OIter1, _OIter2> + partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _FIter + partition_point(_FIter, _FIter, _Predicate); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + pop_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + pop_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + bool + prev_permutation(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + bool + prev_permutation(_BIter, _BIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + push_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + push_heap(_RAIter, _RAIter, _Compare); + + // random_shuffle + + template + _GLIBCXX20_CONSTEXPR + _FIter + remove(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + remove_if(_FIter, _FIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + remove_copy(_IIter, _IIter, _OIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + remove_copy_if(_IIter, _IIter, _OIter, _Predicate); + + // replace + + template + _GLIBCXX20_CONSTEXPR + _OIter + replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); + + // replace_if + + template + _GLIBCXX20_CONSTEXPR + void + reverse(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + reverse_copy(_BIter, _BIter, _OIter); + + inline namespace _V2 + { + template + _GLIBCXX20_CONSTEXPR + _FIter + rotate(_FIter, _FIter, _FIter); + } + + template + _GLIBCXX20_CONSTEXPR + _OIter + rotate_copy(_FIter, _FIter, _FIter, _OIter); + + // search + // search_n + // set_difference + // set_intersection + // set_symmetric_difference + // set_union + +#if (__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1) + template + void + shuffle(_RAIter, _RAIter, _UGenerator&&); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + sort_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + sort_heap(_RAIter, _RAIter, _Compare); + + template + _BIter + stable_partition(_BIter, _BIter, _Predicate); + +#if __cplusplus < 201103L + // For C++11 swap() is declared in . + + template + _GLIBCXX20_CONSTEXPR + inline void + swap(_Tp& __a, _Tp& __b); + + template + _GLIBCXX20_CONSTEXPR + inline void + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]); +#endif + + template + _GLIBCXX20_CONSTEXPR + _FIter2 + swap_ranges(_FIter1, _FIter1, _FIter2); + + // transform + + template + _GLIBCXX20_CONSTEXPR + _FIter + unique(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + unique(_FIter, _FIter, _BinaryPredicate); + + // unique_copy + + template + _GLIBCXX20_CONSTEXPR + _FIter + upper_bound(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + upper_bound(_FIter, _FIter, const _Tp&, _Compare); + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + template + _GLIBCXX20_CONSTEXPR + _FIter + adjacent_find(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + adjacent_find(_FIter, _FIter, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_IIter>::difference_type + count(_IIter, _IIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_IIter>::difference_type + count_if(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + equal(_IIter1, _IIter1, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _IIter + find(_IIter, _IIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _IIter + find_if(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _Funct + for_each(_IIter, _IIter, _Funct); + + template + _GLIBCXX20_CONSTEXPR + void + generate(_FIter, _FIter, _Generator); + + template + _GLIBCXX20_CONSTEXPR + _OIter + generate_n(_OIter, _Size, _Generator); + + template + _GLIBCXX20_CONSTEXPR + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _FIter + max_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + _FIter + max_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _FIter + min_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + _FIter + min_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + void + nth_element(_RAIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + nth_element(_RAIter, _RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + partial_sort(_RAIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + partial_sort(_RAIter, _RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _BIter + partition(_BIter, _BIter, _Predicate); + + template + void + random_shuffle(_RAIter, _RAIter); + + template + void + random_shuffle(_RAIter, _RAIter, +#if __cplusplus >= 201103L + _Generator&&); +#else + _Generator&); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + replace(_FIter, _FIter, const _Tp&, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + void + replace_if(_FIter, _FIter, _Predicate, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, + _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + sort(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + sort(_RAIter, _RAIter, _Compare); + + template + void + stable_sort(_RAIter, _RAIter); + + template + void + stable_sort(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + transform(_IIter, _IIter, _OIter, _UnaryOperation); + + template + _GLIBCXX20_CONSTEXPR + _OIter + transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); + + template + _GLIBCXX20_CONSTEXPR + _OIter + unique_copy(_IIter, _IIter, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); + +_GLIBCXX_END_NAMESPACE_ALGO +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8a14a8f14e4b67611c0cd10de7e24b3e185f25db Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@algorithmfwd.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h new file mode 100644 index 0000000000000000000000000000000000000000..31beb0a7ddc0b280a8b8dc19cd02b648df39b051 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h @@ -0,0 +1,111 @@ +// align implementation -*- C++ -*- + +// Copyright (C) 2014-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/align.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _GLIBCXX_ALIGN_H +#define _GLIBCXX_ALIGN_H 1 + +#include + +#include // std::has_single_bit +#include // uintptr_t +#include // _GLIBCXX_DEBUG_ASSERT + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @brief Fit aligned storage in buffer. + * + * This function tries to fit @a __size bytes of storage with alignment + * @a __align into the buffer @a __ptr of size @a __space bytes. If such + * a buffer fits then @a __ptr is changed to point to the first byte of the + * aligned storage and @a __space is reduced by the bytes used for alignment. + * + * C++11 20.6.5 [ptr.align] + * + * @param __align A fundamental or extended alignment value. + * @param __size Size of the aligned storage required. + * @param __ptr Pointer to a buffer of @a __space bytes. + * @param __space Size of the buffer pointed to by @a __ptr. + * @return the updated pointer if the aligned storage fits, otherwise nullptr. + * + * @ingroup memory + */ +inline void* +align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept +{ + if (__space < __size) + return nullptr; + const auto __intptr = reinterpret_cast(__ptr); + const auto __aligned = (__intptr - 1u + __align) & -__align; + const auto __diff = __aligned - __intptr; + if (__diff > (__space - __size)) + return nullptr; + else + { + __space -= __diff; + return __ptr = reinterpret_cast(__aligned); + } +} + +#if __cplusplus > 201703L +#define __cpp_lib_assume_aligned 201811L + /** @brief Inform the compiler that a pointer is aligned. + * + * @tparam _Align An alignment value (i.e. a power of two) + * @tparam _Tp An object type + * @param __ptr A pointer that is aligned to _Align + * + * C++20 20.10.6 [ptr.align] + * + * @ingroup memory + */ + template + [[nodiscard,__gnu__::__always_inline__]] + constexpr _Tp* + assume_aligned(_Tp* __ptr) noexcept + { + static_assert(std::has_single_bit(_Align)); + if (std::is_constant_evaluated()) + return __ptr; + else + { + // This function is expected to be used in hot code, where + // __glibcxx_assert would add unwanted overhead. + _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0); + return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); + } + } +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_ALIGN_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..027d06eedf7caf422c12da32da4537f5f3c40bdf Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@align.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..a4d06d3fc7ab6d191d9f42b70aa7d214ee53576f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h @@ -0,0 +1,855 @@ +// Allocator traits -*- C++ -*- + +// Copyright (C) 2011-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/alloc_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOC_TRAITS_H +#define _ALLOC_TRAITS_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201103L +#define __cpp_lib_allocator_traits_is_always_equal 201411L + + /// @cond undocumented + struct __allocator_traits_base + { + template + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template + struct __rebind<_Tp, _Up, + __void_t::other>> + { using type = typename _Tp::template rebind<_Up>::other; }; + + protected: + template + using __pointer = typename _Tp::pointer; + template + using __c_pointer = typename _Tp::const_pointer; + template + using __v_pointer = typename _Tp::void_pointer; + template + using __cv_pointer = typename _Tp::const_void_pointer; + template + using __pocca = typename _Tp::propagate_on_container_copy_assignment; + template + using __pocma = typename _Tp::propagate_on_container_move_assignment; + template + using __pocs = typename _Tp::propagate_on_container_swap; + template + using __equal = typename _Tp::is_always_equal; + }; + + template + using __alloc_rebind + = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type; + /// @endcond + + /** + * @brief Uniform interface to all allocator types. + * @headerfile memory + * @ingroup allocators + * @since C++11 + */ + template + struct allocator_traits : __allocator_traits_base + { + /// The allocator type + typedef _Alloc allocator_type; + /// The allocated type + typedef typename _Alloc::value_type value_type; + + /** + * @brief The allocator's pointer type. + * + * @c Alloc::pointer if that type exists, otherwise @c value_type* + */ + using pointer = __detected_or_t; + + private: + // Select _Func<_Alloc> or pointer_traits::rebind<_Tp> + template class _Func, typename _Tp, typename = void> + struct _Ptr + { + using type = typename pointer_traits::template rebind<_Tp>; + }; + + template class _Func, typename _Tp> + struct _Ptr<_Func, _Tp, __void_t<_Func<_Alloc>>> + { + using type = _Func<_Alloc>; + }; + + // Select _A2::difference_type or pointer_traits<_Ptr>::difference_type + template + struct _Diff + { using type = typename pointer_traits<_PtrT>::difference_type; }; + + template + struct _Diff<_A2, _PtrT, __void_t> + { using type = typename _A2::difference_type; }; + + // Select _A2::size_type or make_unsigned<_DiffT>::type + template + struct _Size : make_unsigned<_DiffT> { }; + + template + struct _Size<_A2, _DiffT, __void_t> + { using type = typename _A2::size_type; }; + + public: + /** + * @brief The allocator's const pointer type. + * + * @c Alloc::const_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using const_pointer = typename _Ptr<__c_pointer, const value_type>::type; + + /** + * @brief The allocator's void pointer type. + * + * @c Alloc::void_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using void_pointer = typename _Ptr<__v_pointer, void>::type; + + /** + * @brief The allocator's const void pointer type. + * + * @c Alloc::const_void_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type; + + /** + * @brief The allocator's difference type + * + * @c Alloc::difference_type if that type exists, otherwise + * pointer_traits::difference_type + */ + using difference_type = typename _Diff<_Alloc, pointer>::type; + + /** + * @brief The allocator's size type + * + * @c Alloc::size_type if that type exists, otherwise + * make_unsigned::type + */ + using size_type = typename _Size<_Alloc, difference_type>::type; + + /** + * @brief How the allocator is propagated on copy assignment + * + * @c Alloc::propagate_on_container_copy_assignment if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_copy_assignment + = __detected_or_t; + + /** + * @brief How the allocator is propagated on move assignment + * + * @c Alloc::propagate_on_container_move_assignment if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_move_assignment + = __detected_or_t; + + /** + * @brief How the allocator is propagated on swap + * + * @c Alloc::propagate_on_container_swap if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_swap + = __detected_or_t; + + /** + * @brief Whether all instances of the allocator type compare equal. + * + * @c Alloc::is_always_equal if that type exists, + * otherwise @c is_empty::type + */ + using is_always_equal + = __detected_or_t::type, __equal, _Alloc>; + + template + using rebind_alloc = __alloc_rebind<_Alloc, _Tp>; + template + using rebind_traits = allocator_traits>; + + private: + template + static constexpr auto + _S_allocate(_Alloc2& __a, size_type __n, const_void_pointer __hint, int) + -> decltype(__a.allocate(__n, __hint)) + { return __a.allocate(__n, __hint); } + + template + static constexpr pointer + _S_allocate(_Alloc2& __a, size_type __n, const_void_pointer, ...) + { return __a.allocate(__n); } + + template + struct __construct_helper + { + template()->construct( + std::declval<_Tp*>(), std::declval<_Args>()...))> + static true_type __test(int); + + template + static false_type __test(...); + + using type = decltype(__test<_Alloc>(0)); + }; + + template + using __has_construct + = typename __construct_helper<_Tp, _Args...>::type; + + template + static _GLIBCXX14_CONSTEXPR _Require<__has_construct<_Tp, _Args...>> + _S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...))) + { __a.construct(__p, std::forward<_Args>(__args)...); } + + template + static _GLIBCXX14_CONSTEXPR + _Require<__and_<__not_<__has_construct<_Tp, _Args...>>, + is_constructible<_Tp, _Args...>>> + _S_construct(_Alloc&, _Tp* __p, _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Tp, _Args...>::value) + { +#if __cplusplus <= 201703L + ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); +#else + std::construct_at(__p, std::forward<_Args>(__args)...); +#endif + } + + template + static _GLIBCXX14_CONSTEXPR auto + _S_destroy(_Alloc2& __a, _Tp* __p, int) + noexcept(noexcept(__a.destroy(__p))) + -> decltype(__a.destroy(__p)) + { __a.destroy(__p); } + + template + static _GLIBCXX14_CONSTEXPR void + _S_destroy(_Alloc2&, _Tp* __p, ...) + noexcept(std::is_nothrow_destructible<_Tp>::value) + { std::_Destroy(__p); } + + template + static constexpr auto + _S_max_size(_Alloc2& __a, int) + -> decltype(__a.max_size()) + { return __a.max_size(); } + + template + static constexpr size_type + _S_max_size(_Alloc2&, ...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2466. allocator_traits::max_size() default behavior is incorrect + return __gnu_cxx::__numeric_traits::__max + / sizeof(value_type); + } + + template + static constexpr auto + _S_select(_Alloc2& __a, int) + -> decltype(__a.select_on_container_copy_construction()) + { return __a.select_on_container_copy_construction(); } + + template + static constexpr _Alloc2 + _S_select(_Alloc2& __a, ...) + { return __a; } + + public: + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * + * Calls @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(_Alloc& __a, size_type __n) + { return __a.allocate(__n); } + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * @param __hint Aid to locality. + * @return Memory of suitable size and alignment for @a n objects + * of type @c value_type + * + * Returns a.allocate(n, hint) if that expression is + * well-formed, otherwise returns @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(_Alloc& __a, size_type __n, const_void_pointer __hint) + { return _S_allocate(__a, __n, __hint, 0); } + + /** + * @brief Deallocate memory. + * @param __a An allocator. + * @param __p Pointer to the memory to deallocate. + * @param __n The number of objects space was allocated for. + * + * Calls a.deallocate(p, n) + */ + static _GLIBCXX20_CONSTEXPR void + deallocate(_Alloc& __a, pointer __p, size_type __n) + { __a.deallocate(__p, __n); } + + /** + * @brief Construct an object of type `_Tp` + * @param __a An allocator. + * @param __p Pointer to memory of suitable size and alignment for Tp + * @param __args Constructor arguments. + * + * Calls __a.construct(__p, std::forward(__args)...) + * if that expression is well-formed, otherwise uses placement-new + * to construct an object of type @a _Tp at location @a __p from the + * arguments @a __args... + */ + template + static _GLIBCXX20_CONSTEXPR auto + construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(_S_construct(__a, __p, + std::forward<_Args>(__args)...))) + -> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...)) + { _S_construct(__a, __p, std::forward<_Args>(__args)...); } + + /** + * @brief Destroy an object of type @a _Tp + * @param __a An allocator. + * @param __p Pointer to the object to destroy + * + * Calls @c __a.destroy(__p) if that expression is well-formed, + * otherwise calls @c __p->~_Tp() + */ + template + static _GLIBCXX20_CONSTEXPR void + destroy(_Alloc& __a, _Tp* __p) + noexcept(noexcept(_S_destroy(__a, __p, 0))) + { _S_destroy(__a, __p, 0); } + + /** + * @brief The maximum supported allocation size + * @param __a An allocator. + * @return @c __a.max_size() or @c numeric_limits::max() + * + * Returns @c __a.max_size() if that expression is well-formed, + * otherwise returns @c numeric_limits::max() + */ + static _GLIBCXX20_CONSTEXPR size_type + max_size(const _Alloc& __a) noexcept + { return _S_max_size(__a, 0); } + + /** + * @brief Obtain an allocator to use when copying a container. + * @param __rhs An allocator. + * @return @c __rhs.select_on_container_copy_construction() or @a __rhs + * + * Returns @c __rhs.select_on_container_copy_construction() if that + * expression is well-formed, otherwise returns @a __rhs + */ + static _GLIBCXX20_CONSTEXPR _Alloc + select_on_container_copy_construction(const _Alloc& __rhs) + { return _S_select(__rhs, 0); } + }; + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_dynamic_alloc 201907L +#endif + + /// Partial specialization for std::allocator. + template + struct allocator_traits> + { + /// The allocator type + using allocator_type = allocator<_Tp>; + + /// The allocated type + using value_type = _Tp; + + /// The allocator's pointer type. + using pointer = _Tp*; + + /// The allocator's const pointer type. + using const_pointer = const _Tp*; + + /// The allocator's void pointer type. + using void_pointer = void*; + + /// The allocator's const void pointer type. + using const_void_pointer = const void*; + + /// The allocator's difference type + using difference_type = std::ptrdiff_t; + + /// The allocator's size type + using size_type = std::size_t; + + /// How the allocator is propagated on copy assignment + using propagate_on_container_copy_assignment = false_type; + + /// How the allocator is propagated on move assignment + using propagate_on_container_move_assignment = true_type; + + /// How the allocator is propagated on swap + using propagate_on_container_swap = false_type; + + /// Whether all instances of the allocator type compare equal. + using is_always_equal = true_type; + + template + using rebind_alloc = allocator<_Up>; + + template + using rebind_traits = allocator_traits>; + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * + * Calls @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(allocator_type& __a, size_type __n) + { return __a.allocate(__n); } + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * @param __hint Aid to locality. + * @return Memory of suitable size and alignment for @a n objects + * of type @c value_type + * + * Returns a.allocate(n, hint) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) + { +#if __cplusplus <= 201703L + return __a.allocate(__n, __hint); +#else + return __a.allocate(__n); +#endif + } + + /** + * @brief Deallocate memory. + * @param __a An allocator. + * @param __p Pointer to the memory to deallocate. + * @param __n The number of objects space was allocated for. + * + * Calls a.deallocate(p, n) + */ + static _GLIBCXX20_CONSTEXPR void + deallocate(allocator_type& __a, pointer __p, size_type __n) + { __a.deallocate(__p, __n); } + + /** + * @brief Construct an object of type `_Up` + * @param __a An allocator. + * @param __p Pointer to memory of suitable size and alignment for + * an object of type `_Up`. + * @param __args Constructor arguments. + * + * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` + * in C++11, C++14 and C++17. Changed in C++20 to call + * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. + */ + template + static _GLIBCXX20_CONSTEXPR void + construct(allocator_type& __a __attribute__((__unused__)), _Up* __p, + _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) + { +#if __cplusplus <= 201703L + __a.construct(__p, std::forward<_Args>(__args)...); +#else + std::construct_at(__p, std::forward<_Args>(__args)...); +#endif + } + + /** + * @brief Destroy an object of type @a _Up + * @param __a An allocator. + * @param __p Pointer to the object to destroy + * + * Calls @c __a.destroy(__p). + */ + template + static _GLIBCXX20_CONSTEXPR void + destroy(allocator_type& __a __attribute__((__unused__)), _Up* __p) + noexcept(is_nothrow_destructible<_Up>::value) + { +#if __cplusplus <= 201703L + __a.destroy(__p); +#else + std::destroy_at(__p); +#endif + } + + /** + * @brief The maximum supported allocation size + * @param __a An allocator. + * @return @c __a.max_size() + */ + static _GLIBCXX20_CONSTEXPR size_type + max_size(const allocator_type& __a __attribute__((__unused__))) noexcept + { +#if __cplusplus <= 201703L + return __a.max_size(); +#else + return size_t(-1) / sizeof(value_type); +#endif + } + + /** + * @brief Obtain an allocator to use when copying a container. + * @param __rhs An allocator. + * @return @c __rhs + */ + static _GLIBCXX20_CONSTEXPR allocator_type + select_on_container_copy_construction(const allocator_type& __rhs) + { return __rhs; } + }; + + /// Explicit specialization for std::allocator. + template<> + struct allocator_traits> + { + /// The allocator type + using allocator_type = allocator; + + /// The allocated type + using value_type = void; + + /// The allocator's pointer type. + using pointer = void*; + + /// The allocator's const pointer type. + using const_pointer = const void*; + + /// The allocator's void pointer type. + using void_pointer = void*; + + /// The allocator's const void pointer type. + using const_void_pointer = const void*; + + /// The allocator's difference type + using difference_type = std::ptrdiff_t; + + /// The allocator's size type + using size_type = std::size_t; + + /// How the allocator is propagated on copy assignment + using propagate_on_container_copy_assignment = false_type; + + /// How the allocator is propagated on move assignment + using propagate_on_container_move_assignment = true_type; + + /// How the allocator is propagated on swap + using propagate_on_container_swap = false_type; + + /// Whether all instances of the allocator type compare equal. + using is_always_equal = true_type; + + template + using rebind_alloc = allocator<_Up>; + + template + using rebind_traits = allocator_traits>; + + /// allocate is ill-formed for allocator + static void* + allocate(allocator_type&, size_type, const void* = nullptr) = delete; + + /// deallocate is ill-formed for allocator + static void + deallocate(allocator_type&, void*, size_type) = delete; + + /** + * @brief Construct an object of type `_Up` + * @param __a An allocator. + * @param __p Pointer to memory of suitable size and alignment for + * an object of type `_Up`. + * @param __args Constructor arguments. + * + * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` + * in C++11, C++14 and C++17. Changed in C++20 to call + * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. + */ + template + static _GLIBCXX20_CONSTEXPR void + construct(allocator_type&, _Up* __p, _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) + { std::_Construct(__p, std::forward<_Args>(__args)...); } + + /** + * @brief Destroy an object of type `_Up` + * @param __a An allocator. + * @param __p Pointer to the object to destroy + * + * Invokes the destructor for `*__p`. + */ + template + static _GLIBCXX20_CONSTEXPR void + destroy(allocator_type&, _Up* __p) + noexcept(is_nothrow_destructible<_Up>::value) + { std::_Destroy(__p); } + + /// max_size is ill-formed for allocator + static size_type + max_size(const allocator_type&) = delete; + + /** + * @brief Obtain an allocator to use when copying a container. + * @param __rhs An allocator. + * @return `__rhs` + */ + static _GLIBCXX20_CONSTEXPR allocator_type + select_on_container_copy_construction(const allocator_type& __rhs) + { return __rhs; } + }; + +#if __cplusplus < 201703L + template + inline void + __do_alloc_on_copy(_Alloc& __one, const _Alloc& __two, true_type) + { __one = __two; } + + template + inline void + __do_alloc_on_copy(_Alloc&, const _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_copy(_Alloc& __one, const _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_copy_assignment __pocca; +#if __cplusplus >= 201703L + if constexpr (__pocca::value) + __one = __two; +#else + __do_alloc_on_copy(__one, __two, __pocca()); +#endif + } + + template + constexpr _Alloc + __alloc_on_copy(const _Alloc& __a) + { + typedef allocator_traits<_Alloc> __traits; + return __traits::select_on_container_copy_construction(__a); + } + +#if __cplusplus < 201703L + template + inline void __do_alloc_on_move(_Alloc& __one, _Alloc& __two, true_type) + { __one = std::move(__two); } + + template + inline void __do_alloc_on_move(_Alloc&, _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_move(_Alloc& __one, _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_move_assignment __pocma; +#if __cplusplus >= 201703L + if constexpr (__pocma::value) + __one = std::move(__two); +#else + __do_alloc_on_move(__one, __two, __pocma()); +#endif + } + +#if __cplusplus < 201703L + template + inline void __do_alloc_on_swap(_Alloc& __one, _Alloc& __two, true_type) + { + using std::swap; + swap(__one, __two); + } + + template + inline void __do_alloc_on_swap(_Alloc&, _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_swap(_Alloc& __one, _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_swap __pocs; +#if __cplusplus >= 201703L + if constexpr (__pocs::value) + { + using std::swap; + swap(__one, __two); + } +#else + __do_alloc_on_swap(__one, __two, __pocs()); +#endif + } + + template, + typename = void> + struct __is_alloc_insertable_impl + : false_type + { }; + + template + struct __is_alloc_insertable_impl<_Alloc, _Tp, _ValueT, + __void_t::construct( + std::declval<_Alloc&>(), std::declval<_ValueT*>(), + std::declval<_Tp>()))>> + : true_type + { }; + + // true if _Alloc::value_type is CopyInsertable into containers using _Alloc + // (might be wrong if _Alloc::construct exists but is not constrained, + // i.e. actually trying to use it would still be invalid. Use with caution.) + template + struct __is_copy_insertable + : __is_alloc_insertable_impl<_Alloc, + typename _Alloc::value_type const&>::type + { }; + + // std::allocator<_Tp> just requires CopyConstructible + template + struct __is_copy_insertable> + : is_copy_constructible<_Tp> + { }; + + // true if _Alloc::value_type is MoveInsertable into containers using _Alloc + // (might be wrong if _Alloc::construct exists but is not constrained, + // i.e. actually trying to use it would still be invalid. Use with caution.) + template + struct __is_move_insertable + : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type + { }; + + // std::allocator<_Tp> just requires MoveConstructible + template + struct __is_move_insertable> + : is_move_constructible<_Tp> + { }; + + // Trait to detect Allocator-like types. + template + struct __is_allocator : false_type { }; + + template + struct __is_allocator<_Alloc, + __void_t().allocate(size_t{}))>> + : true_type { }; + + template + using _RequireAllocator + = typename enable_if<__is_allocator<_Alloc>::value, _Alloc>::type; + + template + using _RequireNotAllocator + = typename enable_if::value, _Alloc>::type; + +#if __cpp_concepts >= 201907L + template + concept __allocator_like = requires (_Alloc& __a) { + typename _Alloc::value_type; + __a.deallocate(__a.allocate(1u), 1u); + }; +#endif +#endif // C++11 + + /** + * Destroy a range of objects using the supplied allocator. For + * non-default allocators we do not optimize away invocation of + * destroy() even if _Tp has a trivial destructor. + */ + + template + _GLIBCXX20_CONSTEXPR + void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + _Allocator& __alloc) + { + for (; __first != __last; ++__first) +#if __cplusplus < 201103L + __alloc.destroy(std::__addressof(*__first)); +#else + allocator_traits<_Allocator>::destroy(__alloc, + std::__addressof(*__first)); +#endif + } + + template + _GLIBCXX20_CONSTEXPR + inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + allocator<_Tp>&) + { + _Destroy(__first, __last); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // _ALLOC_TRAITS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..624a50b23e411a3df2b3738b58114b0ae13ae827 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@alloc_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h new file mode 100644 index 0000000000000000000000000000000000000000..0f2c53c946e954c22cbeb1351db14bc31b5b71fd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h @@ -0,0 +1,106 @@ +// Guarded Allocation -*- C++ -*- + +// Copyright (C) 2014-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/allocated_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOCATED_PTR_H +#define _ALLOCATED_PTR_H 1 + +#if __cplusplus < 201103L +# include +#else +# include +# include +# include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +/// @cond undocumented + + /// Non-standard RAII type for managing pointers obtained from allocators. + template + struct __allocated_ptr + { + using pointer = typename allocator_traits<_Alloc>::pointer; + using value_type = typename allocator_traits<_Alloc>::value_type; + + /// Take ownership of __ptr + __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept + : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr) + { } + + /// Convert __ptr to allocator's pointer type and take ownership of it + template>> + __allocated_ptr(_Alloc& __a, _Ptr __ptr) + : _M_alloc(std::__addressof(__a)), + _M_ptr(pointer_traits::pointer_to(*__ptr)) + { } + + /// Transfer ownership of the owned pointer + __allocated_ptr(__allocated_ptr&& __gd) noexcept + : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr) + { __gd._M_ptr = nullptr; } + + /// Deallocate the owned pointer + ~__allocated_ptr() + { + if (_M_ptr != nullptr) + std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1); + } + + /// Release ownership of the owned pointer + __allocated_ptr& + operator=(std::nullptr_t) noexcept + { + _M_ptr = nullptr; + return *this; + } + + /// Get the address that the owned pointer refers to. + value_type* get() { return std::__to_address(_M_ptr); } + + private: + _Alloc* _M_alloc; + pointer _M_ptr; + }; + + /// Allocate space for a single object using __a + template + __allocated_ptr<_Alloc> + __allocate_guarded(_Alloc& __a) + { + return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) }; + } + +/// @endcond +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..01861526bf455700f216efd6ca1f51e88e643181 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocated_ptr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..a4b80d924d64e333a73e15ee9e6fea491069a80e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h @@ -0,0 +1,337 @@ +// Allocators -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996-1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/allocator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOCATOR_H +#define _ALLOCATOR_H 1 + +#include // Define the base class to std::allocator. +#include +#if __cplusplus >= 201103L +#include +#endif + +#define __cpp_lib_incomplete_container_elements 201505L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup allocators + * @{ + */ + + // Since C++20 the primary template should be used for allocator, + // but then it would have a non-trivial default ctor and dtor for C++20, + // but trivial for C++98-17, which would be an ABI incompatibiliy between + // different standard dialects. So C++20 still uses the allocator + // explicit specialization, with the historical ABI properties, but with + // the same members that are present in the primary template. + + /// allocator specialization. + template<> + class allocator + { + public: + typedef void value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +#if __cplusplus <= 201703L + // These were removed for C++20, allocator_traits does the right thing. + typedef void* pointer; + typedef const void* const_pointer; + + template + struct rebind + { typedef allocator<_Tp1> other; }; +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. std::allocator propagate_on_container_move_assignment + using propagate_on_container_move_assignment = true_type; + + using is_always_equal + _GLIBCXX20_DEPRECATED_SUGGEST("std::allocator_traits::is_always_equal") + = true_type; + +#if __cplusplus >= 202002L + // As noted above, these members are present for C++20 to provide the + // same API as the primary template, but still trivial as in pre-C++20. + allocator() = default; + ~allocator() = default; + + template + constexpr + allocator(const allocator<_Up>&) noexcept { } + + // No allocate member because it's ill-formed by LWG 3307. + // No deallocate member because it would be undefined to call it + // with any pointer which wasn't obtained from allocate. +#endif // C++20 +#endif // C++11 + }; + + /** + * @brief The @a standard allocator, as per C++03 [20.4.1]. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator + * for further details. + * + * @tparam _Tp Type of allocated object. + */ + template + class allocator : public __allocator_base<_Tp> + { + public: + typedef _Tp value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +#if __cplusplus <= 201703L + // These were removed for C++20. + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + template + struct rebind + { typedef allocator<_Tp1> other; }; +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. std::allocator propagate_on_container_move_assignment + using propagate_on_container_move_assignment = true_type; + + using is_always_equal + _GLIBCXX20_DEPRECATED_SUGGEST("std::allocator_traits::is_always_equal") + = true_type; +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3035. std::allocator's constructors should be constexpr + _GLIBCXX20_CONSTEXPR + allocator() _GLIBCXX_NOTHROW { } + + _GLIBCXX20_CONSTEXPR + allocator(const allocator& __a) _GLIBCXX_NOTHROW + : __allocator_base<_Tp>(__a) { } + +#if __cplusplus >= 201103L + // Avoid implicit deprecation. + allocator& operator=(const allocator&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR + allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { } + +#if __cpp_constexpr_dynamic_alloc + constexpr +#endif + ~allocator() _GLIBCXX_NOTHROW { } + +#if __cplusplus > 201703L + [[nodiscard,__gnu__::__always_inline__]] + constexpr _Tp* + allocate(size_t __n) + { + if (std::__is_constant_evaluated()) + { + if (__builtin_mul_overflow(__n, sizeof(_Tp), &__n)) + std::__throw_bad_array_new_length(); + return static_cast<_Tp*>(::operator new(__n)); + } + + return __allocator_base<_Tp>::allocate(__n, 0); + } + + [[__gnu__::__always_inline__]] + constexpr void + deallocate(_Tp* __p, size_t __n) + { + if (std::__is_constant_evaluated()) + { + ::operator delete(__p); + return; + } + __allocator_base<_Tp>::deallocate(__p, __n); + } +#endif // C++20 + + friend _GLIBCXX20_CONSTEXPR bool + operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW + { return true; } + +#if __cpp_impl_three_way_comparison < 201907L + friend _GLIBCXX20_CONSTEXPR bool + operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW + { return false; } +#endif + + // Inherit everything else. + }; + + template + inline _GLIBCXX20_CONSTEXPR bool + operator==(const allocator<_T1>&, const allocator<_T2>&) + _GLIBCXX_NOTHROW + { return true; } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline _GLIBCXX20_CONSTEXPR bool + operator!=(const allocator<_T1>&, const allocator<_T2>&) + _GLIBCXX_NOTHROW + { return false; } +#endif + + // Invalid allocator partial specializations. + // allocator_traits::rebind_alloc can be used to form a valid allocator type. + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + /// @} group allocator + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class allocator; + extern template class allocator; +#endif + + // Undefine. +#undef __allocator_base + + // To implement Option 3 of DR 431. + template + struct __alloc_swap + { static void _S_do_it(_Alloc&, _Alloc&) _GLIBCXX_NOEXCEPT { } }; + + template + struct __alloc_swap<_Alloc, false> + { + static void + _S_do_it(_Alloc& __one, _Alloc& __two) _GLIBCXX_NOEXCEPT + { + // Precondition: swappable allocators. + if (__one != __two) + swap(__one, __two); + } + }; + + // Optimize for stateless allocators. + template + struct __alloc_neq + { + static bool + _S_do_it(const _Alloc&, const _Alloc&) + { return false; } + }; + + template + struct __alloc_neq<_Alloc, false> + { + static bool + _S_do_it(const _Alloc& __one, const _Alloc& __two) + { return __one != __two; } + }; + +#if __cplusplus >= 201103L + template, + is_nothrow_move_constructible>::value> + struct __shrink_to_fit_aux + { static bool _S_do_it(_Tp&) noexcept { return false; } }; + + template + struct __shrink_to_fit_aux<_Tp, true> + { + _GLIBCXX20_CONSTEXPR + static bool + _S_do_it(_Tp& __c) noexcept + { +#if __cpp_exceptions + try + { + _Tp(__make_move_if_noexcept_iterator(__c.begin()), + __make_move_if_noexcept_iterator(__c.end()), + __c.get_allocator()).swap(__c); + return true; + } + catch(...) + { return false; } +#else + return false; +#endif + } + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..187cd8490f0c8b45f89803c0631a7434c7866511 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@allocator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h new file mode 100644 index 0000000000000000000000000000000000000000..5cf217dbf28ac9ec151c79a4879df7d763dc63cc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h @@ -0,0 +1,1946 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_BASE_H +#define _GLIBCXX_ATOMIC_BASE_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include + +#if __cplusplus > 201703L && _GLIBCXX_HOSTED +#include +#endif + +#ifndef _GLIBCXX_ALWAYS_INLINE +#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup atomics Atomics + * + * Components for performing atomic operations. + * @{ + */ + + /// Enumeration for memory_order +#if __cplusplus > 201703L + enum class memory_order : int + { + relaxed, + consume, + acquire, + release, + acq_rel, + seq_cst + }; + + inline constexpr memory_order memory_order_relaxed = memory_order::relaxed; + inline constexpr memory_order memory_order_consume = memory_order::consume; + inline constexpr memory_order memory_order_acquire = memory_order::acquire; + inline constexpr memory_order memory_order_release = memory_order::release; + inline constexpr memory_order memory_order_acq_rel = memory_order::acq_rel; + inline constexpr memory_order memory_order_seq_cst = memory_order::seq_cst; +#else + typedef enum memory_order + { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst + } memory_order; +#endif + + enum __memory_order_modifier + { + __memory_order_mask = 0x0ffff, + __memory_order_modifier_mask = 0xffff0000, + __memory_order_hle_acquire = 0x10000, + __memory_order_hle_release = 0x20000 + }; + + constexpr memory_order + operator|(memory_order __m, __memory_order_modifier __mod) + { + return memory_order(int(__m) | int(__mod)); + } + + constexpr memory_order + operator&(memory_order __m, __memory_order_modifier __mod) + { + return memory_order(int(__m) & int(__mod)); + } + + // Drop release ordering as per [atomics.types.operations.req]/21 + constexpr memory_order + __cmpexch_failure_order2(memory_order __m) noexcept + { + return __m == memory_order_acq_rel ? memory_order_acquire + : __m == memory_order_release ? memory_order_relaxed : __m; + } + + constexpr memory_order + __cmpexch_failure_order(memory_order __m) noexcept + { + return memory_order(__cmpexch_failure_order2(__m & __memory_order_mask) + | __memory_order_modifier(__m & __memory_order_modifier_mask)); + } + + constexpr bool + __is_valid_cmpexch_failure_order(memory_order __m) noexcept + { + return (__m & __memory_order_mask) != memory_order_release + && (__m & __memory_order_mask) != memory_order_acq_rel; + } + + _GLIBCXX_ALWAYS_INLINE void + atomic_thread_fence(memory_order __m) noexcept + { __atomic_thread_fence(int(__m)); } + + _GLIBCXX_ALWAYS_INLINE void + atomic_signal_fence(memory_order __m) noexcept + { __atomic_signal_fence(int(__m)); } + + /// kill_dependency + template + inline _Tp + kill_dependency(_Tp __y) noexcept + { + _Tp __ret(__y); + return __ret; + } + + // Base types for atomics. + template + struct __atomic_base; + +#if __cplusplus <= 201703L +# define _GLIBCXX20_INIT(I) +#else +# define __cpp_lib_atomic_value_initialization 201911L +# define _GLIBCXX20_INIT(I) = I +#endif + +#define ATOMIC_VAR_INIT(_VI) { _VI } + + template + struct atomic; + + template + struct atomic<_Tp*>; + + /* The target's "set" value for test-and-set may not be exactly 1. */ +#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 + typedef bool __atomic_flag_data_type; +#else + typedef unsigned char __atomic_flag_data_type; +#endif + + /** + * @brief Base type for atomic_flag. + * + * Base type is POD with data, allowing atomic_flag to derive from + * it and meet the standard layout type requirement. In addition to + * compatibility with a C interface, this allows different + * implementations of atomic_flag to use the same atomic operation + * functions, via a standard conversion to the __atomic_flag_base + * argument. + */ + _GLIBCXX_BEGIN_EXTERN_C + + struct __atomic_flag_base + { + __atomic_flag_data_type _M_i _GLIBCXX20_INIT({}); + }; + + _GLIBCXX_END_EXTERN_C + +#define ATOMIC_FLAG_INIT { 0 } + + /// atomic_flag + struct atomic_flag : public __atomic_flag_base + { + atomic_flag() noexcept = default; + ~atomic_flag() noexcept = default; + atomic_flag(const atomic_flag&) = delete; + atomic_flag& operator=(const atomic_flag&) = delete; + atomic_flag& operator=(const atomic_flag&) volatile = delete; + + // Conversion to ATOMIC_FLAG_INIT. + constexpr atomic_flag(bool __i) noexcept + : __atomic_flag_base{ _S_init(__i) } + { } + + _GLIBCXX_ALWAYS_INLINE bool + test_and_set(memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_test_and_set (&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + test_and_set(memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_test_and_set (&_M_i, int(__m)); + } + +#if __cplusplus > 201703L +#define __cpp_lib_atomic_flag_test 201907L + + _GLIBCXX_ALWAYS_INLINE bool + test(memory_order __m = memory_order_seq_cst) const noexcept + { + __atomic_flag_data_type __v; + __atomic_load(&_M_i, &__v, int(__m)); + return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL; + } + + _GLIBCXX_ALWAYS_INLINE bool + test(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + __atomic_flag_data_type __v; + __atomic_load(&_M_i, &__v, int(__m)); + return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL; + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(bool __old, + memory_order __m = memory_order_seq_cst) const noexcept + { + const __atomic_flag_data_type __v + = __old ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; + + std::__atomic_wait_address_v(&_M_i, __v, + [__m, this] { return __atomic_load_n(&_M_i, int(__m)); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() noexcept + { std::__atomic_notify_address(&_M_i, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() noexcept + { std::__atomic_notify_address(&_M_i, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait +#endif // C++20 + + _GLIBCXX_ALWAYS_INLINE void + clear(memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_consume); + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + + __atomic_clear (&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + clear(memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_consume); + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + + __atomic_clear (&_M_i, int(__m)); + } + + private: + static constexpr __atomic_flag_data_type + _S_init(bool __i) + { return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; } + }; + + + /// Base class for atomic integrals. + // + // For each of the integral types, define atomic_[integral type] struct + // + // atomic_bool bool + // atomic_char char + // atomic_schar signed char + // atomic_uchar unsigned char + // atomic_short short + // atomic_ushort unsigned short + // atomic_int int + // atomic_uint unsigned int + // atomic_long long + // atomic_ulong unsigned long + // atomic_llong long long + // atomic_ullong unsigned long long + // atomic_char8_t char8_t + // atomic_char16_t char16_t + // atomic_char32_t char32_t + // atomic_wchar_t wchar_t + // + // NB: Assuming _ITp is an integral scalar type that is 1, 2, 4, or + // 8 bytes, since that is what GCC built-in functions for atomic + // memory access expect. + template + struct __atomic_base + { + using value_type = _ITp; + using difference_type = value_type; + + private: + typedef _ITp __int_type; + + static constexpr int _S_alignment = + sizeof(_ITp) > alignof(_ITp) ? sizeof(_ITp) : alignof(_ITp); + + alignas(_S_alignment) __int_type _M_i _GLIBCXX20_INIT(0); + + public: + __atomic_base() noexcept = default; + ~__atomic_base() noexcept = default; + __atomic_base(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) volatile = delete; + + // Requires __int_type convertible to _M_i. + constexpr __atomic_base(__int_type __i) noexcept : _M_i (__i) { } + + operator __int_type() const noexcept + { return load(); } + + operator __int_type() const volatile noexcept + { return load(); } + + __int_type + operator=(__int_type __i) noexcept + { + store(__i); + return __i; + } + + __int_type + operator=(__int_type __i) volatile noexcept + { + store(__i); + return __i; + } + + __int_type + operator++(int) noexcept + { return fetch_add(1); } + + __int_type + operator++(int) volatile noexcept + { return fetch_add(1); } + + __int_type + operator--(int) noexcept + { return fetch_sub(1); } + + __int_type + operator--(int) volatile noexcept + { return fetch_sub(1); } + + __int_type + operator++() noexcept + { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator++() volatile noexcept + { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator--() noexcept + { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator--() volatile noexcept + { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator+=(__int_type __i) noexcept + { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator+=(__int_type __i) volatile noexcept + { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator-=(__int_type __i) noexcept + { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator-=(__int_type __i) volatile noexcept + { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator&=(__int_type __i) noexcept + { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator&=(__int_type __i) volatile noexcept + { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator|=(__int_type __i) noexcept + { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator|=(__int_type __i) volatile noexcept + { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator^=(__int_type __i) noexcept + { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator^=(__int_type __i) volatile noexcept + { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + bool + is_lock_free() const noexcept + { + // Use a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + bool + is_lock_free() const volatile noexcept + { + // Use a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + exchange(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_exchange_n(&_M_i, __i, int(__m)); + } + + + _GLIBCXX_ALWAYS_INLINE __int_type + exchange(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_exchange_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m1, memory_order __m2) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_weak(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_weak(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m1, memory_order __m2) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_strong(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_strong(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(__int_type __old, + memory_order __m = memory_order_seq_cst) const noexcept + { + std::__atomic_wait_address_v(&_M_i, __old, + [__m, this] { return this->load(__m); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() noexcept + { std::__atomic_notify_address(&_M_i, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() noexcept + { std::__atomic_notify_address(&_M_i, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_add(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_add(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_add(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_add(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_sub(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_sub(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_and(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_and(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_and(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_and(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_or(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_or(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_or(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_or(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_xor(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_xor(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } + }; + + + /// Partial specialization for pointer types. + template + struct __atomic_base<_PTp*> + { + private: + typedef _PTp* __pointer_type; + + __pointer_type _M_p _GLIBCXX20_INIT(nullptr); + + // Factored out to facilitate explicit specialization. + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) const { return __d * sizeof(_PTp); } + + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) const volatile { return __d * sizeof(_PTp); } + + public: + __atomic_base() noexcept = default; + ~__atomic_base() noexcept = default; + __atomic_base(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) volatile = delete; + + // Requires __pointer_type convertible to _M_p. + constexpr __atomic_base(__pointer_type __p) noexcept : _M_p (__p) { } + + operator __pointer_type() const noexcept + { return load(); } + + operator __pointer_type() const volatile noexcept + { return load(); } + + __pointer_type + operator=(__pointer_type __p) noexcept + { + store(__p); + return __p; + } + + __pointer_type + operator=(__pointer_type __p) volatile noexcept + { + store(__p); + return __p; + } + + __pointer_type + operator++(int) noexcept + { return fetch_add(1); } + + __pointer_type + operator++(int) volatile noexcept + { return fetch_add(1); } + + __pointer_type + operator--(int) noexcept + { return fetch_sub(1); } + + __pointer_type + operator--(int) volatile noexcept + { return fetch_sub(1); } + + __pointer_type + operator++() noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator++() volatile noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator--() noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator--() volatile noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator+=(ptrdiff_t __d) noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator+=(ptrdiff_t __d) volatile noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator-=(ptrdiff_t __d) noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator-=(ptrdiff_t __d) volatile noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + bool + is_lock_free() const noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_p), + reinterpret_cast(-__alignof(_M_p))); + } + + bool + is_lock_free() const volatile noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_p), + reinterpret_cast(-__alignof(_M_p))); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_exchange_n(&_M_p, __p, int(__m)); + } + + + _GLIBCXX_ALWAYS_INLINE __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_exchange_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__m2)); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, + int(__m1), int(__m2)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(__pointer_type __old, + memory_order __m = memory_order_seq_cst) const noexcept + { + std::__atomic_wait_address_v(&_M_p, __old, + [__m, this] + { return this->load(__m); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { std::__atomic_notify_address(&_M_p, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { std::__atomic_notify_address(&_M_p, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } + }; + +#if __cplusplus > 201703L + // Implementation details of atomic_ref and atomic. + namespace __atomic_impl + { + // Remove volatile and create a non-deduced context for value arguments. + template + using _Val = remove_volatile_t<_Tp>; + + // As above, but for difference_type arguments. + template + using _Diff = __conditional_t, ptrdiff_t, _Val<_Tp>>; + + template + _GLIBCXX_ALWAYS_INLINE bool + is_lock_free() noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(_Size, reinterpret_cast(-_Align)); + } + + template + _GLIBCXX_ALWAYS_INLINE void + store(_Tp* __ptr, _Val<_Tp> __t, memory_order __m) noexcept + { __atomic_store(__ptr, std::__addressof(__t), int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> + load(const _Tp* __ptr, memory_order __m) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); + __atomic_load(__ptr, __dest, int(__m)); + return *__dest; + } + + template + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> + exchange(_Tp* __ptr, _Val<_Tp> __desired, memory_order __m) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); + __atomic_exchange(__ptr, std::__addressof(__desired), __dest, int(__m)); + return *__dest; + } + + template + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(_Tp* __ptr, _Val<_Tp>& __expected, + _Val<_Tp> __desired, memory_order __success, + memory_order __failure) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__failure)); + + return __atomic_compare_exchange(__ptr, std::__addressof(__expected), + std::__addressof(__desired), true, + int(__success), int(__failure)); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(_Tp* __ptr, _Val<_Tp>& __expected, + _Val<_Tp> __desired, memory_order __success, + memory_order __failure) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__failure)); + + return __atomic_compare_exchange(__ptr, std::__addressof(__expected), + std::__addressof(__desired), false, + int(__success), int(__failure)); + } + +#if __cpp_lib_atomic_wait + template + _GLIBCXX_ALWAYS_INLINE void + wait(const _Tp* __ptr, _Val<_Tp> __old, + memory_order __m = memory_order_seq_cst) noexcept + { + std::__atomic_wait_address_v(__ptr, __old, + [__ptr, __m]() { return __atomic_impl::load(__ptr, __m); }); + } + + // TODO add const volatile overload + + template + _GLIBCXX_ALWAYS_INLINE void + notify_one(const _Tp* __ptr) noexcept + { std::__atomic_notify_address(__ptr, false); } + + // TODO add const volatile overload + + template + _GLIBCXX_ALWAYS_INLINE void + notify_all(const _Tp* __ptr) noexcept + { std::__atomic_notify_address(__ptr, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_add(_Tp* __ptr, _Diff<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_add(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_sub(_Tp* __ptr, _Diff<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_sub(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_and(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_and(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_or(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_or(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_xor(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_xor(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __add_fetch(_Tp* __ptr, _Diff<_Tp> __i) noexcept + { return __atomic_add_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __sub_fetch(_Tp* __ptr, _Diff<_Tp> __i) noexcept + { return __atomic_sub_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __and_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_and_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __or_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_or_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __xor_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_xor_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _Tp + __fetch_add_flt(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval + __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, __m, + memory_order_relaxed)) + __newval = __oldval + __i; + return __oldval; + } + + template + _Tp + __fetch_sub_flt(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval - __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, __m, + memory_order_relaxed)) + __newval = __oldval - __i; + return __oldval; + } + + template + _Tp + __add_fetch_flt(_Tp* __ptr, _Val<_Tp> __i) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval + __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, + memory_order_seq_cst, + memory_order_relaxed)) + __newval = __oldval + __i; + return __newval; + } + + template + _Tp + __sub_fetch_flt(_Tp* __ptr, _Val<_Tp> __i) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval - __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, + memory_order_seq_cst, + memory_order_relaxed)) + __newval = __oldval - __i; + return __newval; + } + } // namespace __atomic_impl + + // base class for atomic + template + struct __atomic_float + { + static_assert(is_floating_point_v<_Fp>); + + static constexpr size_t _S_alignment = __alignof__(_Fp); + + public: + using value_type = _Fp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Fp), 0); + + __atomic_float() = default; + + constexpr + __atomic_float(_Fp __t) : _M_fp(__t) + { } + + __atomic_float(const __atomic_float&) = delete; + __atomic_float& operator=(const __atomic_float&) = delete; + __atomic_float& operator=(const __atomic_float&) volatile = delete; + + _Fp + operator=(_Fp __t) volatile noexcept + { + this->store(__t); + return __t; + } + + _Fp + operator=(_Fp __t) noexcept + { + this->store(__t); + return __t; + } + + bool + is_lock_free() const volatile noexcept + { return __atomic_impl::is_lock_free(); } + + bool + is_lock_free() const noexcept + { return __atomic_impl::is_lock_free(); } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) volatile noexcept + { __atomic_impl::store(&_M_fp, __t, __m); } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) noexcept + { __atomic_impl::store(&_M_fp, __t, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return __atomic_impl::load(&_M_fp, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(&_M_fp, __m); } + + operator _Fp() const volatile noexcept { return this->load(); } + operator _Fp() const noexcept { return this->load(); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::exchange(&_M_fp, __desired, __m); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::exchange(&_M_fp, __desired, __m); } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) noexcept + { + return __atomic_impl::compare_exchange_weak(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) volatile noexcept + { + return __atomic_impl::compare_exchange_weak(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) noexcept + { + return __atomic_impl::compare_exchange_strong(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) volatile noexcept + { + return __atomic_impl::compare_exchange_strong(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + volatile noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + volatile noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Fp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(&_M_fp, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(&_M_fp); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(&_M_fp); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::__fetch_add_flt(&_M_fp, __i, __m); } + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::__fetch_add_flt(&_M_fp, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::__fetch_sub_flt(&_M_fp, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::__fetch_sub_flt(&_M_fp, __i, __m); } + + value_type + operator+=(value_type __i) noexcept + { return __atomic_impl::__add_fetch_flt(&_M_fp, __i); } + + value_type + operator+=(value_type __i) volatile noexcept + { return __atomic_impl::__add_fetch_flt(&_M_fp, __i); } + + value_type + operator-=(value_type __i) noexcept + { return __atomic_impl::__sub_fetch_flt(&_M_fp, __i); } + + value_type + operator-=(value_type __i) volatile noexcept + { return __atomic_impl::__sub_fetch_flt(&_M_fp, __i); } + + private: + alignas(_S_alignment) _Fp _M_fp _GLIBCXX20_INIT(0); + }; +#undef _GLIBCXX20_INIT + + template, bool = is_floating_point_v<_Tp>> + struct __atomic_ref; + + // base class for non-integral, non-floating-point, non-pointer types + template + struct __atomic_ref<_Tp, false, false> + { + static_assert(is_trivially_copyable_v<_Tp>); + + // 1/2/4/8/16-byte types must be aligned to at least their size. + static constexpr int _S_min_alignment + = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16 + ? 0 : sizeof(_Tp); + + public: + using value_type = _Tp; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Tp), 0); + + static constexpr size_t required_alignment + = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp); + + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp& __t) : _M_ptr(std::__addressof(__t)) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp + operator=(_Tp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { return __atomic_impl::is_lock_free(); } + + void + store(_Tp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp + exchange(_Tp __desired, memory_order __m = memory_order_seq_cst) + const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + private: + _Tp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Tp, true, false> + { + static_assert(is_integral_v<_Tp>); + + public: + using value_type = _Tp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Tp), 0); + + static constexpr size_t required_alignment + = sizeof(_Tp) > alignof(_Tp) ? sizeof(_Tp) : alignof(_Tp); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp& __t) : _M_ptr(&__t) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp + operator=(_Tp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Tp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp + exchange(_Tp __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_add(_M_ptr, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_sub(_M_ptr, __i, __m); } + + value_type + fetch_and(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_and(_M_ptr, __i, __m); } + + value_type + fetch_or(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_or(_M_ptr, __i, __m); } + + value_type + fetch_xor(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_xor(_M_ptr, __i, __m); } + + _GLIBCXX_ALWAYS_INLINE value_type + operator++(int) const noexcept + { return fetch_add(1); } + + _GLIBCXX_ALWAYS_INLINE value_type + operator--(int) const noexcept + { return fetch_sub(1); } + + value_type + operator++() const noexcept + { return __atomic_impl::__add_fetch(_M_ptr, value_type(1)); } + + value_type + operator--() const noexcept + { return __atomic_impl::__sub_fetch(_M_ptr, value_type(1)); } + + value_type + operator+=(value_type __i) const noexcept + { return __atomic_impl::__add_fetch(_M_ptr, __i); } + + value_type + operator-=(value_type __i) const noexcept + { return __atomic_impl::__sub_fetch(_M_ptr, __i); } + + value_type + operator&=(value_type __i) const noexcept + { return __atomic_impl::__and_fetch(_M_ptr, __i); } + + value_type + operator|=(value_type __i) const noexcept + { return __atomic_impl::__or_fetch(_M_ptr, __i); } + + value_type + operator^=(value_type __i) const noexcept + { return __atomic_impl::__xor_fetch(_M_ptr, __i); } + + private: + _Tp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Fp, false, true> + { + static_assert(is_floating_point_v<_Fp>); + + public: + using value_type = _Fp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Fp), 0); + + static constexpr size_t required_alignment = __alignof__(_Fp); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Fp& __t) : _M_ptr(&__t) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Fp + operator=(_Fp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Fp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Fp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::__fetch_add_flt(_M_ptr, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::__fetch_sub_flt(_M_ptr, __i, __m); } + + value_type + operator+=(value_type __i) const noexcept + { return __atomic_impl::__add_fetch_flt(_M_ptr, __i); } + + value_type + operator-=(value_type __i) const noexcept + { return __atomic_impl::__sub_fetch_flt(_M_ptr, __i); } + + private: + _Fp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Tp*, false, false> + { + public: + using value_type = _Tp*; + using difference_type = ptrdiff_t; + + static constexpr bool is_always_lock_free = ATOMIC_POINTER_LOCK_FREE == 2; + + static constexpr size_t required_alignment = __alignof__(_Tp*); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp*& __t) : _M_ptr(std::__addressof(__t)) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp* + operator=(_Tp* __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp*() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Tp* __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp* + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp* + exchange(_Tp* __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp*& __expected, _Tp* __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp*& __expected, _Tp* __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp*& __expected, _Tp* __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp*& __expected, _Tp* __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE value_type + fetch_add(difference_type __d, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_add(_M_ptr, _S_type_size(__d), __m); } + + _GLIBCXX_ALWAYS_INLINE value_type + fetch_sub(difference_type __d, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_sub(_M_ptr, _S_type_size(__d), __m); } + + value_type + operator++(int) const noexcept + { return fetch_add(1); } + + value_type + operator--(int) const noexcept + { return fetch_sub(1); } + + value_type + operator++() const noexcept + { + return __atomic_impl::__add_fetch(_M_ptr, _S_type_size(1)); + } + + value_type + operator--() const noexcept + { + return __atomic_impl::__sub_fetch(_M_ptr, _S_type_size(1)); + } + + value_type + operator+=(difference_type __d) const noexcept + { + return __atomic_impl::__add_fetch(_M_ptr, _S_type_size(__d)); + } + + value_type + operator-=(difference_type __d) const noexcept + { + return __atomic_impl::__sub_fetch(_M_ptr, _S_type_size(__d)); + } + + private: + static constexpr ptrdiff_t + _S_type_size(ptrdiff_t __d) noexcept + { + static_assert(is_object_v<_Tp>); + return __d * sizeof(_Tp); + } + + _Tp** _M_ptr; + }; + +#endif // C++2a + + /// @} group atomics + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..18ab28718f42a31d1afb6bb83f13df5e96f4d9d0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_base.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h new file mode 100644 index 0000000000000000000000000000000000000000..01bc53291d34d7b85c02311073afbe984b886076 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h @@ -0,0 +1,360 @@ +// -*- C++ -*- header. + +// Copyright (C) 2015-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_futex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _GLIBCXX_ATOMIC_FUTEX_H +#define _GLIBCXX_ATOMIC_FUTEX_H 1 + +#pragma GCC system_header + +#include +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) +#include +#include +#endif +#include + +#ifndef _GLIBCXX_ALWAYS_INLINE +#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef _GLIBCXX_HAS_GTHREADS +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 + struct __atomic_futex_unsigned_base + { + // __s and __ns are measured against CLOCK_REALTIME. Returns false + // iff a timeout occurred. + bool + _M_futex_wait_until(unsigned *__addr, unsigned __val, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns); + + // __s and __ns are measured against CLOCK_MONOTONIC. Returns + // false iff a timeout occurred. + bool + _M_futex_wait_until_steady(unsigned *__addr, unsigned __val, + bool __has_timeout, chrono::seconds __s, chrono::nanoseconds __ns); + + // This can be executed after the object has been destroyed. + static void _M_futex_notify_all(unsigned* __addr); + }; + + template + class __atomic_futex_unsigned : __atomic_futex_unsigned_base + { + typedef chrono::steady_clock __clock_t; + + // This must be lock-free and at offset 0. + atomic _M_data; + + public: + explicit + __atomic_futex_unsigned(unsigned __data) : _M_data(__data) + { } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load(memory_order __mo) + { + return _M_data.load(__mo) & ~_Waiter_bit; + } + + private: + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + // __s and __ns are measured against CLOCK_REALTIME. + unsigned + _M_load_and_test_until(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns) + { + for (;;) + { + // Don't bother checking the value again because we expect the caller + // to have done it recently. + // memory_order_relaxed is sufficient because we can rely on just the + // modification order (store_notify uses an atomic RMW operation too), + // and the futex syscalls synchronize between themselves. + _M_data.fetch_or(_Waiter_bit, memory_order_relaxed); + bool __ret = _M_futex_wait_until((unsigned*)(void*)&_M_data, + __assumed | _Waiter_bit, + __has_timeout, __s, __ns); + // Fetch the current value after waiting (clears _Waiter_bit). + __assumed = _M_load(__mo); + if (!__ret || ((__operand == __assumed) == __equal)) + return __assumed; + // TODO adapt wait time + } + } + + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + // __s and __ns are measured against CLOCK_MONOTONIC. + unsigned + _M_load_and_test_until_steady(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns) + { + for (;;) + { + // Don't bother checking the value again because we expect the caller + // to have done it recently. + // memory_order_relaxed is sufficient because we can rely on just the + // modification order (store_notify uses an atomic RMW operation too), + // and the futex syscalls synchronize between themselves. + _M_data.fetch_or(_Waiter_bit, memory_order_relaxed); + bool __ret = _M_futex_wait_until_steady((unsigned*)(void*)&_M_data, + __assumed | _Waiter_bit, + __has_timeout, __s, __ns); + // Fetch the current value after waiting (clears _Waiter_bit). + __assumed = _M_load(__mo); + if (!__ret || ((__operand == __assumed) == __equal)) + return __assumed; + // TODO adapt wait time + } + } + + // Returns the operand's value if equal is true or a different value if + // equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + unsigned + _M_load_and_test(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo) + { + return _M_load_and_test_until(__assumed, __operand, __equal, __mo, + false, {}, {}); + } + + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + template + unsigned + _M_load_and_test_until_impl(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + // XXX correct? + return _M_load_and_test_until(__assumed, __operand, __equal, __mo, + true, __s.time_since_epoch(), __ns); + } + + template + unsigned + _M_load_and_test_until_impl(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + // XXX correct? + return _M_load_and_test_until_steady(__assumed, __operand, __equal, __mo, + true, __s.time_since_epoch(), __ns); + } + + public: + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load_when_not_equal(unsigned __val, memory_order __mo) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) != __val) + return (__i & ~_Waiter_bit); + // TODO Spin-wait first. + return _M_load_and_test(__i, __val, false, __mo); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_load_when_equal(unsigned __val, memory_order __mo) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return; + // TODO Spin-wait first. + _M_load_and_test(__i, __val, true, __mo); + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + using __dur = typename __clock_t::duration; + return _M_load_when_equal_until(__val, __mo, + __clock_t::now() + chrono::__detail::ceil<__dur>(__rtime)); + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + typename _Clock::time_point __c_entry = _Clock::now(); + do { + const __clock_t::time_point __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + + chrono::__detail::ceil<__clock_t::duration>(__delta); + if (_M_load_when_equal_until(__val, __mo, __s_atime)) + return true; + __c_entry = _Clock::now(); + } while (__c_entry < __atime); + return false; + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point& __atime) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return true; + // TODO Spin-wait first. Ignore effect on timeout. + __i = _M_load_and_test_until_impl(__i, __val, true, __mo, __atime); + return (__i & ~_Waiter_bit) == __val; + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point& __atime) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return true; + // TODO Spin-wait first. Ignore effect on timeout. + __i = _M_load_and_test_until_impl(__i, __val, true, __mo, __atime); + return (__i & ~_Waiter_bit) == __val; + } + + _GLIBCXX_ALWAYS_INLINE void + _M_store_notify_all(unsigned __val, memory_order __mo) + { + unsigned* __futex = (unsigned *)(void *)&_M_data; + if (_M_data.exchange(__val, __mo) & _Waiter_bit) + _M_futex_notify_all(__futex); + } + }; + +#else // ! (_GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1) + + // If futexes are not available, use a mutex and a condvar to wait. + // Because we access the data only within critical sections, all accesses + // are sequentially consistent; thus, we satisfy any provided memory_order. + template + class __atomic_futex_unsigned + { + typedef chrono::system_clock __clock_t; + + unsigned _M_data; + mutex _M_mutex; + condition_variable _M_condvar; + + public: + explicit + __atomic_futex_unsigned(unsigned __data) : _M_data(__data) + { } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load(memory_order __mo) + { + unique_lock __lock(_M_mutex); + return _M_data; + } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load_when_not_equal(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + while (_M_data == __val) + _M_condvar.wait(__lock); + return _M_data; + } + + _GLIBCXX_ALWAYS_INLINE void + _M_load_when_equal(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + while (_M_data != __val) + _M_condvar.wait(__lock); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + unique_lock __lock(_M_mutex); + return _M_condvar.wait_for(__lock, __rtime, + [&] { return _M_data == __val;}); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + unique_lock __lock(_M_mutex); + return _M_condvar.wait_until(__lock, __atime, + [&] { return _M_data == __val;}); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_store_notify_all(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + _M_data = __val; + _M_condvar.notify_all(); + } + }; + +#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1 +#endif // _GLIBCXX_HAS_GTHREADS + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b644c41d1207d301f4c6cc676eb05ca45f9e3da2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_futex.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..116ed013c11948a3683ecaf6aa46074c432619a5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h @@ -0,0 +1,66 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_lockfree_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H +#define _GLIBCXX_ATOMIC_LOCK_FREE_H 1 + +#pragma GCC system_header + +/** + * @addtogroup atomics + * @{ + */ + +/** + * Lock-free property. + * + * 0 indicates that the types are never lock-free. + * 1 indicates that the types are sometimes lock-free. + * 2 indicates that the types are always lock-free. + */ + +#if __cplusplus >= 201103L +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#ifdef _GLIBCXX_USE_CHAR8_T +#define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE +#endif +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/// @} group atomics + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7f97b6d4dbd8b7412d66a0701f9a5a5ad9e40c6f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@atomic_lockfree_defines.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h new file mode 100644 index 0000000000000000000000000000000000000000..e3f13a097e47b39f8ed73ef3d6086221226e6e45 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h @@ -0,0 +1,518 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_ios.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _BASIC_IOS_H +#define _BASIC_IOS_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + inline const _Facet& + __check_facet(const _Facet* __f) + { + if (!__f) + __throw_bad_cast(); + return *__f; + } + + /** + * @brief Template class basic_ios, virtual base class for all + * stream classes. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * Most of the member functions called dispatched on stream objects + * (e.g., @c std::cout.foo(bar);) are consolidated in this class. + */ + template + class basic_ios : public ios_base + { + public: + ///@{ + /** + * These are standard types. They permit a standardized way of + * referring to names of (or names dependent on) the template + * parameters, which are specific to the implementation. + */ + 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; + ///@} + + ///@{ + /** + * These are non-standard types. + */ + typedef ctype<_CharT> __ctype_type; + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > + __num_put_type; + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > + __num_get_type; + ///@} + + // Data members: + protected: + basic_ostream<_CharT, _Traits>* _M_tie; + mutable char_type _M_fill; + mutable bool _M_fill_init; + basic_streambuf<_CharT, _Traits>* _M_streambuf; + + // Cached use_facet, which is based on the current locale info. + const __ctype_type* _M_ctype; + // For ostream. + const __num_put_type* _M_num_put; + // For istream. + const __num_get_type* _M_num_get; + + public: + ///@{ + /** + * @brief The quick-and-easy status check. + * + * This allows you to write constructs such as + * if (!a_stream) ... and while (a_stream) ... + */ +#if __cplusplus >= 201103L + explicit operator bool() const + { return !this->fail(); } +#else + operator void*() const + { return this->fail() ? 0 : const_cast(this); } +#endif + + bool + operator!() const + { return this->fail(); } + ///@} + + /** + * @brief Returns the error state of the stream buffer. + * @return A bit pattern (well, isn't everything?) + * + * See std::ios_base::iostate for the possible bit values. Most + * users will call one of the interpreting wrappers, e.g., good(). + */ + iostate + rdstate() const + { return _M_streambuf_state; } + + /** + * @brief [Re]sets the error state. + * @param __state The new state flag(s) to set. + * + * See std::ios_base::iostate for the possible bit values. Most + * users will not need to pass an argument. + */ + void + clear(iostate __state = goodbit); + + /** + * @brief Sets additional flags in the error state. + * @param __state The additional state flag(s) to set. + * + * See std::ios_base::iostate for the possible bit values. + */ + void + setstate(iostate __state) + { this->clear(this->rdstate() | __state); } + + // Flip the internal state on for the proper state bits, then + // rethrows the propagated exception if bit also set in + // exceptions(). + void + _M_setstate(iostate __state) + { + // 27.6.1.2.1 Common requirements. + // Turn this on without causing an ios::failure to be thrown. + _M_streambuf_state |= __state; + if (this->exceptions() & __state) + __throw_exception_again; + } + + /** + * @brief Fast error checking. + * @return True if no error flags are set. + * + * A wrapper around rdstate. + */ + bool + good() const + { return this->rdstate() == 0; } + + /** + * @brief Fast error checking. + * @return True if the eofbit is set. + * + * Note that other iostate flags may also be set. + */ + bool + eof() const + { return (this->rdstate() & eofbit) != 0; } + + /** + * @brief Fast error checking. + * @return True if either the badbit or the failbit is set. + * + * Checking the badbit in fail() is historical practice. + * Note that other iostate flags may also be set. + */ + bool + fail() const + { return (this->rdstate() & (badbit | failbit)) != 0; } + + /** + * @brief Fast error checking. + * @return True if the badbit is set. + * + * Note that other iostate flags may also be set. + */ + bool + bad() const + { return (this->rdstate() & badbit) != 0; } + + /** + * @brief Throwing exceptions on errors. + * @return The current exceptions mask. + * + * This changes nothing in the stream. See the one-argument version + * of exceptions(iostate) for the meaning of the return value. + */ + iostate + exceptions() const + { return _M_exception; } + + /** + * @brief Throwing exceptions on errors. + * @param __except The new exceptions mask. + * + * By default, error flags are set silently. You can set an + * exceptions mask for each stream; if a bit in the mask becomes set + * in the error flags, then an exception of type + * std::ios_base::failure is thrown. + * + * If the error flag is already set when the exceptions mask is + * added, the exception is immediately thrown. Try running the + * following under GCC 3.1 or later: + * @code + * #include + * #include + * #include + * + * int main() + * { + * std::set_terminate (__gnu_cxx::__verbose_terminate_handler); + * + * std::ifstream f ("/etc/motd"); + * + * std::cerr << "Setting badbit\n"; + * f.setstate (std::ios_base::badbit); + * + * std::cerr << "Setting exception mask\n"; + * f.exceptions (std::ios_base::badbit); + * } + * @endcode + */ + void + exceptions(iostate __except) + { + _M_exception = __except; + this->clear(_M_streambuf_state); + } + + // Constructor/destructor: + /** + * @brief Constructor performs initialization. + * + * The parameter is passed by derived streams. + */ + explicit + basic_ios(basic_streambuf<_CharT, _Traits>* __sb) + : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0), + _M_ctype(0), _M_num_put(0), _M_num_get(0) + { this->init(__sb); } + + /** + * @brief Empty. + * + * The destructor does nothing. More specifically, it does not + * destroy the streambuf held by rdbuf(). + */ + virtual + ~basic_ios() { } + + // Members: + /** + * @brief Fetches the current @e tied stream. + * @return A pointer to the tied stream, or NULL if the stream is + * not tied. + * + * A stream may be @e tied (or synchronized) to a second output + * stream. When this stream performs any I/O, the tied stream is + * first flushed. For example, @c std::cin is tied to @c std::cout. + */ + basic_ostream<_CharT, _Traits>* + tie() const + { return _M_tie; } + + /** + * @brief Ties this stream to an output stream. + * @param __tiestr The output stream. + * @return The previously tied output stream, or NULL if the stream + * was not tied. + * + * This sets up a new tie; see tie() for more. + */ + basic_ostream<_CharT, _Traits>* + tie(basic_ostream<_CharT, _Traits>* __tiestr) + { + basic_ostream<_CharT, _Traits>* __old = _M_tie; + _M_tie = __tiestr; + return __old; + } + + /** + * @brief Accessing the underlying buffer. + * @return The current stream buffer. + * + * This does not change the state of the stream. + */ + basic_streambuf<_CharT, _Traits>* + rdbuf() const + { return _M_streambuf; } + + /** + * @brief Changing the underlying buffer. + * @param __sb The new stream buffer. + * @return The previous stream buffer. + * + * Associates a new buffer with the current stream, and clears the + * error state. + * + * Due to historical accidents which the LWG refuses to correct, the + * I/O library suffers from a design error: this function is hidden + * in derived classes by overrides of the zero-argument @c rdbuf(), + * which is non-virtual for hysterical raisins. As a result, you + * must use explicit qualifications to access this function via any + * derived class. For example: + * + * @code + * std::fstream foo; // or some other derived type + * std::streambuf* p = .....; + * + * foo.ios::rdbuf(p); // ios == basic_ios + * @endcode + */ + basic_streambuf<_CharT, _Traits>* + rdbuf(basic_streambuf<_CharT, _Traits>* __sb); + + /** + * @brief Copies fields of __rhs into this. + * @param __rhs The source values for the copies. + * @return Reference to this object. + * + * All fields of __rhs are copied into this object except that rdbuf() + * and rdstate() remain unchanged. All values in the pword and iword + * arrays are copied. Before copying, each callback is invoked with + * erase_event. After copying, each (new) callback is invoked with + * copyfmt_event. The final step is to copy exceptions(). + */ + basic_ios& + copyfmt(const basic_ios& __rhs); + + /** + * @brief Retrieves the @a empty character. + * @return The current fill character. + * + * It defaults to a space (' ') in the current locale. + */ + char_type + fill() const + { + if (!_M_fill_init) + { + _M_fill = this->widen(' '); + _M_fill_init = true; + } + return _M_fill; + } + + /** + * @brief Sets a new @a empty character. + * @param __ch The new character. + * @return The previous fill character. + * + * The fill character is used to fill out space when P+ characters + * have been requested (e.g., via setw), Q characters are actually + * used, and Qfill(); + _M_fill = __ch; + return __old; + } + + // Locales: + /** + * @brief Moves to a new locale. + * @param __loc The new locale. + * @return The previous locale. + * + * Calls @c ios_base::imbue(loc), and if a stream buffer is associated + * with this stream, calls that buffer's @c pubimbue(loc). + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + locale + imbue(const locale& __loc); + + /** + * @brief Squeezes characters. + * @param __c The character to narrow. + * @param __dfault The character to narrow. + * @return The narrowed character. + * + * Maps a character of @c char_type to a character of @c char, + * if possible. + * + * Returns the result of + * @code + * std::use_facet >(getloc()).narrow(c,dfault) + * @endcode + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + char + narrow(char_type __c, char __dfault) const + { return __check_facet(_M_ctype).narrow(__c, __dfault); } + + /** + * @brief Widens characters. + * @param __c The character to widen. + * @return The widened character. + * + * Maps a character of @c char to a character of @c char_type. + * + * Returns the result of + * @code + * std::use_facet >(getloc()).widen(c) + * @endcode + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + char_type + widen(char __c) const + { return __check_facet(_M_ctype).widen(__c); } + + protected: + // 27.4.5.1 basic_ios constructors + /** + * @brief Empty. + * + * The default constructor does nothing and is not normally + * accessible to users. + */ + basic_ios() + : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false), + _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0) + { } + + /** + * @brief All setup is performed here. + * + * This is called from the public constructor. It is not virtual and + * cannot be redefined. + */ + void + init(basic_streambuf<_CharT, _Traits>* __sb); + +#if __cplusplus >= 201103L + basic_ios(const basic_ios&) = delete; + basic_ios& operator=(const basic_ios&) = delete; + + void + move(basic_ios& __rhs) + { + ios_base::_M_move(__rhs); + _M_cache_locale(_M_ios_locale); + this->tie(__rhs.tie(nullptr)); + _M_fill = __rhs._M_fill; + _M_fill_init = __rhs._M_fill_init; + _M_streambuf = nullptr; + } + + void + move(basic_ios&& __rhs) + { this->move(__rhs); } + + void + swap(basic_ios& __rhs) noexcept + { + ios_base::_M_swap(__rhs); + _M_cache_locale(_M_ios_locale); + __rhs._M_cache_locale(__rhs._M_ios_locale); + std::swap(_M_tie, __rhs._M_tie); + std::swap(_M_fill, __rhs._M_fill); + std::swap(_M_fill_init, __rhs._M_fill_init); + } + + void + set_rdbuf(basic_streambuf<_CharT, _Traits>* __sb) + { _M_streambuf = __sb; } +#endif + + void + _M_cache_locale(const locale& __loc); + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _BASIC_IOS_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9961b85390cadb0569eb1ff64aa9437361e0df60 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc new file mode 100644 index 0000000000000000000000000000000000000000..2bbcdc20dc0bbfe4579228162955c40fc38b9194 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc @@ -0,0 +1,188 @@ +// basic_ios member functions -*- C++ -*- + +// Copyright (C) 1999-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_ios.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _BASIC_IOS_TCC +#define _BASIC_IOS_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + basic_ios<_CharT, _Traits>::clear(iostate __state) + { + if (this->rdbuf()) + _M_streambuf_state = __state; + else + _M_streambuf_state = __state | badbit; + if (this->exceptions() & this->rdstate()) + __throw_ios_failure(__N("basic_ios::clear")); + } + + template + basic_streambuf<_CharT, _Traits>* + basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb) + { + basic_streambuf<_CharT, _Traits>* __old = _M_streambuf; + _M_streambuf = __sb; + this->clear(); + return __old; + } + + template + basic_ios<_CharT, _Traits>& + basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 292. effects of a.copyfmt (a) + if (this != std::__addressof(__rhs)) + { + // Per 27.1.1, do not call imbue, yet must trash all caches + // associated with imbue() + + // Alloc any new word array first, so if it fails we have "rollback". + _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? + _M_local_word : new _Words[__rhs._M_word_size]; + + // Bump refs before doing callbacks, for safety. + _Callback_list* __cb = __rhs._M_callbacks; + if (__cb) + __cb->_M_add_reference(); + _M_call_callbacks(erase_event); + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + _M_dispose_callbacks(); + + // NB: Don't want any added during above. + _M_callbacks = __cb; + for (int __i = 0; __i < __rhs._M_word_size; ++__i) + __words[__i] = __rhs._M_word[__i]; + _M_word = __words; + _M_word_size = __rhs._M_word_size; + + this->flags(__rhs.flags()); + this->width(__rhs.width()); + this->precision(__rhs.precision()); + this->tie(__rhs.tie()); + this->fill(__rhs.fill()); + _M_ios_locale = __rhs.getloc(); + _M_cache_locale(_M_ios_locale); + + _M_call_callbacks(copyfmt_event); + + // The next is required to be the last assignment. + this->exceptions(__rhs.exceptions()); + } + return *this; + } + + // Locales: + template + locale + basic_ios<_CharT, _Traits>::imbue(const locale& __loc) + { + locale __old(this->getloc()); + ios_base::imbue(__loc); + _M_cache_locale(__loc); + if (this->rdbuf() != 0) + this->rdbuf()->pubimbue(__loc); + return __old; + } + + template + void + basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb) + { + // NB: This may be called more than once on the same object. + ios_base::_M_init(); + + // Cache locale data and specific facets used by iostreams. + _M_cache_locale(_M_ios_locale); + + // NB: The 27.4.4.1 Postconditions Table specifies requirements + // after basic_ios::init() has been called. As part of this, + // fill() must return widen(' ') any time after init() has been + // called, which needs an imbued ctype facet of char_type to + // return without throwing an exception. Unfortunately, + // ctype is not necessarily a required facet, so + // streams with char_type != [char, wchar_t] will not have it by + // default. Because of this, the correct value for _M_fill is + // constructed on the first call of fill(). That way, + // unformatted input and output with non-required basic_ios + // instantiations is possible even without imbuing the expected + // ctype facet. + _M_fill = _CharT(); + _M_fill_init = false; + + _M_tie = 0; + _M_exception = goodbit; + _M_streambuf = __sb; + _M_streambuf_state = __sb ? goodbit : badbit; + } + + template + void + basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc) + { + if (__builtin_expect(has_facet<__ctype_type>(__loc), true)) + _M_ctype = std::__addressof(use_facet<__ctype_type>(__loc)); + else + _M_ctype = 0; + + if (__builtin_expect(has_facet<__num_put_type>(__loc), true)) + _M_num_put = std::__addressof(use_facet<__num_put_type>(__loc)); + else + _M_num_put = 0; + + if (__builtin_expect(has_facet<__num_get_type>(__loc), true)) + _M_num_get = std::__addressof(use_facet<__num_get_type>(__loc)); + else + _M_num_get = 0; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_ios; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_ios; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..caa78e65504fbdaa738338a6236db95323f97147 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_ios.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h new file mode 100644 index 0000000000000000000000000000000000000000..9777deaf2e91cbb33b0daf9f450c85f477e3e6c9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h @@ -0,0 +1,4382 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_string.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _BASIC_STRING_H +#define _BASIC_STRING_H 1 + +#pragma GCC system_header + +#include +#include + +#if __cplusplus >= 201103L +#include +#endif + +#if __cplusplus >= 201703L +# include +#endif + +#if ! _GLIBCXX_USE_CXX11_ABI +# include "cow_string.h" +#else +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + +#ifdef __cpp_lib_is_constant_evaluated +// Support P0980R1 in C++20. +# define __cpp_lib_constexpr_string 201907L +#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED +// Support P0426R1 changes to char_traits in C++17. +# define __cpp_lib_constexpr_string 201611L +#endif + + /** + * @class basic_string basic_string.h + * @brief Managing sequences of characters and character-like objects. + * + * @ingroup strings + * @ingroup sequences + * + * @tparam _CharT Type of character + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. Of the + * optional sequence requirements, only + * @c push_back, @c at, and @c %array access are supported. + */ + template + class basic_string + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + +#if __cpp_lib_constexpr_string < 201907L + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; +#else + template + struct _Alloc_traits_impl : __gnu_cxx::__alloc_traits<_Char_alloc_type> + { + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Base; + + [[__gnu__::__always_inline__]] + static constexpr typename _Base::pointer + allocate(_Char_alloc_type& __a, typename _Base::size_type __n) + { + pointer __p = _Base::allocate(__a, __n); + if (std::is_constant_evaluated()) + // Begin the lifetime of characters in allocated storage. + for (size_type __i = 0; __i < __n; ++__i) + std::construct_at(__builtin_addressof(__p[__i])); + return __p; + } + }; + + template + struct _Alloc_traits_impl, _Dummy_for_PR85282> + : __gnu_cxx::__alloc_traits<_Char_alloc_type> + { + // std::char_traits begins the lifetime of characters. + }; + + using _Alloc_traits = _Alloc_traits_impl<_Traits, void>; +#endif + + // Types: + public: + typedef _Traits traits_type; + typedef typename _Traits::char_type value_type; + typedef _Char_alloc_type allocator_type; + typedef typename _Alloc_traits::size_type size_type; + typedef typename _Alloc_traits::difference_type difference_type; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + + /// Value returned by various member functions when they fail. + static const size_type npos = static_cast(-1); + + protected: + // type used for positions in insert, erase etc. +#if __cplusplus < 201103L + typedef iterator __const_iterator; +#else + typedef const_iterator __const_iterator; +#endif + + private: +#if __cplusplus >= 201703L + // A helper type for avoiding boiler-plate. + typedef basic_string_view<_CharT, _Traits> __sv_type; + + template + using _If_sv = enable_if_t< + __and_, + __not_>, + __not_>>::value, + _Res>; + + // Allows an implicit conversion to __sv_type. + _GLIBCXX20_CONSTEXPR + static __sv_type + _S_to_string_view(__sv_type __svt) noexcept + { return __svt; } + + // Wraps a string_view by explicit conversion and thus + // allows to add an internal constructor that does not + // participate in overload resolution when a string_view + // is provided. + struct __sv_wrapper + { + _GLIBCXX20_CONSTEXPR explicit + __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { } + + __sv_type _M_sv; + }; + + /** + * @brief Only internally used: Construct string from a string view + * wrapper. + * @param __svw string view wrapper. + * @param __a Allocator to use. + */ + _GLIBCXX20_CONSTEXPR + explicit + basic_string(__sv_wrapper __svw, const _Alloc& __a) + : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { } +#endif + + // Use empty-base optimization: http://www.cantrip.org/emptyopt.html + struct _Alloc_hider : allocator_type // TODO check __is_final + { +#if __cplusplus < 201103L + _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc()) + : allocator_type(__a), _M_p(__dat) { } +#else + _GLIBCXX20_CONSTEXPR + _Alloc_hider(pointer __dat, const _Alloc& __a) + : allocator_type(__a), _M_p(__dat) { } + + _GLIBCXX20_CONSTEXPR + _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc()) + : allocator_type(std::move(__a)), _M_p(__dat) { } +#endif + + pointer _M_p; // The actual data. + }; + + _Alloc_hider _M_dataplus; + size_type _M_string_length; + + enum { _S_local_capacity = 15 / sizeof(_CharT) }; + + union + { + _CharT _M_local_buf[_S_local_capacity + 1]; + size_type _M_allocated_capacity; + }; + + _GLIBCXX20_CONSTEXPR + void + _M_data(pointer __p) + { _M_dataplus._M_p = __p; } + + _GLIBCXX20_CONSTEXPR + void + _M_length(size_type __length) + { _M_string_length = __length; } + + _GLIBCXX20_CONSTEXPR + pointer + _M_data() const + { return _M_dataplus._M_p; } + + _GLIBCXX20_CONSTEXPR + pointer + _M_local_data() + { +#if __cplusplus >= 201103L + return std::pointer_traits::pointer_to(*_M_local_buf); +#else + return pointer(_M_local_buf); +#endif + } + + _GLIBCXX20_CONSTEXPR + const_pointer + _M_local_data() const + { +#if __cplusplus >= 201103L + return std::pointer_traits::pointer_to(*_M_local_buf); +#else + return const_pointer(_M_local_buf); +#endif + } + + _GLIBCXX20_CONSTEXPR + void + _M_capacity(size_type __capacity) + { _M_allocated_capacity = __capacity; } + + _GLIBCXX20_CONSTEXPR + void + _M_set_length(size_type __n) + { + _M_length(__n); + traits_type::assign(_M_data()[__n], _CharT()); + } + + _GLIBCXX20_CONSTEXPR + bool + _M_is_local() const + { return _M_data() == _M_local_data(); } + + // Create & Destroy + _GLIBCXX20_CONSTEXPR + pointer + _M_create(size_type&, size_type); + + _GLIBCXX20_CONSTEXPR + void + _M_dispose() + { + if (!_M_is_local()) + _M_destroy(_M_allocated_capacity); + } + + _GLIBCXX20_CONSTEXPR + void + _M_destroy(size_type __size) throw() + { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); } + +#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _M_construct_aux is used to implement the 21.3.1 para 15 which + // requires special behaviour if _InIterator is an integral type + template + void + _M_construct_aux(_InIterator __beg, _InIterator __end, + std::__false_type) + { + typedef typename iterator_traits<_InIterator>::iterator_category _Tag; + _M_construct(__beg, __end, _Tag()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type) + { _M_construct_aux_2(static_cast(__beg), __end); } + + void + _M_construct_aux_2(size_type __req, _CharT __c) + { _M_construct(__req, __c); } +#endif + + // For Input Iterators, used in istreambuf_iterators, etc. + template + _GLIBCXX20_CONSTEXPR + void + _M_construct(_InIterator __beg, _InIterator __end, + std::input_iterator_tag); + + // For forward_iterators up to random_access_iterators, used for + // string::iterator, _CharT*, etc. + template + _GLIBCXX20_CONSTEXPR + void + _M_construct(_FwdIterator __beg, _FwdIterator __end, + std::forward_iterator_tag); + + _GLIBCXX20_CONSTEXPR + void + _M_construct(size_type __req, _CharT __c); + + _GLIBCXX20_CONSTEXPR + allocator_type& + _M_get_allocator() + { return _M_dataplus; } + + _GLIBCXX20_CONSTEXPR + const allocator_type& + _M_get_allocator() const + { return _M_dataplus; } + + // Ensure that _M_local_buf is the active member of the union. + __attribute__((__always_inline__)) + _GLIBCXX14_CONSTEXPR + pointer + _M_use_local_data() _GLIBCXX_NOEXCEPT + { +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + for (_CharT& __c : _M_local_buf) + __c = _CharT(); +#endif + return _M_local_data(); + } + + private: + +#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST + // The explicit instantiations in misc-inst.cc require this due to + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64063 + template::__value + && !__are_same<_Tp, const _CharT*>::__value + && !__are_same<_Tp, iterator>::__value + && !__are_same<_Tp, const_iterator>::__value> + struct __enable_if_not_native_iterator + { typedef basic_string& __type; }; + template + struct __enable_if_not_native_iterator<_Tp, false> { }; +#endif + + _GLIBCXX20_CONSTEXPR + size_type + _M_check(size_type __pos, const char* __s) const + { + if (__pos > this->size()) + __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > " + "this->size() (which is %zu)"), + __s, __pos, this->size()); + return __pos; + } + + _GLIBCXX20_CONSTEXPR + void + _M_check_length(size_type __n1, size_type __n2, const char* __s) const + { + if (this->max_size() - (this->size() - __n1) < __n2) + __throw_length_error(__N(__s)); + } + + + // NB: _M_limit doesn't check for a bad __pos value. + _GLIBCXX20_CONSTEXPR + size_type + _M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT + { + const bool __testoff = __off < this->size() - __pos; + return __testoff ? __off : this->size() - __pos; + } + + // True if _Rep and source do not overlap. + bool + _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT + { + return (less()(__s, _M_data()) + || less()(_M_data() + this->size(), __s)); + } + + // When __n = 1 way faster than the general multichar + // traits_type::copy/move/assign. + _GLIBCXX20_CONSTEXPR + static void + _S_copy(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::copy(__d, __s, __n); + } + + _GLIBCXX20_CONSTEXPR + static void + _S_move(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::move(__d, __s, __n); + } + + _GLIBCXX20_CONSTEXPR + static void + _S_assign(_CharT* __d, size_type __n, _CharT __c) + { + if (__n == 1) + traits_type::assign(*__d, __c); + else + traits_type::assign(__d, __n, __c); + } + + // _S_copy_chars is a separate template to permit specialization + // to optimize for the common case of pointers as iterators. + template + _GLIBCXX20_CONSTEXPR + static void + _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) + { + for (; __k1 != __k2; ++__k1, (void)++__p) + traits_type::assign(*__p, *__k1); // These types are off. + } + + _GLIBCXX20_CONSTEXPR + static void + _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + _GLIBCXX20_CONSTEXPR + static void + _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) + _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + _GLIBCXX20_CONSTEXPR + static void + _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + _GLIBCXX20_CONSTEXPR + static void + _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) + _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + _GLIBCXX20_CONSTEXPR + static int + _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT + { + const difference_type __d = difference_type(__n1 - __n2); + + if (__d > __gnu_cxx::__numeric_traits::__max) + return __gnu_cxx::__numeric_traits::__max; + else if (__d < __gnu_cxx::__numeric_traits::__min) + return __gnu_cxx::__numeric_traits::__min; + else + return int(__d); + } + + _GLIBCXX20_CONSTEXPR + void + _M_assign(const basic_string&); + + _GLIBCXX20_CONSTEXPR + void + _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, + size_type __len2); + + _GLIBCXX20_CONSTEXPR + void + _M_erase(size_type __pos, size_type __n); + + public: + // Construct/copy/destroy: + // NB: We overload ctors in some cases instead of using default + // arguments, per 17.4.4.4 para. 2 item 2. + + /** + * @brief Default constructor creates an empty string. + */ + _GLIBCXX20_CONSTEXPR + basic_string() + _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value) + : _M_dataplus(_M_local_data()) + { + _M_use_local_data(); + _M_set_length(0); + } + + /** + * @brief Construct an empty string using allocator @a a. + */ + _GLIBCXX20_CONSTEXPR + explicit + basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT + : _M_dataplus(_M_local_data(), __a) + { + _M_use_local_data(); + _M_set_length(0); + } + + /** + * @brief Construct string with copy of value of @a __str. + * @param __str Source string. + */ + _GLIBCXX20_CONSTEXPR + basic_string(const basic_string& __str) + : _M_dataplus(_M_local_data(), + _Alloc_traits::_S_select_on_copy(__str._M_get_allocator())) + { + _M_construct(__str._M_data(), __str._M_data() + __str.length(), + std::forward_iterator_tag()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2583. no way to supply an allocator for basic_string(str, pos) + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __a Allocator to use. + */ + _GLIBCXX20_CONSTEXPR + basic_string(const basic_string& __str, size_type __pos, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { + const _CharT* __start = __str._M_data() + + __str._M_check(__pos, "basic_string::basic_string"); + _M_construct(__start, __start + __str._M_limit(__pos, npos), + std::forward_iterator_tag()); + } + + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + */ + _GLIBCXX20_CONSTEXPR + basic_string(const basic_string& __str, size_type __pos, + size_type __n) + : _M_dataplus(_M_local_data()) + { + const _CharT* __start = __str._M_data() + + __str._M_check(__pos, "basic_string::basic_string"); + _M_construct(__start, __start + __str._M_limit(__pos, __n), + std::forward_iterator_tag()); + } + + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + * @param __a Allocator to use. + */ + _GLIBCXX20_CONSTEXPR + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a) + : _M_dataplus(_M_local_data(), __a) + { + const _CharT* __start + = __str._M_data() + __str._M_check(__pos, "string::string"); + _M_construct(__start, __start + __str._M_limit(__pos, __n), + std::forward_iterator_tag()); + } + + /** + * @brief Construct string initialized by a character %array. + * @param __s Source character %array. + * @param __n Number of characters to copy. + * @param __a Allocator to use (default is default allocator). + * + * NB: @a __s must have at least @a __n characters, '\\0' + * has no special meaning. + */ + _GLIBCXX20_CONSTEXPR + basic_string(const _CharT* __s, size_type __n, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { + // NB: Not required, but considered best practice. + if (__s == 0 && __n > 0) + std::__throw_logic_error(__N("basic_string: " + "construction from null is not valid")); + _M_construct(__s, __s + __n, std::forward_iterator_tag()); + } + + /** + * @brief Construct string as copy of a C string. + * @param __s Source C string. + * @param __a Allocator to use (default is default allocator). + */ +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + _GLIBCXX20_CONSTEXPR + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { + // NB: Not required, but considered best practice. + if (__s == 0) + std::__throw_logic_error(__N("basic_string: " + "construction from null is not valid")); + const _CharT* __end = __s + traits_type::length(__s); + _M_construct(__s, __end, forward_iterator_tag()); + } + + /** + * @brief Construct string as multiple characters. + * @param __n Number of characters. + * @param __c Character to use. + * @param __a Allocator to use (default is default allocator). + */ +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + _GLIBCXX20_CONSTEXPR + basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__n, __c); } + +#if __cplusplus >= 201103L + /** + * @brief Move construct string. + * @param __str Source string. + * + * The newly-created string contains the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + _GLIBCXX20_CONSTEXPR + basic_string(basic_string&& __str) noexcept + : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) + { + if (__str._M_is_local()) + { + traits_type::copy(_M_local_buf, __str._M_local_buf, + __str.length() + 1); + } + else + { + _M_data(__str._M_data()); + _M_capacity(__str._M_allocated_capacity); + } + + // Must use _M_length() here not _M_set_length() because + // basic_stringbuf relies on writing into unallocated capacity so + // we mess up the contents if we put a '\0' in the string. + _M_length(__str.length()); + __str._M_data(__str._M_local_data()); + __str._M_set_length(0); + } + + /** + * @brief Construct string from an initializer %list. + * @param __l std::initializer_list of characters. + * @param __a Allocator to use (default is default allocator). + */ + _GLIBCXX20_CONSTEXPR + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__l.begin(), __l.end(), std::forward_iterator_tag()); } + + _GLIBCXX20_CONSTEXPR + basic_string(const basic_string& __str, const _Alloc& __a) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__str.begin(), __str.end(), std::forward_iterator_tag()); } + + _GLIBCXX20_CONSTEXPR + basic_string(basic_string&& __str, const _Alloc& __a) + noexcept(_Alloc_traits::_S_always_equal()) + : _M_dataplus(_M_local_data(), __a) + { + if (__str._M_is_local()) + { + traits_type::copy(_M_local_buf, __str._M_local_buf, + __str.length() + 1); + _M_length(__str.length()); + __str._M_set_length(0); + } + else if (_Alloc_traits::_S_always_equal() + || __str.get_allocator() == __a) + { + _M_data(__str._M_data()); + _M_length(__str.length()); + _M_capacity(__str._M_allocated_capacity); + __str._M_data(__str._M_local_buf); + __str._M_set_length(0); + } + else + _M_construct(__str.begin(), __str.end(), std::forward_iterator_tag()); + } +#endif // C++11 + +#if __cplusplus >= 202100L + basic_string(nullptr_t) = delete; + basic_string& operator=(nullptr_t) = delete; +#endif // C++23 + + /** + * @brief Construct string as copy of a range. + * @param __beg Start of range. + * @param __end End of range. + * @param __a Allocator to use (default is default allocator). + */ +#if __cplusplus >= 201103L + template> +#else + template +#endif + _GLIBCXX20_CONSTEXPR + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { +#if __cplusplus >= 201103L + _M_construct(__beg, __end, std::__iterator_category(__beg)); +#else + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_construct_aux(__beg, __end, _Integral()); +#endif + } + +#if __cplusplus >= 201703L + /** + * @brief Construct string from a substring of a string_view. + * @param __t Source object convertible to string view. + * @param __pos The index of the first character to copy from __t. + * @param __n The number of characters to copy from __t. + * @param __a Allocator to use. + */ + template>> + _GLIBCXX20_CONSTEXPR + basic_string(const _Tp& __t, size_type __pos, size_type __n, + const _Alloc& __a = _Alloc()) + : basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { } + + /** + * @brief Construct string from a string_view. + * @param __t Source object convertible to string view. + * @param __a Allocator to use (default is default allocator). + */ + template> + _GLIBCXX20_CONSTEXPR + explicit + basic_string(const _Tp& __t, const _Alloc& __a = _Alloc()) + : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { } +#endif // C++17 + + /** + * @brief Destroy the string instance. + */ + _GLIBCXX20_CONSTEXPR + ~basic_string() + { _M_dispose(); } + + /** + * @brief Assign the value of @a str to this string. + * @param __str Source string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator=(const basic_string& __str) + { + return this->assign(__str); + } + + /** + * @brief Copy contents of @a s into this string. + * @param __s Source null-terminated string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator=(const _CharT* __s) + { return this->assign(__s); } + + /** + * @brief Set value to string of length 1. + * @param __c Source character. + * + * Assigning to a character makes this string length 1 and + * (*this)[0] == @a c. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator=(_CharT __c) + { + this->assign(1, __c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Move assign the value of @a str to this string. + * @param __str Source string. + * + * The contents of @a str are moved into this string (without copying). + * @a str is a valid, but unspecified string. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2063. Contradictory requirements for string move assignment + _GLIBCXX20_CONSTEXPR + basic_string& + operator=(basic_string&& __str) + noexcept(_Alloc_traits::_S_nothrow_move()) + { + if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign() + && !_Alloc_traits::_S_always_equal() + && _M_get_allocator() != __str._M_get_allocator()) + { + // Destroy existing storage before replacing allocator. + _M_destroy(_M_allocated_capacity); + _M_data(_M_local_data()); + _M_set_length(0); + } + // Replace allocator if POCMA is true. + std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator()); + + if (__str._M_is_local()) + { + // We've always got room for a short string, just copy it + // (unless this is a self-move, because that would violate the + // char_traits::copy precondition that the ranges don't overlap). + if (__builtin_expect(std::__addressof(__str) != this, true)) + { + if (__str.size()) + this->_S_copy(_M_data(), __str._M_data(), __str.size()); + _M_set_length(__str.size()); + } + } + else if (_Alloc_traits::_S_propagate_on_move_assign() + || _Alloc_traits::_S_always_equal() + || _M_get_allocator() == __str._M_get_allocator()) + { + // Just move the allocated pointer, our allocator can free it. + pointer __data = nullptr; + size_type __capacity; + if (!_M_is_local()) + { + if (_Alloc_traits::_S_always_equal()) + { + // __str can reuse our existing storage. + __data = _M_data(); + __capacity = _M_allocated_capacity; + } + else // __str can't use it, so free it. + _M_destroy(_M_allocated_capacity); + } + + _M_data(__str._M_data()); + _M_length(__str.length()); + _M_capacity(__str._M_allocated_capacity); + if (__data) + { + __str._M_data(__data); + __str._M_capacity(__capacity); + } + else + __str._M_data(__str._M_local_buf); + } + else // Need to do a deep copy + assign(__str); + __str.clear(); + return *this; + } + + /** + * @brief Set value to string constructed from initializer %list. + * @param __l std::initializer_list. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator=(initializer_list<_CharT> __l) + { + this->assign(__l.begin(), __l.size()); + return *this; + } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value to string constructed from a string_view. + * @param __svt An object convertible to string_view. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + operator=(const _Tp& __svt) + { return this->assign(__svt); } + + /** + * @brief Convert to a string_view. + * @return A string_view. + */ + _GLIBCXX20_CONSTEXPR + operator __sv_type() const noexcept + { return __sv_type(data(), size()); } +#endif // C++17 + + // Iterators: + /** + * Returns a read/write iterator that points to the first character in + * the %string. + */ + _GLIBCXX20_CONSTEXPR + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_M_data()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + _GLIBCXX20_CONSTEXPR + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data()); } + + /** + * Returns a read/write iterator that points one past the last + * character in the %string. + */ + _GLIBCXX20_CONSTEXPR + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_M_data() + this->size()); } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + _GLIBCXX20_CONSTEXPR + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data() + this->size()); } + + /** + * Returns a read/write reverse iterator that points to the last + * character in the %string. Iteration is done in reverse element + * order. + */ + _GLIBCXX20_CONSTEXPR + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first character in the %string. Iteration is done in reverse + * element order. + */ + _GLIBCXX20_CONSTEXPR + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + _GLIBCXX20_CONSTEXPR + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_data()); } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + _GLIBCXX20_CONSTEXPR + const_iterator + cend() const noexcept + { return const_iterator(this->_M_data() + this->size()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(this->begin()); } +#endif + + public: + // Capacity: + /// Returns the number of characters in the string, not including any + /// null-termination. + _GLIBCXX20_CONSTEXPR + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the number of characters in the string, not including any + /// null-termination. + _GLIBCXX20_CONSTEXPR + size_type + length() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the size() of the largest possible %string. + _GLIBCXX20_CONSTEXPR + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; } + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * @param __c Character to fill any new elements. + * + * This function will %resize the %string to the specified + * number of characters. If the number is smaller than the + * %string's current size the %string is truncated, otherwise + * the %string is extended and new elements are %set to @a __c. + */ + _GLIBCXX20_CONSTEXPR + void + resize(size_type __n, _CharT __c); + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * + * This function will resize the %string to the specified length. If + * the new size is smaller than the %string's current size the %string + * is truncated, otherwise the %string is extended and new characters + * are default-constructed. For basic types such as char, this means + * setting them to 0. + */ + _GLIBCXX20_CONSTEXPR + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /// A non-binding request to reduce capacity() to size(). + _GLIBCXX20_CONSTEXPR + void + shrink_to_fit() noexcept + { reserve(); } +#pragma GCC diagnostic pop +#endif + +#if __cplusplus > 202002L +#define __cpp_lib_string_resize_and_overwrite 202110L + template + constexpr void + resize_and_overwrite(size_type __n, _Operation __op); +#endif + + /** + * Returns the total number of characters that the %string can hold + * before needing to allocate more memory. + */ + _GLIBCXX20_CONSTEXPR + size_type + capacity() const _GLIBCXX_NOEXCEPT + { + return _M_is_local() ? size_type(_S_local_capacity) + : _M_allocated_capacity; + } + + /** + * @brief Attempt to preallocate enough memory for specified number of + * characters. + * @param __res_arg Number of characters required. + * @throw std::length_error If @a __res_arg exceeds @c max_size(). + * + * This function attempts to reserve enough memory for the + * %string to hold the specified number of characters. If the + * number requested is more than max_size(), length_error is + * thrown. + * + * The advantage of this function is that if optimal code is a + * necessity and the user can determine the string length that will be + * required, the user can reserve the memory in %advance, and thus + * prevent a possible reallocation of memory and copying of %string + * data. + */ + _GLIBCXX20_CONSTEXPR + void + reserve(size_type __res_arg); + + /** + * Equivalent to shrink_to_fit(). + */ +#if __cplusplus > 201703L + [[deprecated("use shrink_to_fit() instead")]] +#endif + _GLIBCXX20_CONSTEXPR + void + reserve(); + + /** + * Erases the string, making it empty. + */ + _GLIBCXX20_CONSTEXPR + void + clear() _GLIBCXX_NOEXCEPT + { _M_set_length(0); } + + /** + * Returns true if the %string is empty. Equivalent to + * *this == "". + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + bool + empty() const _GLIBCXX_NOEXCEPT + { return this->size() == 0; } + + // Element access: + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read-only (constant) reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX20_CONSTEXPR + const_reference + operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT + { + __glibcxx_assert(__pos <= size()); + return _M_data()[__pos]; + } + + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read/write reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX20_CONSTEXPR + reference + operator[](size_type __pos) + { + // Allow pos == size() both in C++98 mode, as v3 extension, + // and in C++11 mode. + __glibcxx_assert(__pos <= size()); + // In pedantic mode be strict in C++98 mode. + _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size()); + return _M_data()[__pos]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read-only (const) reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. + */ + _GLIBCXX20_CONSTEXPR + const_reference + at(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + return _M_data()[__n]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read/write reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. + */ + _GLIBCXX20_CONSTEXPR + reference + at(size_type __n) + { + if (__n >= size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + return _M_data()[__n]; + } + +#if __cplusplus >= 201103L + /** + * Returns a read/write reference to the data at the first + * element of the %string. + */ + _GLIBCXX20_CONSTEXPR + reference + front() noexcept + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %string. + */ + _GLIBCXX20_CONSTEXPR + const_reference + front() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %string. + */ + _GLIBCXX20_CONSTEXPR + reference + back() noexcept + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %string. + */ + _GLIBCXX20_CONSTEXPR + const_reference + back() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } +#endif + + // Modifiers: + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator+=(const basic_string& __str) + { return this->append(__str); } + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator+=(const _CharT* __s) + { return this->append(__s); } + + /** + * @brief Append a character. + * @param __c The character to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator+=(_CharT __c) + { + this->push_back(__c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to be appended. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + operator+=(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt An object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + operator+=(const _Tp& __svt) + { return this->append(__svt); } +#endif // C++17 + + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(const basic_string& __str) + { return this->append(__str._M_data(), __str.size()); } + + /** + * @brief Append a substring. + * @param __str The string to append. + * @param __pos Index of the first character of str to append. + * @param __n The number of characters to append. + * @return Reference to this string. + * @throw std::out_of_range if @a __pos is not a valid index. + * + * This function appends @a __n characters from @a __str + * starting at @a __pos to this string. If @a __n is is larger + * than the number of available characters in @a __str, the + * remainder of @a __str is appended. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n = npos) + { return this->append(__str._M_data() + + __str._M_check(__pos, "basic_string::append"), + __str._M_limit(__pos, __n)); } + + /** + * @brief Append a C substring. + * @param __s The C string to append. + * @param __n The number of characters to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check_length(size_type(0), __n, "basic_string::append"); + return _M_append(__s, __n); + } + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(const _CharT* __s) + { + __glibcxx_requires_string(__s); + const size_type __n = traits_type::length(__s); + _M_check_length(size_type(0), __n, "basic_string::append"); + return _M_append(__s, __n); + } + + /** + * @brief Append multiple characters. + * @param __n The number of characters to append. + * @param __c The character to use. + * @return Reference to this string. + * + * Appends __n copies of __c to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(size_type __n, _CharT __c) + { return _M_replace_aux(this->size(), size_type(0), __n, __c); } + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to append. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + append(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + + /** + * @brief Append a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Appends characters in the range [__first,__last) to this string. + */ +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR +#else + template +#endif + basic_string& + append(_InputIterator __first, _InputIterator __last) + { return this->replace(end(), end(), __first, __last); } + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt An object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->append(__sv.data(), __sv.size()); + } + + /** + * @brief Append a range of characters from a string_view. + * @param __svt An object convertible to string_view to be appended from. + * @param __pos The position in the string_view to append from. + * @param __n The number of characters to append from the string_view. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return _M_append(__sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::append"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + + /** + * @brief Append a single character. + * @param __c Character to append. + */ + _GLIBCXX20_CONSTEXPR + void + push_back(_CharT __c) + { + const size_type __size = this->size(); + if (__size + 1 > this->capacity()) + this->_M_mutate(__size, size_type(0), 0, size_type(1)); + traits_type::assign(this->_M_data()[__size], __c); + this->_M_set_length(__size + 1); + } + + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(const basic_string& __str) + { +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() && !_M_is_local() + && _M_get_allocator() != __str._M_get_allocator()) + { + // Propagating allocator cannot free existing storage so must + // deallocate it before replacing current allocator. + if (__str.size() <= _S_local_capacity) + { + _M_destroy(_M_allocated_capacity); + _M_data(_M_use_local_data()); + _M_set_length(0); + } + else + { + const auto __len = __str.size(); + auto __alloc = __str._M_get_allocator(); + // If this allocation throws there are no effects: + auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1); + _M_destroy(_M_allocated_capacity); + _M_data(__ptr); + _M_capacity(__len); + _M_set_length(__len); + } + } + std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator()); + } +#endif + this->_M_assign(__str); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + * + * This function sets this string to the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(basic_string&& __str) + noexcept(_Alloc_traits::_S_nothrow_move()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2063. Contradictory requirements for string move assignment + return *this = std::move(__str); + } +#endif // C++11 + + /** + * @brief Set value to a substring of a string. + * @param __str The string to use. + * @param __pos Index of the first character of str. + * @param __n Number of characters to use. + * @return Reference to this string. + * @throw std::out_of_range if @a pos is not a valid index. + * + * This function sets this string to the substring of @a __str + * consisting of @a __n characters at @a __pos. If @a __n is + * is larger than the number of available characters in @a + * __str, the remainder of @a __str is used. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n = npos) + { return _M_replace(size_type(0), this->size(), __str._M_data() + + __str._M_check(__pos, "basic_string::assign"), + __str._M_limit(__pos, __n)); } + + /** + * @brief Set value to a C substring. + * @param __s The C string to use. + * @param __n Number of characters to use. + * @return Reference to this string. + * + * This function sets the value of this string to the first @a __n + * characters of @a __s. If @a __n is is larger than the number of + * available characters in @a __s, the remainder of @a __s is used. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + return _M_replace(size_type(0), this->size(), __s, __n); + } + + /** + * @brief Set value to contents of a C string. + * @param __s The C string to use. + * @return Reference to this string. + * + * This function sets the value of this string to the value of @a __s. + * The data is copied, so there is no dependence on @a __s once the + * function returns. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return _M_replace(size_type(0), this->size(), __s, + traits_type::length(__s)); + } + + /** + * @brief Set value to multiple characters. + * @param __n Length of the resulting string. + * @param __c The character to use. + * @return Reference to this string. + * + * This function sets the value of this string to @a __n copies of + * character @a __c. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(size_type __n, _CharT __c) + { return _M_replace_aux(size_type(0), this->size(), __n, __c); } + + /** + * @brief Set value to a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Sets value of string to characters in the range [__first,__last). + */ +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR +#else + template +#endif + basic_string& + assign(_InputIterator __first, _InputIterator __last) + { return this->replace(begin(), end(), __first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Set value to an initializer_list of characters. + * @param __l The initializer_list of characters to assign. + * @return Reference to this string. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + assign(initializer_list<_CharT> __l) + { return this->assign(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value from a string_view. + * @param __svt The source object convertible to string_view. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->assign(__sv.data(), __sv.size()); + } + + /** + * @brief Set value from a range of characters in a string_view. + * @param __svt The source object convertible to string_view. + * @param __pos The position in the string_view to assign from. + * @param __n The number of characters to assign. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return _M_replace(size_type(0), this->size(), + __sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::assign"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + +#if __cplusplus >= 201103L + /** + * @brief Insert multiple characters. + * @param __p Const_iterator referencing location in string to + * insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Iterator referencing the first inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __p, size_type __n, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + this->replace(__p, __p, __n, __c); + return iterator(this->_M_data() + __pos); + } +#else + /** + * @brief Insert multiple characters. + * @param __p Iterator referencing location in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + void + insert(iterator __p, size_type __n, _CharT __c) + { this->replace(__p, __p, __n, __c); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert a range of characters. + * @param __p Const_iterator referencing location in string to + * insert at. + * @param __beg Start of range. + * @param __end End of range. + * @return Iterator referencing the first inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [beg,end). If adding characters + * causes the length to exceed max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + template> + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __p, _InputIterator __beg, _InputIterator __end) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + this->replace(__p, __p, __beg, __end); + return iterator(this->_M_data() + __pos); + } +#else + /** + * @brief Insert a range of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __beg Start of range. + * @param __end End of range. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [__beg,__end). If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + template + void + insert(iterator __p, _InputIterator __beg, _InputIterator __end) + { this->replace(__p, __p, __beg, __end); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert an initializer_list of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __l The initializer_list of characters to insert. + * @throw std::length_error If new length exceeds @c max_size(). + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __p, initializer_list<_CharT> __l) + { return this->insert(__p, __l.begin(), __l.end()); } + +#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // See PR libstdc++/83328 + void + insert(iterator __p, initializer_list<_CharT> __l) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + this->insert(__p - begin(), __l.begin(), __l.size()); + } +#endif +#endif // C++11 + + /** + * @brief Insert value of a string. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts value of @a __str starting at @a __pos1. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + insert(size_type __pos1, const basic_string& __str) + { return this->replace(__pos1, size_type(0), + __str._M_data(), __str.size()); } + + /** + * @brief Insert a substring. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @param __pos2 Start of characters in str to insert. + * @param __n Number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos1 > size() or + * @a __pos2 > @a str.size(). + * + * Starting at @a pos1, insert @a __n character of @a __str + * beginning with @a __pos2. If adding characters causes the + * length to exceed max_size(), length_error is thrown. If @a + * __pos1 is beyond the end of this string or @a __pos2 is + * beyond the end of @a __str, out_of_range is thrown. The + * value of the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n = npos) + { return this->replace(__pos1, size_type(0), __str._M_data() + + __str._M_check(__pos2, "basic_string::insert"), + __str._M_limit(__pos2, __n)); } + + /** + * @brief Insert a C substring. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @param __n The number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts the first @a __n characters of @a __s starting at @a + * __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos is beyond + * end(), out_of_range is thrown. The value of the string + * doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __n) + { return this->replace(__pos, size_type(0), __s, __n); } + + /** + * @brief Insert a C string. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Inserts the first @a n characters of @a __s starting at @a __pos. If + * adding characters causes the length to exceed max_size(), + * length_error is thrown. If @a __pos is beyond end(), out_of_range is + * thrown. The value of the string doesn't change if an error is + * thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + insert(size_type __pos, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__pos, size_type(0), __s, + traits_type::length(__s)); + } + + /** + * @brief Insert multiple characters. + * @param __pos Index in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts @a __n copies of character @a __c starting at index + * @a __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos > length(), + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + insert(size_type __pos, size_type __n, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::insert"), + size_type(0), __n, __c); } + + /** + * @brief Insert one character. + * @param __p Iterator referencing position in string to insert at. + * @param __c The character to insert. + * @return Iterator referencing newly inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts character @a __c at position referenced by @a __p. + * If adding character causes the length to exceed max_size(), + * length_error is thrown. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(__const_iterator __p, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + _M_replace_aux(__pos, size_type(0), size_type(1), __c); + return iterator(_M_data() + __pos); + } + +#if __cplusplus >= 201703L + /** + * @brief Insert a string_view. + * @param __pos Position in string to insert at. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + insert(size_type __pos, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->insert(__pos, __sv.data(), __sv.size()); + } + + /** + * @brief Insert a string_view. + * @param __pos1 Position in string to insert at. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 Start of characters in str to insert. + * @param __n The number of characters to insert. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + insert(size_type __pos1, const _Tp& __svt, + size_type __pos2, size_type __n = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, size_type(0), + __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::insert"), + std::__sv_limit(__sv.size(), __pos2, __n)); + } +#endif // C++17 + + /** + * @brief Remove characters. + * @param __pos Index of first character to remove (default 0). + * @param __n Number of characters to remove (default remainder). + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Removes @a __n characters from this string starting at @a + * __pos. The length of the string is reduced by @a __n. If + * there are < @a __n characters to remove, the remainder of + * the string is truncated. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + erase(size_type __pos = 0, size_type __n = npos) + { + _M_check(__pos, "basic_string::erase"); + if (__n == npos) + this->_M_set_length(__pos); + else if (__n != 0) + this->_M_erase(__pos, _M_limit(__pos, __n)); + return *this; + } + + /** + * @brief Remove one character. + * @param __position Iterator referencing the character to remove. + * @return iterator referencing same location after removal. + * + * Removes the character at @a __position from this string. The value + * of the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + iterator + erase(__const_iterator __position) + { + _GLIBCXX_DEBUG_PEDASSERT(__position >= begin() + && __position < end()); + const size_type __pos = __position - begin(); + this->_M_erase(__pos, size_type(1)); + return iterator(_M_data() + __pos); + } + + /** + * @brief Remove a range of characters. + * @param __first Iterator referencing the first character to remove. + * @param __last Iterator referencing the end of the range. + * @return Iterator referencing location of first after removal. + * + * Removes the characters in the range [first,last) from this string. + * The value of the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + iterator + erase(__const_iterator __first, __const_iterator __last) + { + _GLIBCXX_DEBUG_PEDASSERT(__first >= begin() && __first <= __last + && __last <= end()); + const size_type __pos = __first - begin(); + if (__last == end()) + this->_M_set_length(__pos); + else + this->_M_erase(__pos, __last - __first); + return iterator(this->_M_data() + __pos); + } + +#if __cplusplus >= 201103L + /** + * @brief Remove the last character. + * + * The string must be non-empty. + */ + _GLIBCXX20_CONSTEXPR + void + pop_back() noexcept + { + __glibcxx_assert(!empty()); + _M_erase(size() - 1, 1); + } +#endif // C++11 + + /** + * @brief Replace characters with value from another string. + * @param __pos Index of first character to replace. + * @param __n Number of characters to be replaced. + * @param __str String to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos+__n) from + * this string. In place, the value of @a __str is inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of the result exceeds max_size(), length_error + * is thrown. The value of the string doesn't change if an + * error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(size_type __pos, size_type __n, const basic_string& __str) + { return this->replace(__pos, __n, __str._M_data(), __str.size()); } + + /** + * @brief Replace characters with value from another string. + * @param __pos1 Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __str String to insert. + * @param __pos2 Index of first character of str to use. + * @param __n2 Number of characters from str to use. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 > + * __str.size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos1,__pos1 + n) from this + * string. In place, the value of @a __str is inserted. If @a __pos is + * beyond end of string, out_of_range is thrown. If the length of the + * result exceeds max_size(), length_error is thrown. The value of the + * string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) + { return this->replace(__pos1, __n1, __str._M_data() + + __str._M_check(__pos2, "basic_string::replace"), + __str._M_limit(__pos2, __n2)); } + + /** + * @brief Replace characters with value of a C substring. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @param __n2 Number of characters from @a s to use. + * @return Reference to this string. + * @throw std::out_of_range If @a pos1 > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the first @a __n2 characters of + * @a __s are inserted, or all of @a __s if @a __n2 is too large. If + * @a __pos is beyond end of string, out_of_range is thrown. If + * the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) + { + __glibcxx_requires_string_len(__s, __n2); + return _M_replace(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __s, __n2); + } + + /** + * @brief Replace characters with value of a C string. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the characters of @a __s are + * inserted. If @a __pos is beyond end of string, out_of_range + * is thrown. If the length of result exceeds max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__pos, __n1, __s, traits_type::length(__s)); + } + + /** + * @brief Replace characters with multiple characters. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __n2 Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [pos,pos + n1) from this + * string. In place, @a __n2 copies of @a __c are inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __n2, __c); } + + /** + * @brief Replace range of characters with string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __str String value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the value of @a __str is inserted. If the length of result + * exceeds max_size(), length_error is thrown. The value of + * the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const basic_string& __str) + { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } + + /** + * @brief Replace range of characters with C substring. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @param __n Number of characters from s to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the first @a __n characters of @a __s are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __s, size_type __n) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + return this->replace(__i1 - begin(), __i2 - __i1, __s, __n); + } + + /** + * @brief Replace range of characters with C string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the characters of @a __s are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__i1, __i2, __s, traits_type::length(__s)); + } + + /** + * @brief Replace range of characters with multiple characters + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __n Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * @a __n copies of @a __c are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, size_type __n, + _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __c); + } + + /** + * @brief Replace range of characters with range. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __k1 Iterator referencing start of range to insert. + * @param __k2 Iterator referencing end of range to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + basic_string& + replace(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, + std::__false_type()); + } +#else + template +#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST + typename __enable_if_not_native_iterator<_InputIterator>::__type +#else + basic_string& +#endif + replace(iterator __i1, iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); + } +#endif + + // Specializations for the common case of pointer and iterator: + // useful to avoid the overhead of temporary buffering in _M_replace. + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + _CharT* __k1, _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __k1, const _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + iterator __k1, iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + + _GLIBCXX20_CONSTEXPR + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const_iterator __k1, const_iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + +#if __cplusplus >= 201103L + /** + * @brief Replace range of characters with initializer_list. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __l The initializer_list of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string& replace(const_iterator __i1, const_iterator __i2, + initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Replace range of characters with string_view. + * @param __pos The position to replace at. + * @param __n The number of characters to replace. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + replace(size_type __pos, size_type __n, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__pos, __n, __sv.data(), __sv.size()); + } + + /** + * @brief Replace range of characters with string_view. + * @param __pos1 The position to replace at. + * @param __n1 The number of characters to replace. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 The position in the string_view to insert from. + * @param __n2 The number of characters to insert. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + replace(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, __n1, + __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::replace"), + std::__sv_limit(__sv.size(), __pos2, __n2)); + } + + /** + * @brief Replace range of characters with string_view. + * @param __i1 An iterator referencing the start position + to replace at. + * @param __i2 An iterator referencing the end position + for the replace. + * @param __svt The object convertible to string_view to insert from. + * @return Reference to this string. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, basic_string&> + replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__i1 - begin(), __i2 - __i1, __sv); + } +#endif // C++17 + + private: + template + _GLIBCXX20_CONSTEXPR + basic_string& + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _Integer __n, _Integer __val, __true_type) + { return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __val); } + + template + _GLIBCXX20_CONSTEXPR + basic_string& + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + __false_type); + + _GLIBCXX20_CONSTEXPR + basic_string& + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c); + + _GLIBCXX20_CONSTEXPR + basic_string& + _M_replace(size_type __pos, size_type __len1, const _CharT* __s, + const size_type __len2); + + _GLIBCXX20_CONSTEXPR + basic_string& + _M_append(const _CharT* __s, size_type __n); + + public: + + /** + * @brief Copy substring into C string. + * @param __s C string to copy value into. + * @param __n Number of characters to copy. + * @param __pos Index of first character to copy. + * @return Number of characters actually copied + * @throw std::out_of_range If __pos > size(). + * + * Copies up to @a __n characters starting at @a __pos into the + * C string @a __s. If @a __pos is %greater than size(), + * out_of_range is thrown. + */ + _GLIBCXX20_CONSTEXPR + size_type + copy(_CharT* __s, size_type __n, size_type __pos = 0) const; + + /** + * @brief Swap contents with another string. + * @param __s String to swap with. + * + * Exchanges the contents of this string with that of @a __s in constant + * time. + */ + _GLIBCXX20_CONSTEXPR + void + swap(basic_string& __s) _GLIBCXX_NOEXCEPT; + + // String operations: + /** + * @brief Return const pointer to null-terminated contents. + * + * This is a handle to internal data. Do not modify or dire things may + * happen. + */ + _GLIBCXX20_CONSTEXPR + const _CharT* + c_str() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + + /** + * @brief Return const pointer to contents. + * + * This is a pointer to internal data. It is undefined to modify + * the contents through the returned pointer. To get a pointer that + * allows modifying the contents use @c &str[0] instead, + * (or in C++17 the non-const @c str.data() overload). + */ + _GLIBCXX20_CONSTEXPR + const _CharT* + data() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + +#if __cplusplus >= 201703L + /** + * @brief Return non-const pointer to contents. + * + * This is a pointer to the character sequence held by the string. + * Modifying the characters in the sequence is allowed. + */ + _GLIBCXX20_CONSTEXPR + _CharT* + data() noexcept + { return _M_data(); } +#endif + + /** + * @brief Return copy of allocator used to construct this string. + */ + _GLIBCXX20_CONSTEXPR + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _M_get_allocator(); } + + /** + * @brief Find position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from @a s to search for. + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a string. + * @param __str String to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for value of @a __str within + * this string. If found, returns the index where it begins. If not + * found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, size_type> + find(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the value of @a + * __s within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a string. + * @param __str String to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for value of @a + * __str within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + rfind(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->rfind(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, size_type> + rfind(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->rfind(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + rfind(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to start search at (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the value of + * @a __s within this string. If found, returns the index + * where it begins. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + rfind(const _CharT* __s, size_type __pos = npos) const + { + __glibcxx_requires_string(__s); + return this->rfind(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character of a string_view. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, size_type> + find_first_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character of C substring. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from s to search for. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character of C string. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for the character + * @a __c within this string. If found, returns the index + * where it was found. If not found, returns npos. + * + * Note: equivalent to find(__c, __pos). + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return this->find(__c, __pos); } + + /** + * @brief Find last position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character of string. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, size_type> + find_last_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character of C substring. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a character of C string. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + * + * Note: equivalent to rfind(__c, __pos). + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { return this->rfind(__c, __pos); } + + /** + * @brief Find position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not contained + * in @a __str within this string. If found, returns the index where it + * was found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_not_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character not in a string_view. + * @param __svt A object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + _GLIBCXX20_CONSTEXPR + find_first_not_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from. + * @param __n Number of characters from __s to consider. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in the first @a __n characters of @a __s within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_not_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character + * other than @a __c within this string. If found, returns the + * index where it was found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_not_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_not_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character not in a string_view. + * @param __svt An object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, size_type> + find_last_not_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to consider. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character not + * contained in the first @a __n characters of @a __s within this string. + * If found, returns the index where it was found. If not found, + * returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + /** + * @brief Find last position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __s within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_not_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character other than + * @a __c within this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + _GLIBCXX20_CONSTEXPR + size_type + find_last_not_of(_CharT __c, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Get a substring. + * @param __pos Index of first character (default 0). + * @param __n Number of characters in substring (default remainder). + * @return The new string. + * @throw std::out_of_range If __pos > size(). + * + * Construct and return a new string using the @a __n + * characters starting at @a __pos. If the string is too + * short, use the remainder of the characters. If @a __pos is + * beyond the end of the string, out_of_range is thrown. + */ + _GLIBCXX20_CONSTEXPR + basic_string + substr(size_type __pos = 0, size_type __n = npos) const + { return basic_string(*this, + _M_check(__pos, "basic_string::substr"), __n); } + + /** + * @brief Compare to a string. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a + * __str, 0 if their values are equivalent, or > 0 if this + * string is ordered after @a __str. Determines the effective + * length rlen of the strings to compare as the smallest of + * size() and str.size(). The function then compares the two + * strings by calling traits::compare(data(), str.data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + _GLIBCXX20_CONSTEXPR + int + compare(const basic_string& __str) const + { + const size_type __size = this->size(); + const size_type __osize = __str.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __str.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + +#if __cplusplus >= 201703L + /** + * @brief Compare to a string_view. + * @param __svt An object convertible to string_view to compare against. + * @return Integer < 0, 0, or > 0. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, int> + compare(const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + const size_type __size = this->size(); + const size_type __osize = __sv.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __sv.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + + /** + * @brief Compare to a string_view. + * @param __pos A position in the string to start comparing from. + * @param __n The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @return Integer < 0, 0, or > 0. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, int> + compare(size_type __pos, size_type __n, const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this).substr(__pos, __n).compare(__sv); + } + + /** + * @brief Compare to a string_view. + * @param __pos1 A position in the string to start comparing from. + * @param __n1 The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @param __pos2 A position in the string_view to start comparing from. + * @param __n2 The number of characters to compare. + * @return Integer < 0, 0, or > 0. + */ + template + _GLIBCXX20_CONSTEXPR + _If_sv<_Tp, int> + compare(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this) + .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); + } +#endif // C++17 + + /** + * @brief Compare substring to a string. + * @param __pos Index of first character of substring. + * @param __n Number of characters in substring. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n characters + * starting at @a __pos. Returns an integer < 0 if the + * substring is ordered before @a __str, 0 if their values are + * equivalent, or > 0 if the substring is ordered after @a + * __str. Determines the effective length rlen of the strings + * to compare as the smallest of the length of the substring + * and @a __str.size(). The function then compares the two + * strings by calling + * traits::compare(substring.data(),str.data(),rlen). If the + * result of the comparison is nonzero returns it, otherwise + * the shorter one is ordered first. + */ + _GLIBCXX20_CONSTEXPR + int + compare(size_type __pos, size_type __n, const basic_string& __str) const; + + /** + * @brief Compare substring to a substring. + * @param __pos1 Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __str String to compare against. + * @param __pos2 Index of first character of substring of str. + * @param __n2 Number of characters in substring of str. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos1. Form the substring of @a + * __str from the @a __n2 characters starting at @a __pos2. + * Returns an integer < 0 if this substring is ordered before + * the substring of @a __str, 0 if their values are equivalent, + * or > 0 if this substring is ordered after the substring of + * @a __str. Determines the effective length rlen of the + * strings to compare as the smallest of the lengths of the + * substrings. The function then compares the two strings by + * calling + * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + _GLIBCXX20_CONSTEXPR + int + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) const; + + /** + * @brief Compare to a C string. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a __s, 0 if + * their values are equivalent, or > 0 if this string is ordered after + * @a __s. Determines the effective length rlen of the strings to + * compare as the smallest of size() and the length of a string + * constructed from @a __s. The function then compares the two strings + * by calling traits::compare(data(),s,rlen). If the result of the + * comparison is nonzero returns it, otherwise the shorter one is + * ordered first. + */ + _GLIBCXX20_CONSTEXPR + int + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 5 String::compare specification questionable + /** + * @brief Compare substring to a C string. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a pos. Returns an integer < 0 if + * the substring is ordered before @a __s, 0 if their values + * are equivalent, or > 0 if the substring is ordered after @a + * __s. Determines the effective length rlen of the strings to + * compare as the smallest of the length of the substring and + * the length of a string constructed from @a __s. The + * function then compares the two string by calling + * traits::compare(substring.data(),__s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + */ + _GLIBCXX20_CONSTEXPR + int + compare(size_type __pos, size_type __n1, const _CharT* __s) const; + + /** + * @brief Compare substring against a character %array. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s character %array to compare against. + * @param __n2 Number of characters of s. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos. Form a string from the + * first @a __n2 characters of @a __s. Returns an integer < 0 + * if this substring is ordered before the string from @a __s, + * 0 if their values are equivalent, or > 0 if this substring + * is ordered after the string from @a __s. Determines the + * effective length rlen of the strings to compare as the + * smallest of the length of the substring and @a __n2. The + * function then compares the two strings by calling + * traits::compare(substring.data(),s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + * + * NB: s must have at least n2 characters, '\\0' has + * no special meaning. + */ + _GLIBCXX20_CONSTEXPR + int + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const; + +#if __cplusplus >= 202002L + constexpr bool + starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + constexpr bool + starts_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + constexpr bool + starts_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + constexpr bool + ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + constexpr bool + ends_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + constexpr bool + ends_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } +#endif // C++20 + +#if __cplusplus > 202002L + constexpr bool + contains(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + constexpr bool + contains(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + constexpr bool + contains(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } +#endif // C++23 + + // Allow basic_stringbuf::__xfer_bufptrs to call _M_length: + template friend class basic_stringbuf; + }; +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // _GLIBCXX_USE_CXX11_ABI + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cpp_deduction_guides >= 201606 +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template::value_type, + typename _Allocator = allocator<_CharT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3075. basic_string needs deduction guides from basic_string_view + template, + typename = _RequireAllocator<_Allocator>> + basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) + -> basic_string<_CharT, _Traits, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + basic_string(basic_string_view<_CharT, _Traits>, + typename basic_string<_CharT, _Traits, _Allocator>::size_type, + typename basic_string<_CharT, _Traits, _Allocator>::size_type, + const _Allocator& = _Allocator()) + -> basic_string<_CharT, _Traits, _Allocator>; +_GLIBCXX_END_NAMESPACE_CXX11 +#endif + + // operator+ + /** + * @brief Concatenate two strings. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with value of @a __lhs followed by @a __rhs. + */ + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + basic_string<_CharT, _Traits, _Alloc> __str(__lhs); + __str.append(__rhs); + return __str; + } + + /** + * @brief Concatenate C string and string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with value of @a __lhs followed by @a __rhs. + */ + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT,_Traits,_Alloc> + operator+(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Alloc>& __rhs); + + /** + * @brief Concatenate character and string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT,_Traits,_Alloc> + operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); + + /** + * @brief Concatenate string and C string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { + basic_string<_CharT, _Traits, _Alloc> __str(__lhs); + __str.append(__rhs); + return __str; + } + + /** + * @brief Concatenate string and character. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) + { + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + __string_type __str(__lhs); + __str.append(__size_type(1), __rhs); + return __str; + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return std::move(__lhs.append(__rhs)); } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, __lhs)); } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { +#if _GLIBCXX_USE_CXX11_ABI + using _Alloc_traits = allocator_traits<_Alloc>; + bool __use_rhs = false; + if _GLIBCXX17_CONSTEXPR (typename _Alloc_traits::is_always_equal{}) + __use_rhs = true; + else if (__lhs.get_allocator() == __rhs.get_allocator()) + __use_rhs = true; + if (__use_rhs) +#endif + { + const auto __size = __lhs.size() + __rhs.size(); + if (__size > __lhs.capacity() && __size <= __rhs.capacity()) + return std::move(__rhs.insert(0, __lhs)); + } + return std::move(__lhs.append(__rhs)); + } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const _CharT* __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, __lhs)); } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(_CharT __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, 1, __lhs)); } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + const _CharT* __rhs) + { return std::move(__lhs.append(__rhs)); } + + template + _GLIBCXX20_CONSTEXPR + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + _CharT __rhs) + { return std::move(__lhs.append(1, __rhs)); } +#endif + + // operator == + /** + * @brief Test equivalence of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) == 0; } + + template + _GLIBCXX20_CONSTEXPR + inline + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type + operator==(const basic_string<_CharT>& __lhs, + const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT + { return (__lhs.size() == __rhs.size() + && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), + __lhs.size())); } + + /** + * @brief Test equivalence of string and C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a string and a C string. + * @param __lhs A string. + * @param __rhs A null-terminated string. + * @return A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + constexpr auto + operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept + -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) + { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); } + + /** + * @brief Three-way comparison of a string and a C string. + * @param __lhs A string. + * @param __rhs A null-terminated string. + * @return A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + constexpr auto + operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) noexcept + -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) + { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); } +#else + /** + * @brief Test equivalence of C string and string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise. + */ + template + inline bool + operator==(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) == 0; } + + // operator != + /** + * @brief Test difference of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return !(__lhs == __rhs); } + + /** + * @brief Test difference of C string and string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Test difference of string and C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return !(__lhs == __rhs); } + + // operator < + /** + * @brief Test if string precedes string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Test if string precedes C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Test if C string precedes string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) > 0; } + + // operator > + /** + * @brief Test if string follows string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Test if string follows C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Test if C string follows string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) < 0; } + + // operator <= + /** + * @brief Test if string doesn't follow string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Test if string doesn't follow C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Test if C string doesn't follow string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) >= 0; } + + // operator >= + /** + * @brief Test if string doesn't precede string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Test if string doesn't precede C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Test if C string doesn't precede string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) <= 0; } +#endif // three-way comparison + + /** + * @brief Swap contents of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * + * Exchanges the contents of @a __lhs and @a __rhs in constant time. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, + basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + + + /** + * @brief Read stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @return Reference to the input stream. + * + * Stores characters from @a __is into @a __str until whitespace is + * found, the end of the stream is encountered, or str.max_size() + * is reached. If is.width() is non-zero, that is the limit on the + * number of characters stored into @a __str. Any previous + * contents of @a __str are erased. + */ + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str); + + template<> + basic_istream& + operator>>(basic_istream& __is, basic_string& __str); + + /** + * @brief Write string to a stream. + * @param __os Output stream. + * @param __str String to write out. + * @return Reference to the output stream. + * + * Output characters of @a __str into os following the same rules as for + * writing a C string. + */ + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const basic_string<_CharT, _Traits, _Alloc>& __str) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 586. string inserter not a formatted function + return __ostream_insert(__os, __str.data(), __str.size()); + } + + /** + * @brief Read a line from stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @param __delim Character marking end of line. + * @return Reference to the input stream. + * + * Stores characters from @a __is into @a __str until @a __delim is + * found, the end of the stream is encountered, or str.max_size() + * is reached. Any previous contents of @a __str are erased. If + * @a __delim is encountered, it is extracted but not stored into + * @a __str. + */ + template + basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim); + + /** + * @brief Read a line from stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @return Reference to the input stream. + * + * Stores characters from is into @a __str until '\n' is + * found, the end of the stream is encountered, or str.max_size() + * is reached. Any previous contents of @a __str are erased. If + * end of line is encountered, it is extracted but not stored into + * @a __str. + */ + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str) + { return std::getline(__is, __str, __is.widen('\n')); } + +#if __cplusplus >= 201103L + /// Read a line from an rvalue stream into a string. + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>&& __is, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) + { return std::getline(__is, __str, __delim); } + + /// Read a line from an rvalue stream into a string. + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>&& __is, + basic_string<_CharT, _Traits, _Alloc>& __str) + { return std::getline(__is, __str); } +#endif + + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + char __delim); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + wchar_t __delim); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + +#if _GLIBCXX_USE_C99_STDLIB + // 21.4 Numeric Conversions [string.conversions]. + inline int + stoi(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtol, "stoi", __str.c_str(), + __idx, __base); } + + inline long + stol(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(), + __idx, __base); } + + inline unsigned long + stoul(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(), + __idx, __base); } + + inline long long + stoll(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(), + __idx, __base); } + + inline unsigned long long + stoull(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(), + __idx, __base); } + + // NB: strtof vs strtod. + inline float + stof(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); } + + inline double + stod(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } + + inline long double + stold(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); } +#endif // _GLIBCXX_USE_C99_STDLIB + + // DR 1261. Insufficent overloads for to_string / to_wstring + + inline string + to_string(int __val) +#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32 + noexcept // any 32-bit value fits in the SSO buffer +#endif + { + const bool __neg = __val < 0; + const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned __val) +#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32 + noexcept // any 32-bit value fits in the SSO buffer +#endif + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + + inline string + to_string(long __val) +#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32 + noexcept // any 32-bit value fits in the SSO buffer +#endif + { + const bool __neg = __val < 0; + const unsigned long __uval = __neg ? (unsigned long)~__val + 1ul : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned long __val) +#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32 + noexcept // any 32-bit value fits in the SSO buffer +#endif + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + + inline string + to_string(long long __val) + { + const bool __neg = __val < 0; + const unsigned long long __uval + = __neg ? (unsigned long long)~__val + 1ull : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned long long __val) + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + +#if _GLIBCXX_USE_C99_STDIO + // NB: (v)snprintf vs sprintf. + + inline string + to_string(float __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%f", __val); + } + + inline string + to_string(double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%f", __val); + } + + inline string + to_string(long double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%Lf", __val); + } +#endif // _GLIBCXX_USE_C99_STDIO + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR + inline int + stoi(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstol, "stoi", __str.c_str(), + __idx, __base); } + + inline long + stol(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(), + __idx, __base); } + + inline unsigned long + stoul(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(), + __idx, __base); } + + inline long long + stoll(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(), + __idx, __base); } + + inline unsigned long long + stoull(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(), + __idx, __base); } + + // NB: wcstof vs wcstod. + inline float + stof(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); } + + inline double + stod(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); } + + inline long double + stold(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); } + +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + // DR 1261. + inline wstring + to_wstring(int __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(int), + L"%d", __val); } + + inline wstring + to_wstring(unsigned __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned), + L"%u", __val); } + + inline wstring + to_wstring(long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(long), + L"%ld", __val); } + + inline wstring + to_wstring(unsigned long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned long), + L"%lu", __val); } + + inline wstring + to_wstring(long long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(long long), + L"%lld", __val); } + + inline wstring + to_wstring(unsigned long long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned long long), + L"%llu", __val); } + + inline wstring + to_wstring(float __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%f", __val); + } + + inline wstring + to_wstring(double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%f", __val); + } + + inline wstring + to_wstring(long double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%Lf", __val); + } +#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF +#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* C++11 */ + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // DR 1182. + +#ifndef _GLIBCXX_COMPATIBILITY_CXX0X + /// std::hash specialization for string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), __s.length()); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + + /// std::hash specialization for wstring. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const wstring& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(wchar_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; +#endif /* _GLIBCXX_COMPATIBILITY_CXX0X */ + +#ifdef _GLIBCXX_USE_CHAR8_T + /// std::hash specialization for u8string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u8string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char8_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; +#endif + + /// std::hash specialization for u16string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u16string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char16_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + + /// std::hash specialization for u32string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u32string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char32_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + +#if __cplusplus >= 201402L + +#define __cpp_lib_string_udls 201304L + + inline namespace literals + { + inline namespace string_literals + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + +#if __cpp_lib_constexpr_string >= 201907L +# define _GLIBCXX_STRING_CONSTEXPR constexpr +#else +# define _GLIBCXX_STRING_CONSTEXPR +#endif + + _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR + inline basic_string + operator""s(const char* __str, size_t __len) + { return basic_string{__str, __len}; } + + _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR + inline basic_string + operator""s(const wchar_t* __str, size_t __len) + { return basic_string{__str, __len}; } + +#ifdef _GLIBCXX_USE_CHAR8_T + _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR + inline basic_string + operator""s(const char8_t* __str, size_t __len) + { return basic_string{__str, __len}; } +#endif + + _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR + inline basic_string + operator""s(const char16_t* __str, size_t __len) + { return basic_string{__str, __len}; } + + _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR + inline basic_string + operator""s(const char32_t* __str, size_t __len) + { return basic_string{__str, __len}; } + +#undef _GLIBCXX_STRING_CONSTEXPR +#pragma GCC diagnostic pop + } // inline namespace string_literals + } // inline namespace literals + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // basic_string into a variant, but only if moving the string cannot throw. + template + struct _Never_valueless_alt> + : __and_< + is_nothrow_move_constructible>, + is_nothrow_move_assignable> + >::type + { }; + } // namespace __detail::__variant +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif /* _BASIC_STRING_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a0f93f8ac66162ab6f4bc43d14974dcebb1d1588 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc new file mode 100644 index 0000000000000000000000000000000000000000..0696b96604c168111ae16aa66e245d83d7578c87 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc @@ -0,0 +1,1129 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_string.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers to ISO-14882. +// Non-reference-counted implementation written by Paolo Carlini and +// updated by Jonathan Wakely for ISO-14882-2011. + +#ifndef _BASIC_STRING_TCC +#define _BASIC_STRING_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_CXX11_ABI + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::npos; + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) _GLIBCXX_NOEXCEPT + { + if (this == std::__addressof(__s)) + return; + + _Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator()); + + if (_M_is_local()) + if (__s._M_is_local()) + { + if (length() && __s.length()) + { + _CharT __tmp_data[_S_local_capacity + 1]; + traits_type::copy(__tmp_data, __s._M_local_buf, + __s.length() + 1); + traits_type::copy(__s._M_local_buf, _M_local_buf, + length() + 1); + traits_type::copy(_M_local_buf, __tmp_data, + __s.length() + 1); + } + else if (__s.length()) + { + traits_type::copy(_M_local_buf, __s._M_local_buf, + __s.length() + 1); + _M_length(__s.length()); + __s._M_set_length(0); + return; + } + else if (length()) + { + traits_type::copy(__s._M_local_buf, _M_local_buf, + length() + 1); + __s._M_length(length()); + _M_set_length(0); + return; + } + } + else + { + const size_type __tmp_capacity = __s._M_allocated_capacity; + traits_type::copy(__s._M_local_buf, _M_local_buf, + length() + 1); + _M_data(__s._M_data()); + __s._M_data(__s._M_local_buf); + _M_capacity(__tmp_capacity); + } + else + { + const size_type __tmp_capacity = _M_allocated_capacity; + if (__s._M_is_local()) + { + traits_type::copy(_M_local_buf, __s._M_local_buf, + __s.length() + 1); + __s._M_data(_M_data()); + _M_data(_M_local_buf); + } + else + { + pointer __tmp_ptr = _M_data(); + _M_data(__s._M_data()); + __s._M_data(__tmp_ptr); + _M_capacity(__s._M_allocated_capacity); + } + __s._M_capacity(__tmp_capacity); + } + + const size_type __tmp_length = length(); + _M_length(__s.length()); + __s._M_length(__tmp_length); + } + + template + _GLIBCXX20_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::pointer + basic_string<_CharT, _Traits, _Alloc>:: + _M_create(size_type& __capacity, size_type __old_capacity) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 83. String::npos vs. string::max_size() + if (__capacity > max_size()) + std::__throw_length_error(__N("basic_string::_M_create")); + + // The below implements an exponential growth policy, necessary to + // meet amortized linear time requirements of the library: see + // http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html. + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) + { + __capacity = 2 * __old_capacity; + // Never allocate a string bigger than max_size. + if (__capacity > max_size()) + __capacity = max_size(); + } + + // NB: Need an array of char_type[__capacity], plus a terminating + // null char_type() element. + return _Alloc_traits::allocate(_M_get_allocator(), __capacity + 1); + } + + // NB: This is the special case for Input Iterators, used in + // istreambuf_iterators, etc. + // Input Iterators have a cost structure very different from + // pointers, calling for a different coding style. + template + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(_InIterator __beg, _InIterator __end, + std::input_iterator_tag) + { + size_type __len = 0; + size_type __capacity = size_type(_S_local_capacity); + + pointer __p = _M_use_local_data(); + + while (__beg != __end && __len < __capacity) + { + __p[__len++] = *__beg; + ++__beg; + } + + struct _Guard + { + _GLIBCXX20_CONSTEXPR + explicit _Guard(basic_string* __s) : _M_guarded(__s) { } + + _GLIBCXX20_CONSTEXPR + ~_Guard() { if (_M_guarded) _M_guarded->_M_dispose(); } + + basic_string* _M_guarded; + } __guard(this); + + while (__beg != __end) + { + if (__len == __capacity) + { + // Allocate more space. + __capacity = __len + 1; + pointer __another = _M_create(__capacity, __len); + this->_S_copy(__another, _M_data(), __len); + _M_dispose(); + _M_data(__another); + _M_capacity(__capacity); + } + traits_type::assign(_M_data()[__len++], *__beg); + ++__beg; + } + + __guard._M_guarded = 0; + + _M_set_length(__len); + } + + template + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(_InIterator __beg, _InIterator __end, + std::forward_iterator_tag) + { + size_type __dnew = static_cast(std::distance(__beg, __end)); + + if (__dnew > size_type(_S_local_capacity)) + { + _M_data(_M_create(__dnew, size_type(0))); + _M_capacity(__dnew); + } + else + _M_use_local_data(); + + // Check for out_of_range and length_error exceptions. + struct _Guard + { + _GLIBCXX20_CONSTEXPR + explicit _Guard(basic_string* __s) : _M_guarded(__s) { } + + _GLIBCXX20_CONSTEXPR + ~_Guard() { if (_M_guarded) _M_guarded->_M_dispose(); } + + basic_string* _M_guarded; + } __guard(this); + + this->_S_copy_chars(_M_data(), __beg, __end); + + __guard._M_guarded = 0; + + _M_set_length(__dnew); + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(size_type __n, _CharT __c) + { + if (__n > size_type(_S_local_capacity)) + { + _M_data(_M_create(__n, size_type(0))); + _M_capacity(__n); + } + else + _M_use_local_data(); + + if (__n) + this->_S_assign(_M_data(), __n, __c); + + _M_set_length(__n); + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_assign(const basic_string& __str) + { + if (this != std::__addressof(__str)) + { + const size_type __rsize = __str.length(); + const size_type __capacity = capacity(); + + if (__rsize > __capacity) + { + size_type __new_capacity = __rsize; + pointer __tmp = _M_create(__new_capacity, __capacity); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__new_capacity); + } + + if (__rsize) + this->_S_copy(_M_data(), __str._M_data(), __rsize); + + _M_set_length(__rsize); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) + { + const size_type __capacity = capacity(); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2968. Inconsistencies between basic_string reserve and + // vector/unordered_map/unordered_set reserve functions + // P0966 reserve should not shrink + if (__res <= __capacity) + return; + + pointer __tmp = _M_create(__res, __capacity); + this->_S_copy(__tmp, _M_data(), length() + 1); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__res); + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, + size_type __len2) + { + const size_type __how_much = length() - __pos - __len1; + + size_type __new_capacity = length() + __len2 - __len1; + pointer __r = _M_create(__new_capacity, capacity()); + + if (__pos) + this->_S_copy(__r, _M_data(), __pos); + if (__s && __len2) + this->_S_copy(__r + __pos, __s, __len2); + if (__how_much) + this->_S_copy(__r + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + + _M_dispose(); + _M_data(__r); + _M_capacity(__new_capacity); + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_erase(size_type __pos, size_type __n) + { + const size_type __how_much = length() - __pos - __n; + + if (__how_much && __n) + this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much); + + _M_set_length(length() - __n); + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve() + { + if (_M_is_local()) + return; + + const size_type __length = length(); + const size_type __capacity = _M_allocated_capacity; + + if (__length <= size_type(_S_local_capacity)) + { + this->_S_copy(_M_use_local_data(), _M_data(), __length + 1); + _M_destroy(__capacity); + _M_data(_M_local_data()); + } +#if __cpp_exceptions + else if (__length < __capacity) + try + { + pointer __tmp + = _Alloc_traits::allocate(_M_get_allocator(), __length + 1); + this->_S_copy(__tmp, _M_data(), __length + 1); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__length); + } + catch (const __cxxabiv1::__forced_unwind&) + { throw; } + catch (...) + { /* swallow the exception */ } +#endif + } + + template + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + resize(size_type __n, _CharT __c) + { + const size_type __size = this->size(); + if (__size < __n) + this->append(__n - __size, __c); + else if (__n < __size) + this->_M_set_length(__n); + } + + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_append(const _CharT* __s, size_type __n) + { + const size_type __len = __n + this->size(); + + if (__len <= this->capacity()) + { + if (__n) + this->_S_copy(this->_M_data() + this->size(), __s, __n); + } + else + this->_M_mutate(this->size(), size_type(0), __s, __n); + + this->_M_set_length(__len); + return *this; + } + + template + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + std::__false_type) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2788. unintentionally require a default constructible allocator + const basic_string __s(__k1, __k2, this->get_allocator()); + const size_type __n1 = __i2 - __i1; + return _M_replace(__i1 - begin(), __n1, __s._M_data(), + __s.size()); + } + + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c) + { + _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); + + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __n2 - __n1; + + if (__new_size <= this->capacity()) + { + pointer __p = this->_M_data() + __pos1; + + const size_type __how_much = __old_size - __pos1 - __n1; + if (__how_much && __n1 != __n2) + this->_S_move(__p + __n2, __p + __n1, __how_much); + } + else + this->_M_mutate(__pos1, __n1, 0, __n2); + + if (__n2) + this->_S_assign(this->_M_data() + __pos1, __n2, __c); + + this->_M_set_length(__new_size); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace(size_type __pos, size_type __len1, const _CharT* __s, + const size_type __len2) + { + _M_check_length(__len1, __len2, "basic_string::_M_replace"); + + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __len2 - __len1; + + if (__new_size <= this->capacity()) + { + pointer __p = this->_M_data() + __pos; + + const size_type __how_much = __old_size - __pos - __len1; +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + auto __newp = _Alloc_traits::allocate(_M_get_allocator(), + __new_size); + _S_copy(__newp, this->_M_data(), __pos); + _S_copy(__newp + __pos, __s, __len2); + _S_copy(__newp + __pos + __len2, __p + __len1, __how_much); + _S_copy(this->_M_data(), __newp, __new_size); + this->_M_get_allocator().deallocate(__newp, __new_size); + } + else +#endif + if (_M_disjunct(__s)) + { + if (__how_much && __len1 != __len2) + this->_S_move(__p + __len2, __p + __len1, __how_much); + if (__len2) + this->_S_copy(__p, __s, __len2); + } + else + { + // Work in-place. + if (__len2 && __len2 <= __len1) + this->_S_move(__p, __s, __len2); + if (__how_much && __len1 != __len2) + this->_S_move(__p + __len2, __p + __len1, __how_much); + if (__len2 > __len1) + { + if (__s + __len2 <= __p + __len1) + this->_S_move(__p, __s, __len2); + else if (__s >= __p + __len1) + { + // Hint to middle end that __p and __s overlap + // (PR 98465). + const size_type __poff = (__s - __p) + (__len2 - __len1); + this->_S_copy(__p, __p + __poff, __len2); + } + else + { + const size_type __nleft = (__p + __len1) - __s; + this->_S_move(__p, __s, __nleft); + this->_S_copy(__p + __nleft, __p + __len2, + __len2 - __nleft); + } + } + } + } + else + this->_M_mutate(__pos, __len1, __s, __len2); + + this->_M_set_length(__new_size); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + copy(_CharT* __s, size_type __n, size_type __pos) const + { + _M_check(__pos, "basic_string::copy"); + __n = _M_limit(__pos, __n); + __glibcxx_requires_string_len(__s, __n); + if (__n) + _S_copy(__s, _M_data() + __pos, __n); + // 21.3.5.7 par 3: do not append null. (good.) + return __n; + } + +#if __cplusplus > 202002L + template + template + constexpr void + basic_string<_CharT, _Traits, _Alloc>:: + resize_and_overwrite(size_type __n, _Operation __op) + { + const size_type __capacity = capacity(); + _CharT* __p; + if (__n > __capacity) + { + __p = _M_create(__n, __capacity); + this->_S_copy(__p, _M_data(), length()); // exclude trailing null +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + traits_type::assign(__p + length(), __n - length(), _CharT()); +#endif + _M_dispose(); + _M_data(__p); + _M_capacity(__n); + } + else + __p = _M_data(); + struct _Terminator { + constexpr ~_Terminator() { _M_this->_M_set_length(_M_r); } + basic_string* _M_this; + size_type _M_r; + }; + _Terminator __term{this}; + const size_type __n2 [[maybe_unused]] = __n; + __term._M_r = std::move(__op)(__p, __n); + _GLIBCXX_DEBUG_ASSERT(__term._M_r >= 0 && __term._M_r <= __n2); + } +#endif // C++23 + +#endif // _GLIBCXX_USE_CXX11_ABI + +#if __cpp_lib_constexpr_string >= 201907L +# define _GLIBCXX_STRING_CONSTEXPR constexpr +#else +# define _GLIBCXX_STRING_CONSTEXPR +#endif + + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc> + operator+(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + __glibcxx_requires_string(__lhs); + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + const __size_type __len = _Traits::length(__lhs); + __string_type __str(_Alloc_traits::_S_select_on_copy( + __rhs.get_allocator())); + __str.reserve(__len + __rhs.size()); + __str.append(__lhs, __len); + __str.append(__rhs); + return __str; + } + + template + _GLIBCXX20_CONSTEXPR + basic_string<_CharT, _Traits, _Alloc> + operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + __string_type __str(_Alloc_traits::_S_select_on_copy( + __rhs.get_allocator())); + const __size_type __len = __rhs.size(); + __str.reserve(__len + 1); + __str.append(__size_type(1), __lhs); + __str.append(__rhs); + return __str; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + const size_type __size = this->size(); + + if (__n == 0) + return __pos <= __size ? __pos : npos; + if (__pos >= __size) + return npos; + + const _CharT __elem0 = __s[0]; + const _CharT* const __data = data(); + const _CharT* __first = __data + __pos; + const _CharT* const __last = __data + __size; + size_type __len = __size - __pos; + + while (__len >= __n) + { + // Find the first occurrence of __elem0: + __first = traits_type::find(__first, __len - __n + 1, __elem0); + if (!__first) + return npos; + // Compare the full strings from the first occurrence of __elem0. + // We already know that __first[0] == __s[0] but compare them again + // anyway because __s is probably aligned, which helps memcmp. + if (traits_type::compare(__first, __s, __n) == 0) + return __first - __data; + __len = __last - ++__first; + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __ret = npos; + const size_type __size = this->size(); + if (__pos < __size) + { + const _CharT* __data = _M_data(); + const size_type __n = __size - __pos; + const _CharT* __p = traits_type::find(__data + __pos, __n, __c); + if (__p) + __ret = __p - __data; + } + return __ret; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + rfind(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + const size_type __size = this->size(); + if (__n <= __size) + { + __pos = std::min(size_type(__size - __n), __pos); + const _CharT* __data = _M_data(); + do + { + if (traits_type::compare(__data + __pos, __s, __n) == 0) + return __pos; + } + while (__pos-- > 0); + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + for (++__size; __size-- > 0; ) + if (traits_type::eq(_M_data()[__size], __c)) + return __size; + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + 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 + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + for (; __n && __pos < this->size(); ++__pos) + { + const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]); + if (__p) + return __pos; + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + 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 + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + size_type __size = this->size(); + if (__size && __n) + { + if (--__size > __pos) + __size = __pos; + do + { + if (traits_type::find(__s, __n, _M_data()[__size])) + return __size; + } + while (__size-- != 0); + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + 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 + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + for (; __pos < this->size(); ++__pos) + if (!traits_type::find(__s, __n, _M_data()[__pos])) + return __pos; + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + for (; __pos < this->size(); ++__pos) + if (!traits_type::eq(_M_data()[__pos], __c)) + return __pos; + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + 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 + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::find(__s, __n, _M_data()[__size])) + return __size; + } + while (__size--); + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::eq(_M_data()[__size], __c)) + return __size; + } + while (__size--); + } + return npos; + } + + template + _GLIBCXX_STRING_CONSTEXPR + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n, const basic_string& __str) const + { + _M_check(__pos, "basic_string::compare"); + __n = _M_limit(__pos, __n); + const size_type __osize = __str.size(); + const size_type __len = std::min(__n, __osize); + int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len); + if (!__r) + __r = _S_compare(__n, __osize); + return __r; + } + + template + _GLIBCXX_STRING_CONSTEXPR + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2) const + { + _M_check(__pos1, "basic_string::compare"); + __str._M_check(__pos2, "basic_string::compare"); + __n1 = _M_limit(__pos1, __n1); + __n2 = __str._M_limit(__pos2, __n2); + const size_type __len = std::min(__n1, __n2); + int __r = traits_type::compare(_M_data() + __pos1, + __str.data() + __pos2, __len); + if (!__r) + __r = _S_compare(__n1, __n2); + return __r; + } + + template + _GLIBCXX_STRING_CONSTEXPR + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + const size_type __size = this->size(); + const size_type __osize = traits_type::length(__s); + const size_type __len = std::min(__size, __osize); + int __r = traits_type::compare(_M_data(), __s, __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + + template + _GLIBCXX_STRING_CONSTEXPR + int + basic_string <_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n1, const _CharT* __s) const + { + __glibcxx_requires_string(__s); + _M_check(__pos, "basic_string::compare"); + __n1 = _M_limit(__pos, __n1); + const size_type __osize = traits_type::length(__s); + const size_type __len = std::min(__n1, __osize); + int __r = traits_type::compare(_M_data() + __pos, __s, __len); + if (!__r) + __r = _S_compare(__n1, __osize); + return __r; + } + + template + _GLIBCXX_STRING_CONSTEXPR + int + basic_string <_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const + { + __glibcxx_requires_string_len(__s, __n2); + _M_check(__pos, "basic_string::compare"); + __n1 = _M_limit(__pos, __n1); + const size_type __len = std::min(__n1, __n2); + int __r = traits_type::compare(_M_data() + __pos, __s, __len); + if (!__r) + __r = _S_compare(__n1, __n2); + return __r; + } + +#undef _GLIBCXX_STRING_CONSTEXPR + + // 21.3.7.9 basic_string::getline and operators + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, + basic_string<_CharT, _Traits, _Alloc>& __str) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __istream_type::ios_base __ios_base; + typedef typename __istream_type::int_type __int_type; + typedef typename __string_type::size_type __size_type; + typedef ctype<_CharT> __ctype_type; + typedef typename __ctype_type::ctype_base __ctype_base; + + __size_type __extracted = 0; + typename __ios_base::iostate __err = __ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + __try + { + // Avoid reallocation for common case. + __str.erase(); + _CharT __buf[128]; + __size_type __len = 0; + const streamsize __w = __in.width(); + const __size_type __n = __w > 0 ? static_cast<__size_type>(__w) + : __str.max_size(); + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); + __int_type __c = __in.rdbuf()->sgetc(); + + while (__extracted < __n + && !_Traits::eq_int_type(__c, __eof) + && !__ct.is(__ctype_base::space, + _Traits::to_char_type(__c))) + { + if (__len == sizeof(__buf) / sizeof(_CharT)) + { + __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); + __len = 0; + } + __buf[__len++] = _Traits::to_char_type(__c); + ++__extracted; + __c = __in.rdbuf()->snextc(); + } + __str.append(__buf, __len); + + if (__extracted < __n && _Traits::eq_int_type(__c, __eof)) + __err |= __ios_base::eofbit; + __in.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 91. Description of operator>> and getline() for string<> + // might cause endless loop + __in._M_setstate(__ios_base::badbit); + } + } + // 211. operator>>(istream&, string&) doesn't set failbit + if (!__extracted) + __err |= __ios_base::failbit; + if (__err) + __in.setstate(__err); + return __in; + } + + template + basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __in, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __istream_type::ios_base __ios_base; + typedef typename __istream_type::int_type __int_type; + typedef typename __string_type::size_type __size_type; + + __size_type __extracted = 0; + const __size_type __n = __str.max_size(); + typename __ios_base::iostate __err = __ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, true); + if (__cerb) + { + __try + { + __str.erase(); + const __int_type __idelim = _Traits::to_int_type(__delim); + const __int_type __eof = _Traits::eof(); + __int_type __c = __in.rdbuf()->sgetc(); + + while (__extracted < __n + && !_Traits::eq_int_type(__c, __eof) + && !_Traits::eq_int_type(__c, __idelim)) + { + __str += _Traits::to_char_type(__c); + ++__extracted; + __c = __in.rdbuf()->snextc(); + } + + if (_Traits::eq_int_type(__c, __eof)) + __err |= __ios_base::eofbit; + else if (_Traits::eq_int_type(__c, __idelim)) + { + ++__extracted; + __in.rdbuf()->sbumpc(); + } + else + __err |= __ios_base::failbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 91. Description of operator>> and getline() for string<> + // might cause endless loop + __in._M_setstate(__ios_base::badbit); + } + } + if (!__extracted) + __err |= __ios_base::failbit; + if (__err) + __in.setstate(__err); + return __in; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + // The explicit instantiation definitions in src/c++11/string-inst.cc and + // src/c++17/string-inst.cc only instantiate the members required for C++17 + // and earlier standards (so not C++20's starts_with and ends_with). + // Suppress the explicit instantiation declarations for C++20, so C++20 + // code will implicitly instantiate std::string and std::wstring as needed. +# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0 + extern template class basic_string; +# elif ! _GLIBCXX_USE_CXX11_ABI + // Still need to prevent implicit instantiation of the COW empty rep, + // to ensure the definition in libstdc++.so is unique (PR 86138). + extern template basic_string::size_type + basic_string::_Rep::_S_empty_rep_storage[]; +# endif + + extern template + basic_istream& + operator>>(basic_istream&, string&); + extern template + basic_ostream& + operator<<(basic_ostream&, const string&); + extern template + basic_istream& + getline(basic_istream&, string&, char); + extern template + basic_istream& + getline(basic_istream&, string&); + +#ifdef _GLIBCXX_USE_WCHAR_T +# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0 + extern template class basic_string; +# elif ! _GLIBCXX_USE_CXX11_ABI + extern template basic_string::size_type + basic_string::_Rep::_S_empty_rep_storage[]; +# endif + + extern template + basic_istream& + operator>>(basic_istream&, wstring&); + extern template + basic_ostream& + operator<<(basic_ostream&, const wstring&); + extern template + basic_istream& + getline(basic_istream&, wstring&, wchar_t); + extern template + basic_istream& + getline(basic_istream&, wstring&); +#endif // _GLIBCXX_USE_WCHAR_T +#endif // _GLIBCXX_EXTERN_TEMPLATE + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..d64eabbc94c0f44d9ad747f8495fe7086dcbff3e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@basic_string.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..cac1326d4b58e9766998575c254ef9d14157a6c5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h @@ -0,0 +1,1005 @@ +// Character Traits for use by standard string and iostream -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/char_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _CHAR_TRAITS_H +#define _CHAR_TRAITS_H 1 + +#pragma GCC system_header + +#include // For streampos +#include // For WEOF, wmemmove, wmemset, etc. +#if __cplusplus >= 201103L +# include +#endif +#if __cplusplus >= 202002L +# include +# include +#endif + +#ifndef _GLIBCXX_ALWAYS_INLINE +# define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Wstringop-overread" +#pragma GCC diagnostic ignored "-Warray-bounds" + + /** + * @brief Mapping from character type to associated types. + * + * @note This is an implementation class for the generic version + * of char_traits. It defines int_type, off_type, pos_type, and + * state_type. By default these are unsigned long, streamoff, + * streampos, and mbstate_t. Users who need a different set of + * types, but who don't need to change the definitions of any function + * defined in char_traits, can specialize __gnu_cxx::_Char_types + * while leaving __gnu_cxx::char_traits alone. */ + template + struct _Char_types + { + typedef unsigned long int_type; + typedef std::streampos pos_type; + typedef std::streamoff off_type; + typedef std::mbstate_t state_type; + }; + + + /** + * @brief Base class used to implement std::char_traits. + * + * @note For any given actual character type, this definition is + * probably wrong. (Most of the member functions are likely to be + * right, but the int_type and state_type typedefs, and the eof() + * member function, are likely to be wrong.) The reason this class + * exists is so users can specialize it. Classes in namespace std + * may not be specialized for fundamental types, but classes in + * namespace __gnu_cxx may be. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types + * for advice on how to make use of this class for @a unusual character + * types. Also, check out include/ext/pod_char_traits.h. + */ + template + struct char_traits + { + typedef _CharT char_type; + typedef typename _Char_types<_CharT>::int_type int_type; + typedef typename _Char_types<_CharT>::pos_type pos_type; + typedef typename _Char_types<_CharT>::off_type off_type; + typedef typename _Char_types<_CharT>::state_type state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = std::strong_ordering; +#endif + + static _GLIBCXX14_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static _GLIBCXX14_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX14_CONSTEXPR std::size_t + length(const char_type* __s); + + static _GLIBCXX14_CONSTEXPR const char_type* + find(const char_type* __s, std::size_t __n, const char_type& __a); + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, std::size_t __n, char_type __a); + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) + { return static_cast(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) + { return static_cast(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() + { return static_cast(_GLIBCXX_STDIO_EOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) + { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); } + }; + + template + _GLIBCXX14_CONSTEXPR int + char_traits<_CharT>:: + compare(const char_type* __s1, const char_type* __s2, std::size_t __n) + { + for (std::size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + template + _GLIBCXX14_CONSTEXPR std::size_t + char_traits<_CharT>:: + length(const char_type* __p) + { + std::size_t __i = 0; + while (!eq(__p[__i], char_type())) + ++__i; + return __i; + } + + template + _GLIBCXX14_CONSTEXPR const typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + find(const char_type* __s, std::size_t __n, const char_type& __a) + { + for (std::size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + move(char_type* __s1, const char_type* __s2, std::size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + { + if (__s1 == __s2) // unlikely, but saves a lot of work + return __s1; +#if __cpp_constexpr_dynamic_alloc + // The overlap detection below fails due to PR c++/89074, + // so use a temporary buffer instead. + char_type* __tmp = new char_type[__n]; + copy(__tmp, __s2, __n); + copy(__s1, __tmp, __n); + delete[] __tmp; +#else + const auto __end = __s2 + __n - 1; + bool __overlap = false; + for (std::size_t __i = 0; __i < __n - 1; ++__i) + { + if (__s1 + __i == __end) + { + __overlap = true; + break; + } + } + if (__overlap) + { + do + { + --__n; + assign(__s1[__n], __s2[__n]); + } + while (__n > 0); + } + else + copy(__s1, __s2, __n); +#endif + return __s1; + } +#endif + __builtin_memmove(__s1, __s2, __n * sizeof(char_type)); + return __s1; + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + copy(char_type* __s1, const char_type* __s2, std::size_t __n) + { +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + { + for (std::size_t __i = 0; __i < __n; ++__i) + std::construct_at(__s1 + __i, __s2[__i]); + return __s1; + } +#endif + + __builtin_memcpy(__s1, __s2, __n * sizeof(char_type)); + return __s1; + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + assign(char_type* __s, std::size_t __n, char_type __a) + { +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + { + for (std::size_t __i = 0; __i < __n; ++__i) + std::construct_at(__s + __i, __a); + return __s; + } +#endif + + if _GLIBCXX17_CONSTEXPR (sizeof(_CharT) == 1 && __is_trivial(_CharT)) + { + unsigned char __c; + __builtin_memcpy(&__c, __builtin_addressof(__a), 1); + __builtin_memset(__s, __c, __n); + } + else + { + for (std::size_t __i = 0; __i < __n; ++__i) + __s[__i] = __a; + } + return __s; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __cpp_lib_is_constant_evaluated +// Unofficial macro indicating P1032R1 support in C++20 +# define __cpp_lib_constexpr_char_traits 201811L +#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED +// Unofficial macro indicating P0426R1 support in C++17 +# define __cpp_lib_constexpr_char_traits 201611L +#endif + + // 21.1 + /** + * @brief Basis for explicit traits specializations. + * + * @note For any given actual character type, this definition is + * probably wrong. Since this is just a thin wrapper around + * __gnu_cxx::char_traits, it is possible to achieve a more + * appropriate definition by specializing __gnu_cxx::char_traits. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types + * for advice on how to make use of this class for @a unusual character + * types. Also, check out include/ext/pod_char_traits.h. + */ + template + struct char_traits : public __gnu_cxx::char_traits<_CharT> + { }; + + + /// 21.1.3.1 char_traits specializations + template<> + struct char_traits + { + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { + // LWG 467. + return (static_cast(__c1) + < static_cast(__c2)); + } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } +#endif + return __builtin_memcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::length(__s); +#endif + return __builtin_strlen(__s); + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return static_cast(__builtin_memchr(__s, __a, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return static_cast(__builtin_memmove(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return static_cast(__builtin_memcpy(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return static_cast(__builtin_memset(__s, __a, __n)); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return static_cast(__c); } + + // To keep both the byte 0xff and the eof symbol 0xffffffff + // from ending up as 0xffffffff. + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return static_cast(static_cast(__c)); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(_GLIBCXX_STDIO_EOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return (__c == eof()) ? 0 : __c; } + }; + + +#ifdef _GLIBCXX_USE_WCHAR_T + /// 21.1.3.2 char_traits specializations + template<> + struct char_traits + { + typedef wchar_t char_type; + typedef wint_t int_type; + typedef streamoff off_type; + typedef wstreampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::compare(__s1, __s2, __n); +#endif + return wmemcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::length(__s); +#endif + return wcslen(__s); + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return wmemchr(__s, __a, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return wmemmove(__s1, __s2, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return wmemcpy(__s1, __s2, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return wmemset(__s, __a, __n); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return char_type(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return int_type(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(WEOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; +#else // _GLIBCXX_USE_WCHAR_T + template<> + struct char_traits : public __gnu_cxx::char_traits + { }; +#endif //_GLIBCXX_USE_WCHAR_T + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct char_traits + { + typedef char8_t char_type; + typedef unsigned int int_type; + typedef u8streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::compare(__s1, __s2, __n); +#endif + return __builtin_memcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::length(__s); +#endif + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return static_cast(__builtin_memchr(__s, __a, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return static_cast(__builtin_memmove(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return static_cast(__builtin_memcpy(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return static_cast(__builtin_memset(__s, __a, __n)); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return char_type(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return int_type(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(-1); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; +#endif //_GLIBCXX_USE_CHAR8_T + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<> + struct char_traits + { + typedef char16_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least16_t int_type; +#elif defined __UINT_LEAST16_TYPE__ + typedef __UINT_LEAST16_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif + typedef streamoff off_type; + typedef u16streampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) noexcept + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static constexpr bool + eq(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr bool + lt(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (size_t __i = 0; __i < __n; ++__i) + assign(__s[__i], __a); + return __s; + } + + static constexpr char_type + to_char_type(const int_type& __c) noexcept + { return char_type(__c); } + + static constexpr int_type + to_int_type(const char_type& __c) noexcept + { return __c == eof() ? int_type(0xfffd) : int_type(__c); } + + static constexpr bool + eq_int_type(const int_type& __c1, const int_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr int_type + eof() noexcept + { return static_cast(-1); } + + static constexpr int_type + not_eof(const int_type& __c) noexcept + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; + + template<> + struct char_traits + { + typedef char32_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least32_t int_type; +#elif defined __UINT_LEAST32_TYPE__ + typedef __UINT_LEAST32_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif + typedef streamoff off_type; + typedef u32streampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) noexcept + { +#if __cpp_constexpr_dynamic_alloc + if (std::__is_constant_evaluated()) + std::construct_at(__builtin_addressof(__c1), __c2); + else +#endif + __c1 = __c2; + } + + static constexpr bool + eq(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr bool + lt(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (size_t __i = 0; __i < __n; ++__i) + assign(__s[__i], __a); + return __s; + } + + static constexpr char_type + to_char_type(const int_type& __c) noexcept + { return char_type(__c); } + + static constexpr int_type + to_int_type(const char_type& __c) noexcept + { return int_type(__c); } + + static constexpr bool + eq_int_type(const int_type& __c1, const int_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr int_type + eof() noexcept + { return static_cast(-1); } + + static constexpr int_type + not_eof(const int_type& __c) noexcept + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; + +#if __cpp_lib_three_way_comparison + namespace __detail + { + template + constexpr auto + __char_traits_cmp_cat(int __cmp) noexcept + { + if constexpr (requires { typename _ChTraits::comparison_category; }) + { + using _Cat = typename _ChTraits::comparison_category; + static_assert( !is_void_v> ); + return static_cast<_Cat>(__cmp <=> 0); + } + else + return static_cast(__cmp <=> 0); + } + } // namespace __detail +#endif // C++20 + +#pragma GCC diagnostic pop + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _CHAR_TRAITS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f094ae7736de95b6d4aafacfdb62abbd397a52fd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@char_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h new file mode 100644 index 0000000000000000000000000000000000000000..4cae10a72f71764078d2608f655ce4bf91bec42c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h @@ -0,0 +1,106 @@ +// Numeric conversions (to_string, to_chars) -*- C++ -*- + +// Copyright (C) 2017-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/charconv.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{charconv} + */ + +#ifndef _GLIBCXX_CHARCONV_H +#define _GLIBCXX_CHARCONV_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace __detail +{ + // Generic implementation for arbitrary bases. + template + _GLIBCXX14_CONSTEXPR unsigned + __to_chars_len(_Tp __value, int __base = 10) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + unsigned __n = 1; + const unsigned __b2 = __base * __base; + const unsigned __b3 = __b2 * __base; + const unsigned long __b4 = __b3 * __base; + for (;;) + { + if (__value < (unsigned)__base) return __n; + if (__value < __b2) return __n + 1; + if (__value < __b3) return __n + 2; + if (__value < __b4) return __n + 3; + __value /= __b4; + __n += 4; + } + } + + // Write an unsigned integer value to the range [first,first+len). + // The caller is required to provide a buffer of exactly the right size + // (which can be determined by the __to_chars_len function). + template + void + __to_chars_10_impl(char* __first, unsigned __len, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + static constexpr char __digits[201] = + "0001020304050607080910111213141516171819" + "2021222324252627282930313233343536373839" + "4041424344454647484950515253545556575859" + "6061626364656667686970717273747576777879" + "8081828384858687888990919293949596979899"; + unsigned __pos = __len - 1; + while (__val >= 100) + { + auto const __num = (__val % 100) * 2; + __val /= 100; + __first[__pos] = __digits[__num + 1]; + __first[__pos - 1] = __digits[__num]; + __pos -= 2; + } + if (__val >= 10) + { + auto const __num = __val * 2; + __first[1] = __digits[__num + 1]; + __first[0] = __digits[__num]; + } + else + __first[0] = '0' + __val; + } + +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++11 +#endif // _GLIBCXX_CHARCONV_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8d06fbe7e3b0557ca6b36960fcc0ab9b686df8c4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@charconv.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h new file mode 100644 index 0000000000000000000000000000000000000000..421898516ae43b9cedac0f9b54014cf693fa3e1a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h @@ -0,0 +1,1392 @@ +// chrono::duration and chrono::time_point -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/chrono.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{chrono} + */ + +#ifndef _GLIBCXX_CHRONO_H +#define _GLIBCXX_CHRONO_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include +#include +#include +#include +#include // for literals support. +#if __cplusplus >= 202002L +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + namespace filesystem { struct __file_clock; }; +#endif + + namespace chrono + { + /// @addtogroup chrono + /// @{ + + /// `chrono::duration` represents a distance between two points in time + template> + struct duration; + + /// `chrono::time_point` represents a point in time as measured by a clock + template + struct time_point; + /// @} + } + + /// @addtogroup chrono + /// @{ + + // 20.11.4.3 specialization of common_type (for duration, sfinae-friendly) + + /// @cond undocumented + + template + struct __duration_common_type + { }; + + template + struct __duration_common_type<_CT, _Period1, _Period2, + __void_t> + { + private: + using __gcd_num = __static_gcd<_Period1::num, _Period2::num>; + using __gcd_den = __static_gcd<_Period1::den, _Period2::den>; + using __cr = typename _CT::type; + using __r = ratio<__gcd_num::value, + (_Period1::den / __gcd_den::value) * _Period2::den>; + + public: + using type = chrono::duration<__cr, typename __r::type>; + }; + + /// @endcond + + /// @{ + /// @relates chrono::duration + + /// Specialization of common_type for chrono::duration types. + template + struct common_type, + chrono::duration<_Rep2, _Period2>> + : __duration_common_type, + typename _Period1::type, + typename _Period2::type> + { }; + + /// Specialization of common_type for two identical chrono::duration types. + template + struct common_type, + chrono::duration<_Rep, _Period>> + { + using type = chrono::duration::type, + typename _Period::type>; + }; + + /// Specialization of common_type for one chrono::duration type. + template + struct common_type> + { + using type = chrono::duration::type, + typename _Period::type>; + }; + /// @} + + // 20.11.4.3 specialization of common_type (for time_point, sfinae-friendly) + + /// @cond undocumented + + template + struct __timepoint_common_type + { }; + + template + struct __timepoint_common_type<_CT, _Clock, __void_t> + { + using type = chrono::time_point<_Clock, typename _CT::type>; + }; + + /// @endcond + + /// @{ + /// @relates chrono::time_point + + /// Specialization of common_type for chrono::time_point types. + template + struct common_type, + chrono::time_point<_Clock, _Duration2>> + : __timepoint_common_type, _Clock> + { }; + + /// Specialization of common_type for two identical chrono::time_point types. + template + struct common_type, + chrono::time_point<_Clock, _Duration>> + { using type = chrono::time_point<_Clock, _Duration>; }; + + /// Specialization of common_type for one chrono::time_point type. + template + struct common_type> + { using type = chrono::time_point<_Clock, _Duration>; }; + /// @} + + /// @} group chrono + + namespace chrono + { + /// @addtogroup chrono + /// @{ + + /// @cond undocumented + + // Primary template for duration_cast impl. + template + struct __duration_cast_impl + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count()) + * static_cast<_CR>(_CF::num) + / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, true, true> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(__d.count())); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, true, false> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, false, true> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num))); + } + }; + + template + struct __is_duration + : std::false_type + { }; + + template + struct __is_duration> + : std::true_type + { }; + + template + using __enable_if_is_duration + = typename enable_if<__is_duration<_Tp>::value, _Tp>::type; + + template + using __disable_if_is_duration + = typename enable_if::value, _Tp>::type; + + /// @endcond + + /// duration_cast + template + constexpr __enable_if_is_duration<_ToDur> + duration_cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::period __to_period; + typedef typename _ToDur::rep __to_rep; + typedef ratio_divide<_Period, __to_period> __cf; + typedef typename common_type<__to_rep, _Rep, intmax_t>::type __cr; + typedef __duration_cast_impl<_ToDur, __cf, __cr, + __cf::num == 1, __cf::den == 1> __dc; + return __dc::__cast(__d); + } + + /// treat_as_floating_point + template + struct treat_as_floating_point + : is_floating_point<_Rep> + { }; + +#if __cplusplus > 201402L + template + inline constexpr bool treat_as_floating_point_v = + treat_as_floating_point<_Rep>::value; +#endif // C++17 + +#if __cplusplus > 201703L + template + struct is_clock; + + template + inline constexpr bool is_clock_v = is_clock<_Tp>::value; + +#if __cpp_lib_concepts + template + struct is_clock : false_type + { }; + + template + requires requires { + typename _Tp::rep; + typename _Tp::period; + typename _Tp::duration; + typename _Tp::time_point::clock; + typename _Tp::time_point::duration; + { &_Tp::is_steady } -> same_as; + { _Tp::now() } -> same_as; + requires same_as>; + requires same_as; + } + struct is_clock<_Tp> : true_type + { }; +#else + template + struct __is_clock_impl : false_type + { }; + + template + struct __is_clock_impl<_Tp, + void_t> + : __and_>, + is_same, + is_same, + is_same>::type + { }; + + template + struct is_clock : __is_clock_impl<_Tp>::type + { }; +#endif +#endif // C++20 + +#if __cplusplus >= 201703L +# define __cpp_lib_chrono 201611L + + template + constexpr __enable_if_is_duration<_ToDur> + floor(const duration<_Rep, _Period>& __d) + { + auto __to = chrono::duration_cast<_ToDur>(__d); + if (__to > __d) + return __to - _ToDur{1}; + return __to; + } + + template + constexpr __enable_if_is_duration<_ToDur> + ceil(const duration<_Rep, _Period>& __d) + { + auto __to = chrono::duration_cast<_ToDur>(__d); + if (__to < __d) + return __to + _ToDur{1}; + return __to; + } + + template + constexpr enable_if_t< + __and_<__is_duration<_ToDur>, + __not_>>::value, + _ToDur> + round(const duration<_Rep, _Period>& __d) + { + _ToDur __t0 = chrono::floor<_ToDur>(__d); + _ToDur __t1 = __t0 + _ToDur{1}; + auto __diff0 = __d - __t0; + auto __diff1 = __t1 - __d; + if (__diff0 == __diff1) + { + if (__t0.count() & 1) + return __t1; + return __t0; + } + else if (__diff0 < __diff1) + return __t0; + return __t1; + } + + template + constexpr + enable_if_t::is_signed, duration<_Rep, _Period>> + abs(duration<_Rep, _Period> __d) + { + if (__d >= __d.zero()) + return __d; + return -__d; + } + + // Make chrono::ceil also usable as chrono::__detail::ceil. + namespace __detail { using chrono::ceil; } + +#else // ! C++17 + + // We want to use ceil even when compiling for earlier standards versions. + // C++11 only allows a single statement in a constexpr function, so we + // need to move the comparison into a separate function, __ceil_impl. + namespace __detail + { + template + constexpr _Tp + __ceil_impl(const _Tp& __t, const _Up& __u) + { + return (__t < __u) ? (__t + _Tp{1}) : __t; + } + + // C++11-friendly version of std::chrono::ceil for internal use. + template + constexpr _ToDur + ceil(const duration<_Rep, _Period>& __d) + { + return __detail::__ceil_impl(chrono::duration_cast<_ToDur>(__d), __d); + } + } +#endif // C++17 + + /// duration_values + template + struct duration_values + { + static constexpr _Rep + zero() noexcept + { return _Rep(0); } + + static constexpr _Rep + max() noexcept + { return numeric_limits<_Rep>::max(); } + + static constexpr _Rep + min() noexcept + { return numeric_limits<_Rep>::lowest(); } + }; + + /// @cond undocumented + + template + struct __is_ratio + : std::false_type + { }; + + template + struct __is_ratio> + : std::true_type + { }; + + /// @endcond + + template + struct duration + { + private: + template + using __is_float = treat_as_floating_point<_Rep2>; + + static constexpr intmax_t + _S_gcd(intmax_t __m, intmax_t __n) noexcept + { + // Duration only allows positive periods so we don't need to + // handle negative values here (unlike __static_gcd and std::gcd). +#if __cplusplus >= 201402L + do + { + intmax_t __rem = __m % __n; + __m = __n; + __n = __rem; + } + while (__n != 0); + return __m; +#else + // C++11 doesn't allow loops in constexpr functions, but this + // recursive version can be more expensive to evaluate. + return (__n == 0) ? __m : _S_gcd(__n, __m % __n); +#endif + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2094. overflow shouldn't participate in overload resolution + // 3090. What is [2094] intended to mean? + // This only produces a valid type if no overflow occurs. + template + using __divide = ratio<(_R1::num / __gcd1) * (_R2::den / __gcd2), + (_R1::den / __gcd2) * (_R2::num / __gcd1)>; + + // _Period2 is an exact multiple of _Period + template + using __is_harmonic + = __bool_constant<__divide<_Period2, _Period>::den == 1>; + + public: + + using rep = _Rep; + using period = typename _Period::type; + + static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration"); + static_assert(__is_ratio<_Period>::value, + "period must be a specialization of ratio"); + static_assert(_Period::num > 0, "period must be positive"); + + // 20.11.5.1 construction / copy / destroy + constexpr duration() = default; + + duration(const duration&) = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3050. Conversion specification problem in chrono::duration + template, + __or_<__is_float, __not_<__is_float<_Rep2>>>>> + constexpr explicit duration(const _Rep2& __rep) + : __r(static_cast(__rep)) { } + + template, + __or_<__is_float, + __and_<__is_harmonic<_Period2>, + __not_<__is_float<_Rep2>>>>>> + constexpr duration(const duration<_Rep2, _Period2>& __d) + : __r(duration_cast(__d).count()) { } + + ~duration() = default; + duration& operator=(const duration&) = default; + + // 20.11.5.2 observer + constexpr rep + count() const + { return __r; } + + // 20.11.5.3 arithmetic + + constexpr duration::type, period> + operator+() const + { return duration::type, period>(__r); } + + constexpr duration::type, period> + operator-() const + { return duration::type, period>(-__r); } + + _GLIBCXX17_CONSTEXPR duration& + operator++() + { + ++__r; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration + operator++(int) + { return duration(__r++); } + + _GLIBCXX17_CONSTEXPR duration& + operator--() + { + --__r; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration + operator--(int) + { return duration(__r--); } + + _GLIBCXX17_CONSTEXPR duration& + operator+=(const duration& __d) + { + __r += __d.count(); + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator-=(const duration& __d) + { + __r -= __d.count(); + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator*=(const rep& __rhs) + { + __r *= __rhs; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator/=(const rep& __rhs) + { + __r /= __rhs; + return *this; + } + + // DR 934. + template + _GLIBCXX17_CONSTEXPR + typename enable_if::value, + duration&>::type + operator%=(const rep& __rhs) + { + __r %= __rhs; + return *this; + } + + template + _GLIBCXX17_CONSTEXPR + typename enable_if::value, + duration&>::type + operator%=(const duration& __d) + { + __r %= __d.count(); + return *this; + } + + // 20.11.5.4 special values + static constexpr duration + zero() noexcept + { return duration(duration_values::zero()); } + + static constexpr duration + min() noexcept + { return duration(duration_values::min()); } + + static constexpr duration + max() noexcept + { return duration(duration_values::max()); } + + private: + rep __r; + }; + + /// @{ + /// @relates std::chrono::duration + + /// The sum of two durations. + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator+(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() + __cd(__rhs).count()); + } + + /// The difference between two durations. + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator-(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() - __cd(__rhs).count()); + } + + /// @} + + /// @cond undocumented + + // SFINAE helper to obtain common_type<_Rep1, _Rep2> only if _Rep2 + // is implicitly convertible to it. + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3050. Conversion specification problem in chrono::duration constructor + template::type> + using __common_rep_t = typename + enable_if::value, _CRep>::type; + + /// @endcond + + /** @{ + * Arithmetic operators for chrono::duration + * @relates std::chrono::duration + */ + + template + constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period> + operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() * __s); + } + + template + constexpr duration<__common_rep_t<_Rep2, _Rep1>, _Period> + operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) + { return __d * __s; } + + template + constexpr + duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> + operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() / __s); + } + + template + constexpr typename common_type<_Rep1, _Rep2>::type + operator/(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__lhs).count() / __cd(__rhs).count(); + } + + // DR 934. + template + constexpr + duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> + operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() % __s); + } + + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator%(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() % __cd(__rhs).count()); + } + /// @} + + // comparisons + + /** @{ + * Comparisons for chrono::duration + * @relates std::chrono::duration + */ + + template + constexpr bool + operator==(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __ct; + return __ct(__lhs).count() == __ct(__rhs).count(); + } + + template + constexpr bool + operator<(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __ct; + return __ct(__lhs).count() < __ct(__rhs).count(); + } + +#if __cpp_lib_three_way_comparison + template + requires three_way_comparable> + constexpr auto + operator<=>(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + using __ct = common_type_t, + duration<_Rep2, _Period2>>; + return __ct(__lhs).count() <=> __ct(__rhs).count(); + } +#else + template + constexpr bool + operator!=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs == __rhs); } +#endif + + template + constexpr bool + operator<=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__rhs < __lhs); } + + template + constexpr bool + operator>(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return __rhs < __lhs; } + + template + constexpr bool + operator>=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs < __rhs); } + + /// @} + + /// @cond undocumented +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +# define _GLIBCXX_CHRONO_INT64_T int64_t +#elif defined __INT64_TYPE__ +# define _GLIBCXX_CHRONO_INT64_T __INT64_TYPE__ +#else + static_assert(std::numeric_limits::digits >= 64, + "Representation type for nanoseconds must have at least 64 bits"); +# define _GLIBCXX_CHRONO_INT64_T long long +#endif + /// @endcond + + /// nanoseconds + using nanoseconds = duration<_GLIBCXX_CHRONO_INT64_T, nano>; + + /// microseconds + using microseconds = duration<_GLIBCXX_CHRONO_INT64_T, micro>; + + /// milliseconds + using milliseconds = duration<_GLIBCXX_CHRONO_INT64_T, milli>; + + /// seconds + using seconds = duration<_GLIBCXX_CHRONO_INT64_T>; + + /// minutes + using minutes = duration<_GLIBCXX_CHRONO_INT64_T, ratio< 60>>; + + /// hours + using hours = duration<_GLIBCXX_CHRONO_INT64_T, ratio<3600>>; + +#if __cplusplus > 201703L + /// days + using days = duration<_GLIBCXX_CHRONO_INT64_T, ratio<86400>>; + + /// weeks + using weeks = duration<_GLIBCXX_CHRONO_INT64_T, ratio<604800>>; + + /// years + using years = duration<_GLIBCXX_CHRONO_INT64_T, ratio<31556952>>; + + /// months + using months = duration<_GLIBCXX_CHRONO_INT64_T, ratio<2629746>>; +#endif // C++20 + +#undef _GLIBCXX_CHRONO_INT64_T + + template + struct time_point + { + static_assert(__is_duration<_Dur>::value, + "duration must be a specialization of std::chrono::duration"); + + typedef _Clock clock; + typedef _Dur duration; + typedef typename duration::rep rep; + typedef typename duration::period period; + + constexpr time_point() : __d(duration::zero()) + { } + + constexpr explicit time_point(const duration& __dur) + : __d(__dur) + { } + + // conversions + template>> + constexpr time_point(const time_point& __t) + : __d(__t.time_since_epoch()) + { } + + // observer + constexpr duration + time_since_epoch() const + { return __d; } + +#if __cplusplus > 201703L + constexpr time_point& + operator++() + { + ++__d; + return *this; + } + + constexpr time_point + operator++(int) + { return time_point{__d++}; } + + constexpr time_point& + operator--() + { + --__d; + return *this; + } + + constexpr time_point + operator--(int) + { return time_point{__d--}; } +#endif + + // arithmetic + _GLIBCXX17_CONSTEXPR time_point& + operator+=(const duration& __dur) + { + __d += __dur; + return *this; + } + + _GLIBCXX17_CONSTEXPR time_point& + operator-=(const duration& __dur) + { + __d -= __dur; + return *this; + } + + // special values + static constexpr time_point + min() noexcept + { return time_point(duration::min()); } + + static constexpr time_point + max() noexcept + { return time_point(duration::max()); } + + private: + duration __d; + }; + + /// time_point_cast + template + constexpr typename enable_if<__is_duration<_ToDur>::value, + time_point<_Clock, _ToDur>>::type + time_point_cast(const time_point<_Clock, _Dur>& __t) + { + typedef time_point<_Clock, _ToDur> __time_point; + return __time_point(duration_cast<_ToDur>(__t.time_since_epoch())); + } + +#if __cplusplus > 201402L + template + constexpr + enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>> + floor(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::floor<_ToDur>(__tp.time_since_epoch())}; + } + + template + constexpr + enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>> + ceil(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::ceil<_ToDur>(__tp.time_since_epoch())}; + } + + template + constexpr enable_if_t< + __and_<__is_duration<_ToDur>, + __not_>>::value, + time_point<_Clock, _ToDur>> + round(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::round<_ToDur>(__tp.time_since_epoch())}; + } +#endif // C++17 + + /// @{ + /// @relates time_point + + /// Adjust a time point forwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> + operator+(const time_point<_Clock, _Dur1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<_Dur1,__dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__lhs.time_since_epoch() + __rhs); + } + + /// Adjust a time point forwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type, _Dur2>::type> + operator+(const duration<_Rep1, _Period1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef typename common_type<__dur1,_Dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__rhs.time_since_epoch() + __lhs); + } + + /// Adjust a time point backwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> + operator-(const time_point<_Clock, _Dur1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<_Dur1,__dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__lhs.time_since_epoch() -__rhs); + } + + /// The difference between two time points (as a duration) + template + constexpr typename common_type<_Dur1, _Dur2>::type + operator-(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } + /// @} + + /** @{ + * Comparisons for time_point + * @relates chrono::time_point + */ + + template + constexpr bool + operator==(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } + +#if __cpp_lib_three_way_comparison + template _Dur2> + constexpr auto + operator<=>(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() <=> __rhs.time_since_epoch(); } +#else + template + constexpr bool + operator!=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__lhs == __rhs); } +#endif + + template + constexpr bool + operator<(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } + + template + constexpr bool + operator<=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__rhs < __lhs); } + + template + constexpr bool + operator>(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __rhs < __lhs; } + + template + constexpr bool + operator>=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__lhs < __rhs); } + + /// @} + /// @} group chrono + + // Clocks. + + // Why nanosecond resolution as the default? + // Why have std::system_clock always count in the highest + // resolution (ie nanoseconds), even if on some OSes the low 3 + // or 9 decimal digits will be always zero? This allows later + // implementations to change the system_clock::now() + // implementation any time to provide better resolution without + // changing function signature or units. + + // To support the (forward) evolution of the library's defined + // clocks, wrap inside inline namespace so that the current + // defintions of system_clock, steady_clock, and + // high_resolution_clock types are uniquely mangled. This way, new + // code can use the latests clocks, while the library can contain + // compatibility definitions for previous versions. At some + // point, when these clocks settle down, the inlined namespaces + // can be removed. XXX GLIBCXX_ABI Deprecated + inline namespace _V2 { + + /** + * @brief System clock. + * + * Time returned represents wall time from the system-wide clock. + * @ingroup chrono + */ + struct system_clock + { + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point time_point; + + static_assert(system_clock::duration::min() + < system_clock::duration::zero(), + "a clock's minimum duration cannot be less than its epoch"); + + static constexpr bool is_steady = false; + + static time_point + now() noexcept; + + // Map to C API + static std::time_t + to_time_t(const time_point& __t) noexcept + { + return std::time_t(duration_cast + (__t.time_since_epoch()).count()); + } + + static time_point + from_time_t(std::time_t __t) noexcept + { + typedef chrono::time_point __from; + return time_point_cast + (__from(chrono::seconds(__t))); + } + }; + + + /** + * @brief Monotonic clock + * + * Time returned has the property of only increasing at a uniform rate. + * @ingroup chrono + */ + struct steady_clock + { + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point time_point; + + static constexpr bool is_steady = true; + + static time_point + now() noexcept; + }; + + + /** + * @brief Highest-resolution clock + * + * This is the clock "with the shortest tick period." Alias to + * std::system_clock until higher-than-nanosecond definitions + * become feasible. + * @ingroup chrono + */ + using high_resolution_clock = system_clock; + + } // end inline namespace _V2 + +#if __cplusplus >= 202002L + /// @addtogroup chrono + /// @{ + template + using sys_time = time_point; + using sys_seconds = sys_time; + using sys_days = sys_time; + + using file_clock = ::std::filesystem::__file_clock; + + template + using file_time = time_point; + + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + /// @} +#endif // C++20 + } // namespace chrono + +#if __cplusplus >= 201402L +#define __cpp_lib_chrono_udls 201304L + + inline namespace literals + { + /** ISO C++ 2014 namespace for suffixes for duration literals. + * + * These suffixes can be used to create `chrono::duration` values with + * tick periods of hours, minutes, seconds, milliseconds, microseconds + * or nanoseconds. For example, `std::chrono::seconds(5)` can be written + * as `5s` after making the suffix visible in the current scope. + * The suffixes can be made visible by a using-directive or + * using-declaration such as: + * - `using namespace std::chrono_literals;` + * - `using namespace std::literals;` + * - `using namespace std::chrono;` + * - `using namespace std;` + * - `using std::chrono_literals::operator""s;` + * + * The result of these suffixes on an integer literal is one of the + * standard typedefs such as `std::chrono::hours`. + * The result on a floating-point literal is a duration type with the + * specified tick period and an unspecified floating-point representation, + * for example `1.5e2ms` might be equivalent to + * `chrono::duration(1.5e2)`. + * + * @since C+14 + * @ingroup chrono + */ + inline namespace chrono_literals + { + /// @addtogroup chrono + /// @{ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + /// @cond undocumented + template + constexpr _Dur __check_overflow() + { + using _Val = __parse_int::_Parse_int<_Digits...>; + constexpr typename _Dur::rep __repval = _Val::value; + static_assert(__repval >= 0 && __repval == _Val::value, + "literal value cannot be represented by duration type"); + return _Dur(__repval); + } + /// @endcond + + /// Literal suffix for durations representing non-integer hours + constexpr chrono::duration> + operator""h(long double __hours) + { return chrono::duration>{__hours}; } + + /// Literal suffix for durations of type `std::chrono::hours` + template + constexpr chrono::hours + operator""h() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer minutes + constexpr chrono::duration> + operator""min(long double __mins) + { return chrono::duration>{__mins}; } + + /// Literal suffix for durations of type `std::chrono::minutes` + template + constexpr chrono::minutes + operator""min() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer seconds + constexpr chrono::duration + operator""s(long double __secs) + { return chrono::duration{__secs}; } + + /// Literal suffix for durations of type `std::chrono::seconds` + template + constexpr chrono::seconds + operator""s() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer milliseconds + constexpr chrono::duration + operator""ms(long double __msecs) + { return chrono::duration{__msecs}; } + + /// Literal suffix for durations of type `std::chrono::milliseconds` + template + constexpr chrono::milliseconds + operator""ms() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer microseconds + constexpr chrono::duration + operator""us(long double __usecs) + { return chrono::duration{__usecs}; } + + /// Literal suffix for durations of type `std::chrono::microseconds` + template + constexpr chrono::microseconds + operator""us() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer nanoseconds + constexpr chrono::duration + operator""ns(long double __nsecs) + { return chrono::duration{__nsecs}; } + + /// Literal suffix for durations of type `std::chrono::nanoseconds` + template + constexpr chrono::nanoseconds + operator""ns() + { return __check_overflow(); } + +#pragma GCC diagnostic pop + /// @} + } // inline namespace chrono_literals + } // inline namespace literals + + namespace chrono + { + using namespace literals::chrono_literals; + } // namespace chrono +#endif // C++14 + +#if __cplusplus >= 201703L + namespace filesystem + { + struct __file_clock + { + using duration = chrono::nanoseconds; + using rep = duration::rep; + using period = duration::period; + using time_point = chrono::time_point<__file_clock>; + static constexpr bool is_steady = false; + + static time_point + now() noexcept + { return _S_from_sys(chrono::system_clock::now()); } + +#if __cplusplus > 201703L + template + static + chrono::file_time<_Dur> + from_sys(const chrono::sys_time<_Dur>& __t) noexcept + { return _S_from_sys(__t); } + + // For internal use only + template + static + chrono::sys_time<_Dur> + to_sys(const chrono::file_time<_Dur>& __t) noexcept + { return _S_to_sys(__t); } +#endif // C++20 + + private: + using __sys_clock = chrono::system_clock; + + // This clock's (unspecified) epoch is 2174-01-01 00:00:00 UTC. + // A signed 64-bit duration with nanosecond resolution gives roughly + // +/- 292 years, which covers the 1901-2446 date range for ext4. + static constexpr chrono::seconds _S_epoch_diff{6437664000}; + + protected: + // For internal use only + template + static + chrono::time_point<__file_clock, _Dur> + _S_from_sys(const chrono::time_point<__sys_clock, _Dur>& __t) noexcept + { + using __file_time = chrono::time_point<__file_clock, _Dur>; + return __file_time{__t.time_since_epoch()} - _S_epoch_diff; + } + + // For internal use only + template + static + chrono::time_point<__sys_clock, _Dur> + _S_to_sys(const chrono::time_point<__file_clock, _Dur>& __t) noexcept + { + using __sys_time = chrono::time_point<__sys_clock, _Dur>; + return __sys_time{__t.time_since_epoch()} + _S_epoch_diff; + } + }; + } // namespace filesystem +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif //_GLIBCXX_CHRONO_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..329d36d090fc66050ee9cd2b3a878cc6b77f2155 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@chrono.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h new file mode 100644 index 0000000000000000000000000000000000000000..7db316f111f110407df19223da709d84aa72c591 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h @@ -0,0 +1,843 @@ +// Locale support (codecvt) -*- C++ -*- + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/codecvt.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.1.5 Template class codecvt +// + +// Written by Benjamin Kosnik + +#ifndef _CODECVT_H +#define _CODECVT_H 1 + +#pragma GCC system_header + +#include +#include // locale::facet + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Empty base class for codecvt facet [22.2.1.5]. + class codecvt_base + { + public: + enum result + { + ok, + partial, + error, + noconv + }; + }; + + /** + * @brief Common base for codecvt functions. + * + * This template class provides implementations of the public functions + * that forward to the protected virtual functions. + * + * This template also provides abstract stubs for the protected virtual + * functions. + */ + template + class __codecvt_abstract_base + : public locale::facet, public codecvt_base + { + public: + // Types: + typedef codecvt_base::result result; + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef _StateT state_type; + + // 22.2.1.5.1 codecvt members + /** + * @brief Convert from internal to external character set. + * + * Converts input string of intern_type to output string of + * extern_type. This is analogous to wcsrtombs. It does this by + * calling codecvt::do_out. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The characters in [from,from_end) are converted and written to + * [to,to_end). from_next and to_next are set to point to the + * character following the last successfully converted character, + * respectively. If the result needed no conversion, from_next and + * to_next are not affected. + * + * The @a state argument should be initialized if the input is at the + * beginning and carried from a previous call if continuing + * conversion. There are no guarantees about how @a state is used. + * + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __from Start of input. + * @param __from_end End of input. + * @param __from_next Returns start of unconverted data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const + { + return this->do_out(__state, __from, __from_end, __from_next, + __to, __to_end, __to_next); + } + + /** + * @brief Reset conversion state. + * + * Writes characters to output that would restore @a state to initial + * conditions. The idea is that if a partial conversion occurs, then + * the converting the characters written by this function would leave + * the state in initial conditions, rather than partial conversion + * state. It does this by calling codecvt::do_unshift(). + * + * For example, if 4 external characters always converted to 1 internal + * character, and input to in() had 6 external characters with state + * saved, this function would write two characters to the output and + * set the state to initialized conditions. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The result returned is a member of codecvt_base::result. If the + * state could be reset and data written, returns codecvt_base::ok. If + * no conversion is necessary, returns codecvt_base::noconv. If the + * output has insufficient space, returns codecvt_base::partial. + * Otherwise the reset failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + unshift(state_type& __state, extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const + { return this->do_unshift(__state, __to,__to_end,__to_next); } + + /** + * @brief Convert from external to internal character set. + * + * Converts input string of extern_type to output string of + * intern_type. This is analogous to mbsrtowcs. It does this by + * calling codecvt::do_in. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The characters in [from,from_end) are converted and written to + * [to,to_end). from_next and to_next are set to point to the + * character following the last successfully converted character, + * respectively. If the result needed no conversion, from_next and + * to_next are not affected. + * + * The @a state argument should be initialized if the input is at the + * beginning and carried from a previous call if continuing + * conversion. There are no guarantees about how @a state is used. + * + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __from Start of input. + * @param __from_end End of input. + * @param __from_next Returns start of unconverted data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const + { + return this->do_in(__state, __from, __from_end, __from_next, + __to, __to_end, __to_next); + } + + int + encoding() const throw() + { return this->do_encoding(); } + + bool + always_noconv() const throw() + { return this->do_always_noconv(); } + + int + length(state_type& __state, const extern_type* __from, + const extern_type* __end, size_t __max) const + { return this->do_length(__state, __from, __end, __max); } + + int + max_length() const throw() + { return this->do_max_length(); } + + protected: + explicit + __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { } + + virtual + ~__codecvt_abstract_base() { } + + /** + * @brief Convert from internal to external character set. + * + * Converts input string of intern_type to output string of + * extern_type. This function is a hook for derived classes to change + * the value returned. @see out for more information. + */ + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const = 0; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const = 0; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const = 0; + + virtual int + do_encoding() const throw() = 0; + + virtual bool + do_always_noconv() const throw() = 0; + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const = 0; + + virtual int + do_max_length() const throw() = 0; + }; + + /** + * @brief Primary class template codecvt. + * @ingroup locales + * + * NB: Generic, mostly useless implementation. + * + */ + template + class codecvt + : public __codecvt_abstract_base<_InternT, _ExternT, _StateT> + { + public: + // Types: + typedef codecvt_base::result result; + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef _StateT state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs), + _M_c_locale_codecvt(0) + { } + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt() { } + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual int + do_encoding() const throw(); + + virtual bool + do_always_noconv() const throw(); + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + template + locale::id codecvt<_InternT, _ExternT, _StateT>::id; + + /// class codecvt specialization. + template<> + class codecvt + : public __codecvt_abstract_base + { + friend class messages; + + public: + // Types: + typedef char intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0); + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual int + do_encoding() const throw(); + + virtual bool + do_always_noconv() const throw(); + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Class codecvt specialization. + * + * Converts between narrow and wide characters in the native character set + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + friend class messages; + + public: + // Types: + typedef wchar_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0); + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; +#endif //_GLIBCXX_USE_WCHAR_T + +#if __cplusplus >= 201103L + /** @brief Class codecvt specialization. + * + * Converts between UTF-16 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char16_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + /** @brief Class codecvt specialization. + * + * Converts between UTF-32 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char32_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + +#ifdef _GLIBCXX_USE_CHAR8_T + /** @brief Class codecvt specialization. + * + * Converts between UTF-16 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char16_t intern_type; + typedef char8_t extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + /** @brief Class codecvt specialization. + * + * Converts between UTF-32 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char32_t intern_type; + typedef char8_t extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; +#endif // _GLIBCXX_USE_CHAR8_T + +#endif // C++11 + + /// class codecvt_byname [22.2.1.6]. + template + class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> + { + public: + explicit + codecvt_byname(const char* __s, size_t __refs = 0) + : codecvt<_InternT, _ExternT, _StateT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_codecvt); + this->_S_create_c_locale(this->_M_c_locale_codecvt, __s); + } + } + +#if __cplusplus >= 201103L + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~codecvt_byname() { } + }; + +#if __cplusplus >= 201103L + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + +#if defined(_GLIBCXX_USE_CHAR8_T) + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; +#endif + +#endif // C++11 + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class codecvt_byname; + + extern template + const codecvt& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class codecvt_byname; + + extern template + const codecvt& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif + +#if __cplusplus >= 201103L + extern template class codecvt_byname; + extern template class codecvt_byname; + +#if defined(_GLIBCXX_USE_CHAR8_T) + extern template class codecvt_byname; + extern template class codecvt_byname; +#endif + +#endif + +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _CODECVT_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7aff7bc7790c097cbf10f93ac65a12f860edc8a2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@codecvt.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h new file mode 100644 index 0000000000000000000000000000000000000000..35969d27280fd9815cc1643e1f426a05a4763eac --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h @@ -0,0 +1,81 @@ +// Concept-checking control -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/concept_check.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _CONCEPT_CHECK_H +#define _CONCEPT_CHECK_H 1 + +#pragma GCC system_header + +#include + +// All places in libstdc++-v3 where these are used, or /might/ be used, or +// don't need to be used, or perhaps /should/ be used, are commented with +// "concept requirements" (and maybe some more text). So grep like crazy +// if you're looking for additional places to use these. + +// Concept-checking code is off by default unless users turn it on via +// configure options or editing c++config.h. +// It is not supported for freestanding implementations. + +#if !defined(_GLIBCXX_CONCEPT_CHECKS) || !_GLIBCXX_HOSTED + +#define __glibcxx_function_requires(...) +#define __glibcxx_class_requires(_a,_b) +#define __glibcxx_class_requires2(_a,_b,_c) +#define __glibcxx_class_requires3(_a,_b,_c,_d) +#define __glibcxx_class_requires4(_a,_b,_c,_d,_e) + +#else // the checks are on + +#include + +// Note that the obvious and elegant approach of +// +//#define glibcxx_function_requires(C) debug::function_requires< debug::C >() +// +// won't work due to concept templates with more than one parameter, e.g., +// BinaryPredicateConcept. The preprocessor tries to split things up on +// the commas in the template argument list. We can't use an inner pair of +// parenthesis to hide the commas, because "debug::(Temp)" isn't +// a valid instantiation pattern. Thus, we steal a feature from C99. + +#define __glibcxx_function_requires(...) \ + __gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >(); +#define __glibcxx_class_requires(_a,_C) \ + _GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C); +#define __glibcxx_class_requires2(_a,_b,_C) \ + _GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C); +#define __glibcxx_class_requires3(_a,_b,_c,_C) \ + _GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C); +#define __glibcxx_class_requires4(_a,_b,_c,_d,_C) \ + _GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C); + +#endif // enable/disable + +#endif // _GLIBCXX_CONCEPT_CHECK diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..35eed55de7c4c3ea3c9b766de071a024357c50d1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@concept_check.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..8f91bbedbed0468ab04e8de3055dca04c67dd1ae --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h @@ -0,0 +1,569 @@ +// The -*- C++ -*- type traits classes for internal use in libstdc++ + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cpp_type_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ext/type_traits} + */ + +// Written by Gabriel Dos Reis + +#ifndef _CPP_TYPE_TRAITS_H +#define _CPP_TYPE_TRAITS_H 1 + +#pragma GCC system_header + +#include + +// +// This file provides some compile-time information about various types. +// These representations were designed, on purpose, to be constant-expressions +// and not types as found in . In particular, they +// can be used in control structures and the optimizer hopefully will do +// the obvious thing. +// +// Why integral expressions, and not functions nor types? +// Firstly, these compile-time entities are used as template-arguments +// so function return values won't work: We need compile-time entities. +// We're left with types and constant integral expressions. +// Secondly, from the point of view of ease of use, type-based compile-time +// information is -not- *that* convenient. One has to write lots of +// overloaded functions and to hope that the compiler will select the right +// one. As a net effect, the overall structure isn't very clear at first +// glance. +// Thirdly, partial ordering and overload resolution (of function templates) +// is highly costly in terms of compiler-resource. It is a Good Thing to +// keep these resource consumption as least as possible. +// +// See valarray_array.h for a case use. +// +// -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. +// +// Update 2005: types are also provided and has been +// removed. +// + +extern "C++" { + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __true_type { }; + struct __false_type { }; + + template + struct __truth_type + { typedef __false_type __type; }; + + template<> + struct __truth_type + { typedef __true_type __type; }; + + // N.B. The conversions to bool are needed due to the issue + // explained in c++/19404. + template + struct __traitor + { + enum { __value = bool(_Sp::__value) || bool(_Tp::__value) }; + typedef typename __truth_type<__value>::__type __type; + }; + + // Compare for equality of types. + template + struct __are_same + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template + struct __are_same<_Tp, _Tp> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // Holds if the template-argument is a void type. + template + struct __is_void + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_void + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // Integer types + // + template + struct __is_integer + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // Thirteen specializations (yes there are eleven standard integer + // types; long long and unsigned long long are + // supported as extensions). Up to four target-specific __int + // types are supported as well. + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +# ifdef __WCHAR_TYPE__ + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +# endif + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#if __cplusplus >= 201103L + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#define __INT_N(TYPE) \ + __extension__ \ + template<> \ + struct __is_integer \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; \ + __extension__ \ + template<> \ + struct __is_integer \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; + +#ifdef __GLIBCXX_TYPE_INT_N_0 +__INT_N(__GLIBCXX_TYPE_INT_N_0) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 +__INT_N(__GLIBCXX_TYPE_INT_N_1) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 +__INT_N(__GLIBCXX_TYPE_INT_N_2) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 +__INT_N(__GLIBCXX_TYPE_INT_N_3) +#endif + +#undef __INT_N + + // + // Floating point types + // + template + struct __is_floating + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // three specializations (float, double and 'long double') + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // Pointer types + // + template + struct __is_pointer + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template + struct __is_pointer<_Tp*> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // An arithmetic type is an integer type or a floating point type + // + template + struct __is_arithmetic + : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > + { }; + + // + // A scalar type is an arithmetic type or a pointer type + // + template + struct __is_scalar + : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > + { }; + + // + // For use in std::copy and std::find overloads for streambuf iterators. + // + template + struct __is_char + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#ifdef __WCHAR_TYPE__ + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template + struct __is_byte + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#if __cplusplus >= 201703L + enum class byte : unsigned char; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif // C++17 + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template struct iterator_traits; + + // A type that is safe for use with memcpy, memmove, memcmp etc. + template + struct __is_nonvolatile_trivially_copyable + { + enum { __value = __is_trivially_copyable(_Tp) }; + }; + + // Cannot use memcpy/memmove/memcmp on volatile types even if they are + // trivially copyable, so ensure __memcpyable + // and similar will be false. + template + struct __is_nonvolatile_trivially_copyable + { + enum { __value = 0 }; + }; + + // Whether two iterator types can be used with memcpy/memmove. + template + struct __memcpyable + { + enum { __value = 0 }; + }; + + template + struct __memcpyable<_Tp*, _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcpyable<_Tp*, const _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + // Whether two iterator types can be used with memcmp. + // This trait only says it's well-formed to use memcmp, not that it + // gives the right answer for a given algorithm. So for example, std::equal + // needs to add additional checks that the types are integers or pointers, + // because other trivially copyable types can overload operator==. + template + struct __memcmpable + { + enum { __value = 0 }; + }; + + // OK to use memcmp with pointers to trivially copyable types. + template + struct __memcmpable<_Tp*, _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcmpable + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcmpable<_Tp*, const _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + // Whether memcmp can be used to determine ordering for a type + // e.g. in std::lexicographical_compare or three-way comparisons. + // True for unsigned integer-like types where comparing each byte in turn + // as an unsigned char yields the right result. This is true for all + // unsigned integers on big endian targets, but only unsigned narrow + // character types (and std::byte) on little endian targets. + template::__value +#else + __is_byte<_Tp>::__value +#endif + > + struct __is_memcmp_ordered + { + static const bool __value = _Tp(-1) > _Tp(1); // is unsigned + }; + + template + struct __is_memcmp_ordered<_Tp, false> + { + static const bool __value = false; + }; + + // Whether two types can be compared using memcmp. + template + struct __is_memcmp_ordered_with + { + static const bool __value = __is_memcmp_ordered<_Tp>::__value + && __is_memcmp_ordered<_Up>::__value; + }; + + template + struct __is_memcmp_ordered_with<_Tp, _Up, false> + { + static const bool __value = false; + }; + +#if __cplusplus >= 201703L +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + // std::byte is not an integer, but it can be compared using memcmp. + template<> + struct __is_memcmp_ordered + { static constexpr bool __value = true; }; +#endif + + // std::byte can only be compared to itself, not to other types. + template<> + struct __is_memcmp_ordered_with + { static constexpr bool __value = true; }; + + template + struct __is_memcmp_ordered_with<_Tp, std::byte, _SameSize> + { static constexpr bool __value = false; }; + + template + struct __is_memcmp_ordered_with + { static constexpr bool __value = false; }; +#endif + + // + // Move iterator type + // + template + struct __is_move_iterator + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // Fallback implementation of the function in bits/stl_iterator.h used to + // remove the move_iterator wrapper. + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __miter_base(_Iterator __it) + { return __it; } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif //_CPP_TYPE_TRAITS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a0ba274c3eabdb6dd97394a5cde1e934e91f2a4f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cpp_type_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h new file mode 100644 index 0000000000000000000000000000000000000000..9b5af45e547d9d3ca7d956889f3002c9b6ca7155 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h @@ -0,0 +1,60 @@ +// cxxabi.h subset for cancellation -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cxxabi_forced.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cxxabi.h} + */ + +#ifndef _CXXABI_FORCED_H +#define _CXXABI_FORCED_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + /** + * @brief Thrown as part of forced unwinding. + * @ingroup exceptions + * + * A magic placeholder class that can be caught by reference to + * recognize forced unwinding. + */ + class __forced_unwind + { + virtual ~__forced_unwind() throw(); + + // Prevent catch by value. + virtual void __pure_dummy() = 0; + }; +} +#endif // __cplusplus + +#pragma GCC visibility pop + +#endif // __CXXABI_FORCED_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9cb5681021f4735794da1ff3e48ada379d2feb4f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_forced.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h new file mode 100644 index 0000000000000000000000000000000000000000..d4a03928d1f3621b7e6881adda6beb57679d30e5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h @@ -0,0 +1,80 @@ +// ABI Support -*- C++ -*- + +// Copyright (C) 2016-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cxxabi_init_exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _CXXABI_INIT_EXCEPTION_H +#define _CXXABI_INIT_EXCEPTION_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include +#include + +#ifndef _GLIBCXX_CDTOR_CALLABI +#define _GLIBCXX_CDTOR_CALLABI +#define _GLIBCXX_HAVE_CDTOR_CALLABI 0 +#else +#define _GLIBCXX_HAVE_CDTOR_CALLABI 1 +#endif + +#ifdef __cplusplus + +namespace std +{ + class type_info; +} + +namespace __cxxabiv1 +{ + struct __cxa_refcounted_exception; + + extern "C" + { + // Allocate memory for the primary exception plus the thrown object. + void* + __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW; + + void + __cxa_free_exception(void*) _GLIBCXX_NOTHROW; + + // Initialize exception (this is a GNU extension) + __cxa_refcounted_exception* + __cxa_init_primary_exception(void *object, std::type_info *tinfo, + void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW; + + } +} // namespace __cxxabiv1 + +#endif + +#pragma GCC visibility pop + +#endif // _CXXABI_INIT_EXCEPTION_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c9721b64cc2c63f02ddb2c3ae7ed3dcb46f4cda3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@cxxabi_init_exception.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc new file mode 100644 index 0000000000000000000000000000000000000000..03e0a505e14bff51eb833ee482a709ee06702578 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc @@ -0,0 +1,1369 @@ +// Deque implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/deque.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{deque} + */ + +#ifndef _DEQUE_TCC +#define _DEQUE_TCC 1 + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_default_initialize() + { + _Map_pointer __cur; + __try + { + for (__cur = this->_M_impl._M_start._M_node; + __cur < this->_M_impl._M_finish._M_node; + ++__cur) + std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(), + _M_get_Tp_allocator()); + std::__uninitialized_default_a(this->_M_impl._M_finish._M_first, + this->_M_impl._M_finish._M_cur, + _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } +#endif + + template + deque<_Tp, _Alloc>& + deque<_Tp, _Alloc>:: + operator=(const deque& __x) + { + if (std::__addressof(__x) != this) + { +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() + && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) + { + // Replacement allocator cannot free existing storage, + // so deallocate everything and take copy of __x's data. + _M_replace_map(__x, __x.get_allocator()); + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + return *this; + } + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } +#endif + const size_type __len = size(); + if (__len >= __x.size()) + _M_erase_at_end(std::copy(__x.begin(), __x.end(), + this->_M_impl._M_start)); + else + { + const_iterator __mid = __x.begin() + difference_type(__len); + std::copy(__x.begin(), __mid, this->_M_impl._M_start); + _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.end(), + std::random_access_iterator_tag()); + } + } + return *this; + } + +#if __cplusplus >= 201103L + template + template +#if __cplusplus > 201402L + typename deque<_Tp, _Alloc>::reference +#else + void +#endif + deque<_Tp, _Alloc>:: + emplace_front(_Args&&... __args) + { + if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur - 1, + std::forward<_Args>(__args)...); + --this->_M_impl._M_start._M_cur; + } + else + _M_push_front_aux(std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } + + template + template +#if __cplusplus > 201402L + typename deque<_Tp, _Alloc>::reference +#else + void +#endif + deque<_Tp, _Alloc>:: + emplace_back(_Args&&... __args) + { + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_last - 1) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish._M_cur; + } + else + _M_push_back_aux(std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + +#if __cplusplus >= 201103L + template + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + emplace(const_iterator __position, _Args&&... __args) + { + if (__position._M_cur == this->_M_impl._M_start._M_cur) + { + emplace_front(std::forward<_Args>(__args)...); + return this->_M_impl._M_start; + } + else if (__position._M_cur == this->_M_impl._M_finish._M_cur) + { + emplace_back(std::forward<_Args>(__args)...); + iterator __tmp = this->_M_impl._M_finish; + --__tmp; + return __tmp; + } + else + return _M_insert_aux(__position._M_const_cast(), + std::forward<_Args>(__args)...); + } +#endif + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + if (__position._M_cur == this->_M_impl._M_start._M_cur) + { + push_front(__x); + return this->_M_impl._M_start; + } + else if (__position._M_cur == this->_M_impl._M_finish._M_cur) + { + push_back(__x); + iterator __tmp = this->_M_impl._M_finish; + --__tmp; + return __tmp; + } + else + return _M_insert_aux(__position._M_const_cast(), __x); + } + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_erase(iterator __position) + { + iterator __next = __position; + ++__next; + const difference_type __index = __position - begin(); + if (static_cast(__index) < (size() >> 1)) + { + if (__position != begin()) + _GLIBCXX_MOVE_BACKWARD3(begin(), __position, __next); + pop_front(); + } + else + { + if (__next != end()) + _GLIBCXX_MOVE3(__next, end(), __position); + pop_back(); + } + return begin() + __index; + } + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_erase(iterator __first, iterator __last) + { + if (__first == __last) + return __first; + else if (__first == begin() && __last == end()) + { + clear(); + return end(); + } + else + { + const difference_type __n = __last - __first; + const difference_type __elems_before = __first - begin(); + if (static_cast(__elems_before) <= (size() - __n) / 2) + { + if (__first != begin()) + _GLIBCXX_MOVE_BACKWARD3(begin(), __first, __last); + _M_erase_at_begin(begin() + __n); + } + else + { + if (__last != end()) + _GLIBCXX_MOVE3(__last, end(), __first); + _M_erase_at_end(end() - __n); + } + return begin() + __elems_before; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + iterator __cur = begin(); + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + _M_range_insert_aux(end(), __first, __last, + std::__iterator_category(__first)); + } + + template + void + deque<_Tp, _Alloc>:: + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) + { + if (__pos._M_cur == this->_M_impl._M_start._M_cur) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + __try + { + std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start, + __x, _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_fill_a(this->_M_impl._M_finish, + __new_finish, __x, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + else + _M_insert_aux(__pos, __n, __x); + } + +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + if (__n) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_default_a(this->_M_impl._M_finish, + __new_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + bool + deque<_Tp, _Alloc>:: + _M_shrink_to_fit() + { + const difference_type __front_capacity + = (this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first); + if (__front_capacity == 0) + return false; + + const difference_type __back_capacity + = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur); + if (__front_capacity + __back_capacity < _S_buffer_size()) + return false; + + return std::__shrink_to_fit_aux::_S_do_it(*this); + } +#endif + + template + void + deque<_Tp, _Alloc>:: + _M_fill_initialize(const value_type& __value) + { + _Map_pointer __cur; + __try + { + for (__cur = this->_M_impl._M_start._M_node; + __cur < this->_M_impl._M_finish._M_node; + ++__cur) + std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), + __value, _M_get_Tp_allocator()); + std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first, + this->_M_impl._M_finish._M_cur, + __value, _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + this->_M_initialize_map(0); + __try + { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } + __catch(...) + { + clear(); + __throw_exception_again; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + this->_M_initialize_map(_S_check_init_len(__n, _M_get_Tp_allocator())); + + _Map_pointer __cur_node; + __try + { + for (__cur_node = this->_M_impl._M_start._M_node; + __cur_node < this->_M_impl._M_finish._M_node; + ++__cur_node) + { + if (__n < _S_buffer_size()) + __builtin_unreachable(); // See PR 100516 + + _ForwardIterator __mid = __first; + std::advance(__mid, _S_buffer_size()); + std::__uninitialized_copy_a(__first, __mid, *__cur_node, + _M_get_Tp_allocator()); + __first = __mid; + } + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish._M_first, + _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, + iterator(*__cur_node, __cur_node), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1. + template +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_push_back_aux(_Args&&... __args) +#else + void + deque<_Tp, _Alloc>:: + _M_push_back_aux(const value_type& __t) +#endif + { + if (size() == max_size()) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + + _M_reserve_map_at_back(); + *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node(); + __try + { +#if __cplusplus >= 201103L + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, + std::forward<_Args>(__args)...); +#else + this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __t); +#endif + this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + + 1); + this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first; + } + __catch(...) + { + _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1)); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first. + template +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_push_front_aux(_Args&&... __args) +#else + void + deque<_Tp, _Alloc>:: + _M_push_front_aux(const value_type& __t) +#endif + { + if (size() == max_size()) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + + _M_reserve_map_at_front(); + *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node(); + __try + { + this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + - 1); + this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1; +#if __cplusplus >= 201103L + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur, + std::forward<_Args>(__args)...); +#else + this->_M_impl.construct(this->_M_impl._M_start._M_cur, __t); +#endif + } + __catch(...) + { + ++this->_M_impl._M_start; + _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1)); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first. + template + void deque<_Tp, _Alloc>:: + _M_pop_back_aux() + { + _M_deallocate_node(this->_M_impl._M_finish._M_first); + this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1); + this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1; + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_finish._M_cur); + } + + // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1. + // Note that if the deque has at least one element (a precondition for this + // member function), and if + // _M_impl._M_start._M_cur == _M_impl._M_start._M_last, + // then the deque must have at least two nodes. + template + void deque<_Tp, _Alloc>:: + _M_pop_front_aux() + { + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_start._M_cur); + _M_deallocate_node(this->_M_impl._M_start._M_first); + this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1); + this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first; + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_insert_aux(iterator __pos, + _InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { std::copy(__first, __last, std::inserter(*this, __pos)); } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + if (__pos._M_cur == this->_M_impl._M_start._M_cur) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + else + _M_insert_aux(__pos, __first, __last, __n); + } + + template +#if __cplusplus >= 201103L + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, _Args&&... __args) + { + value_type __x_copy(std::forward<_Args>(__args)...); // XXX copy +#else + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, const value_type& __x) + { + value_type __x_copy = __x; // XXX copy +#endif + difference_type __index = __pos - this->_M_impl._M_start; + if (static_cast(__index) < size() / 2) + { + push_front(_GLIBCXX_MOVE(front())); + iterator __front1 = this->_M_impl._M_start; + ++__front1; + iterator __front2 = __front1; + ++__front2; + __pos = this->_M_impl._M_start + __index; + iterator __pos1 = __pos; + ++__pos1; + _GLIBCXX_MOVE3(__front2, __pos1, __front1); + } + else + { + push_back(_GLIBCXX_MOVE(back())); + iterator __back1 = this->_M_impl._M_finish; + --__back1; + iterator __back2 = __back1; + --__back2; + __pos = this->_M_impl._M_start + __index; + _GLIBCXX_MOVE_BACKWARD3(__pos, __back2, __back1); + } + *__pos = _GLIBCXX_MOVE(__x_copy); + return __pos; + } + + template + void + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, size_type __n, const value_type& __x) + { + const difference_type __elems_before = __pos - this->_M_impl._M_start; + const size_type __length = this->size(); + value_type __x_copy = __x; + if (__elems_before < difference_type(__length / 2)) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_impl._M_start; + __pos = this->_M_impl._M_start + __elems_before; + __try + { + if (__elems_before >= difference_type(__n)) + { + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_move_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + _GLIBCXX_MOVE3(__start_n, __pos, __old_start); + std::fill(__pos - difference_type(__n), __pos, __x_copy); + } + else + { + std::__uninitialized_move_fill(this->_M_impl._M_start, + __pos, __new_start, + this->_M_impl._M_start, + __x_copy, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + std::fill(__old_start, __pos, __x_copy); + } + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_impl._M_finish; + const difference_type __elems_after = + difference_type(__length) - __elems_before; + __pos = this->_M_impl._M_finish - __elems_after; + __try + { + if (__elems_after > difference_type(__n)) + { + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_move_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish); + std::fill(__pos, __pos + difference_type(__n), __x_copy); + } + else + { + std::__uninitialized_fill_move(this->_M_impl._M_finish, + __pos + difference_type(__n), + __x_copy, __pos, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + std::fill(__pos, __old_finish, __x_copy); + } + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n) + { + const difference_type __elemsbefore = __pos - this->_M_impl._M_start; + const size_type __length = size(); + if (static_cast(__elemsbefore) < __length / 2) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_impl._M_start; + __pos = this->_M_impl._M_start + __elemsbefore; + __try + { + if (__elemsbefore >= difference_type(__n)) + { + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_move_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + _GLIBCXX_MOVE3(__start_n, __pos, __old_start); + std::copy(__first, __last, __pos - difference_type(__n)); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, difference_type(__n) - __elemsbefore); + std::__uninitialized_move_copy(this->_M_impl._M_start, + __pos, __first, __mid, + __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + std::copy(__mid, __last, __old_start); + } + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_impl._M_finish; + const difference_type __elemsafter = + difference_type(__length) - __elemsbefore; + __pos = this->_M_impl._M_finish - __elemsafter; + __try + { + if (__elemsafter > difference_type(__n)) + { + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_move_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish); + std::copy(__first, __last, __pos); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, __elemsafter); + std::__uninitialized_copy_move(__mid, __last, __pos, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + std::copy(__first, __mid, __pos); + } + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_destroy_data_aux(iterator __first, iterator __last) + { + for (_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::_Destroy(*__node, *__node + _S_buffer_size(), + _M_get_Tp_allocator()); + + if (__first._M_node != __last._M_node) + { + std::_Destroy(__first._M_cur, __first._M_last, + _M_get_Tp_allocator()); + std::_Destroy(__last._M_first, __last._M_cur, + _M_get_Tp_allocator()); + } + else + std::_Destroy(__first._M_cur, __last._M_cur, + _M_get_Tp_allocator()); + } + + template + void + deque<_Tp, _Alloc>:: + _M_new_elements_at_front(size_type __new_elems) + { + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_front")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); + _M_reserve_map_at_front(__new_nodes); + size_type __i; + __try + { + for (__i = 1; __i <= __new_nodes; ++__i) + *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node(); + } + __catch(...) + { + for (size_type __j = 1; __j < __i; ++__j) + _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j)); + __throw_exception_again; + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_new_elements_at_back(size_type __new_elems) + { + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_back")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); + _M_reserve_map_at_back(__new_nodes); + size_type __i; + __try + { + for (__i = 1; __i <= __new_nodes; ++__i) + *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node(); + } + __catch(...) + { + for (size_type __j = 1; __j < __i; ++__j) + _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j)); + __throw_exception_again; + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) + { + const size_type __old_num_nodes + = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1; + const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; + + _Map_pointer __new_nstart; + if (this->_M_impl._M_map_size > 2 * __new_num_nodes) + { + __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size + - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + if (__new_nstart < this->_M_impl._M_start._M_node) + std::copy(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart); + else + std::copy_backward(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart + __old_num_nodes); + } + else + { + size_type __new_map_size = this->_M_impl._M_map_size + + std::max(this->_M_impl._M_map_size, + __nodes_to_add) + 2; + + _Map_pointer __new_map = this->_M_allocate_map(__new_map_size); + __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + std::copy(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart); + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + + this->_M_impl._M_map = __new_map; + this->_M_impl._M_map_size = __new_map_size; + } + + this->_M_impl._M_start._M_set_node(__new_nstart); + this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); + } + +_GLIBCXX_END_NAMESPACE_CONTAINER + + // Overload for deque::iterators, exploiting the "segmented-iterator + // optimization". + template + void + __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last, + const _VTp& __value) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + if (__first._M_node != __last._M_node) + { + std::__fill_a1(__first._M_cur, __first._M_last, __value); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::__fill_a1(*__node, *__node + _Iter::_S_buffer_size(), __value); + + std::__fill_a1(__last._M_first, __last._M_cur, __value); + } + else + std::__fill_a1(__first._M_cur, __last._M_cur, __value); + } + + template + _OI + __copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first._M_node != __last._M_node) + { + __result + = std::__copy_move_a1<_IsMove>(__first._M_cur, __first._M_last, + __result); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node != __last._M_node; ++__node) + __result + = std::__copy_move_a1<_IsMove>(*__node, + *__node + _Iter::_S_buffer_size(), + __result); + + return std::__copy_move_a1<_IsMove>(__last._M_first, __last._M_cur, + __result); + } + + return std::__copy_move_a1<_IsMove>(__first._M_cur, __last._M_cur, + __result); + } + + template + _OI + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { return __copy_move_dit<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) + { return __copy_move_dit<_IsMove>(__first, __last, __result); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_a1(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __result._M_last - __result._M_cur); + std::__copy_move_a1<_IsMove>(__first, __first + __clen, + __result._M_cur); + + __first += __clen; + __result += __clen; + __len -= __clen; + } + + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_move_a2( + istreambuf_iterator<_CharT, char_traits<_CharT> > __first, + istreambuf_iterator<_CharT, char_traits<_CharT> > __last, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result) + { + if (__first == __last) + return __result; + + for (;;) + { + const std::ptrdiff_t __len = __result._M_last - __result._M_cur; + const std::ptrdiff_t __nb + = std::__copy_n_a(__first, __len, __result._M_cur, false) + - __result._M_cur; + __result += __nb; + + if (__nb != __len) + break; + } + + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_n_a( + istreambuf_iterator<_CharT, char_traits<_CharT> > __it, _Size __size, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result, + bool __strict) + { + if (__size == 0) + return __result; + + do + { + const _Size __len + = std::min<_Size>(__result._M_last - __result._M_cur, __size); + std::__copy_n_a(__it, __len, __result._M_cur, __strict); + __result += __len; + __size -= __len; + } + while (__size != 0); + return __result; + } + + template + _OI + __copy_move_backward_dit( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first._M_node != __last._M_node) + { + __result = std::__copy_move_backward_a1<_IsMove>( + __last._M_first, __last._M_cur, __result); + + for (typename _Iter::_Map_pointer __node = __last._M_node - 1; + __node != __first._M_node; --__node) + __result = std::__copy_move_backward_a1<_IsMove>( + *__node, *__node + _Iter::_S_buffer_size(), __result); + + return std::__copy_move_backward_a1<_IsMove>( + __first._M_cur, __first._M_last, __result); + } + + return std::__copy_move_backward_a1<_IsMove>( + __first._M_cur, __last._M_cur, __result); + } + + template + _OI + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) + { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_backward_a1(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + difference_type __rlen = __result._M_cur - __result._M_first; + _Tp* __rend = __result._M_cur; + if (!__rlen) + { + __rlen = _Iter::_S_buffer_size(); + __rend = *(__result._M_node - 1) + __rlen; + } + + const difference_type __clen = std::min(__len, __rlen); + std::__copy_move_backward_a1<_IsMove>(__last - __clen, __last, __rend); + + __last -= __clen; + __result -= __clen; + __len -= __clen; + } + + return __result; + } + + template + bool + __equal_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1, + _II __first2) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first1._M_node != __last1._M_node) + { + if (!std::__equal_aux1(__first1._M_cur, __first1._M_last, __first2)) + return false; + + __first2 += __first1._M_last - __first1._M_cur; + for (typename _Iter::_Map_pointer __node = __first1._M_node + 1; + __node != __last1._M_node; + __first2 += _Iter::_S_buffer_size(), ++__node) + if (!std::__equal_aux1(*__node, *__node + _Iter::_S_buffer_size(), + __first2)) + return false; + + return std::__equal_aux1(__last1._M_first, __last1._M_cur, __first2); + } + + return std::__equal_aux1(__first1._M_cur, __last1._M_cur, __first2); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last1, + _II __first2) + { return std::__equal_dit(__first1, __last1, __first2); } + + template + bool + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2) + { return std::__equal_dit(__first1, __last1, __first2); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_II __first1, _II __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first2) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last1 - __first1; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __first2._M_last - __first2._M_cur); + if (!std::__equal_aux1(__first1, __first1 + __clen, __first2._M_cur)) + return false; + + __first1 += __clen; + __len -= __clen; + __first2 += __clen; + } + + return true; + } + + template + int + __lex_cmp_dit( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1, + const _Tp2* __first2, const _Tp2* __last2) + { + const bool __simple = + (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value + && __is_pointer<_Ptr>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v<_Tp1> + && !is_volatile_v<_Tp2> +#endif + ); + typedef std::__lexicographical_compare<__simple> _Lc; + + while (__first1._M_node != __last1._M_node) + { + const ptrdiff_t __len1 = __first1._M_last - __first1._M_cur; + const ptrdiff_t __len2 = __last2 - __first2; + const ptrdiff_t __len = std::min(__len1, __len2); + // if __len1 > __len2 this will return a positive value: + if (int __ret = _Lc::__3way(__first1._M_cur, __first1._M_last, + __first2, __first2 + __len)) + return __ret; + + __first1 += __len; + __first2 += __len; + } + return _Lc::__3way(__first1._M_cur, __last1._M_cur, + __first2, __last2); + } + + template + inline bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _Tp2* __first2, _Tp2* __last2) + { return std::__lex_cmp_dit(__first1, __last1, __first2, __last2) < 0; } + + template + inline bool + __lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2) + { return std::__lex_cmp_dit(__first2, __last2, __first1, __last1) > 0; } + + template + inline bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2) + { + const bool __simple = + (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value + && __is_pointer<_Ptr1>::__value + && __is_pointer<_Ptr2>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v<_Tp1> + && !is_volatile_v<_Tp2> +#endif + ); + typedef std::__lexicographical_compare<__simple> _Lc; + + while (__first1 != __last1) + { + const ptrdiff_t __len2 = __first2._M_node == __last2._M_node + ? __last2._M_cur - __first2._M_cur + : __first2._M_last - __first2._M_cur; + if (__len2 == 0) + return false; + const ptrdiff_t __len1 = __first1._M_node == __last1._M_node + ? __last1._M_cur - __first1._M_cur + : __first1._M_last - __first1._M_cur; + const ptrdiff_t __len = std::min(__len1, __len2); + if (int __ret = _Lc::__3way(__first1._M_cur, __first1._M_cur + __len, + __first2._M_cur, __first2._M_cur + __len)) + return __ret < 0; + + __first1 += __len; + __first2 += __len; + } + + return __last2 != __first2; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..cf946774977cdd07cf62f106bebbebf49205f0c5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@deque.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h new file mode 100644 index 0000000000000000000000000000000000000000..1e89f9d599475e4fb155dc97086ac4ec9ad2d79a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h @@ -0,0 +1,316 @@ +// -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/enable_special_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _ENABLE_SPECIAL_MEMBERS_H +#define _ENABLE_SPECIAL_MEMBERS_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +/// @cond undocumented + + struct _Enable_default_constructor_tag + { + explicit constexpr _Enable_default_constructor_tag() = default; + }; + +/** + * @brief A mixin helper to conditionally enable or disable the default + * constructor. + * @sa _Enable_special_members + */ +template + struct _Enable_default_constructor + { + constexpr _Enable_default_constructor() noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor const&) + noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor&&) + noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor const&) noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor&&) noexcept = default; + + // Can be used in other ctors. + constexpr explicit + _Enable_default_constructor(_Enable_default_constructor_tag) { } + }; + + +/** + * @brief A mixin helper to conditionally enable or disable the default + * destructor. + * @sa _Enable_special_members + */ +template + struct _Enable_destructor { }; + +/** + * @brief A mixin helper to conditionally enable or disable the copy/move + * special members. + * @sa _Enable_special_members + */ +template + struct _Enable_copy_move { }; + +/** + * @brief A mixin helper to conditionally enable or disable the special + * members. + * + * The @c _Tag type parameter is to make mixin bases unique and thus avoid + * ambiguities. + */ +template + struct _Enable_special_members + : private _Enable_default_constructor<_Default, _Tag>, + private _Enable_destructor<_Destructor, _Tag>, + private _Enable_copy_move<_Copy, _CopyAssignment, + _Move, _MoveAssignment, + _Tag> + { }; + +// Boilerplate follows. + +template + struct _Enable_default_constructor + { + constexpr _Enable_default_constructor() noexcept = delete; + constexpr _Enable_default_constructor(_Enable_default_constructor const&) + noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor&&) + noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor const&) noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor&&) noexcept = default; + + // Can be used in other ctors. + constexpr explicit + _Enable_default_constructor(_Enable_default_constructor_tag) { } + }; + +template + struct _Enable_destructor + { ~_Enable_destructor() noexcept = delete; }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +/// @endcond +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _ENABLE_SPECIAL_MEMBERS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..cf74230ded33f0483236a26ef7e4c21b2fee6449 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@enable_special_members.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h new file mode 100644 index 0000000000000000000000000000000000000000..397207f4b56804e12c9a384bae48787cedb9826e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h @@ -0,0 +1,76 @@ +// -*- C++ -*- + +// Copyright (C) 2015-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/erase_if.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _GLIBCXX_ERASE_IF_H +#define _GLIBCXX_ERASE_IF_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus > 201703L +# define __cpp_lib_erase_if 202002L +#endif + + namespace __detail + { + template + typename _Container::size_type + __erase_nodes_if(_Container& __cont, const _UnsafeContainer& __ucont, + _Predicate __pred) + { + typename _Container::size_type __num = 0; + for (auto __iter = __ucont.begin(), __last = __ucont.end(); + __iter != __last;) + { + if (__pred(*__iter)) + { + __iter = __cont.erase(__iter); + ++__num; + } + else + ++__iter; + } + return __num; + } + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_ERASE_IF_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b9ccddb922f0dec8a841987aadfbc07dc4773920 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@erase_if.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h new file mode 100644 index 0000000000000000000000000000000000000000..7d905184c64a4f2e47f10845ef9a6d0d2c5a3f99 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h @@ -0,0 +1,87 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 2016-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef __EXCEPTION_H +#define __EXCEPTION_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include + +extern "C++" { + +namespace std +{ + /** + * @defgroup exceptions Exceptions + * @ingroup diagnostics + * @since C++98 + * + * Classes and functions for reporting errors via exceptions. + * @{ + */ + + /** + * @brief Base class for all library exceptions. + * + * This is the base class for all exceptions thrown by the standard + * library, and by certain language expressions. You are free to derive + * your own %exception classes, or use a different hierarchy, or to + * throw non-class data (e.g., fundamental types). + */ + class exception + { + public: + exception() _GLIBCXX_NOTHROW { } + virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; +#if __cplusplus >= 201103L + exception(const exception&) = default; + exception& operator=(const exception&) = default; + exception(exception&&) = default; + exception& operator=(exception&&) = default; +#endif + + /** Returns a C-style character string describing the general cause + * of the current error. */ + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + }; + + /// @} + +} // namespace std + +} + +#pragma GCC visibility pop + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..25d32ff66727c693fd6d2bc195426b0667fc7786 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..b8794ab00a3755a973af933d2e589b469a9d910c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h @@ -0,0 +1,45 @@ +// -fno-exceptions Support -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _EXCEPTION_DEFINES_H +#define _EXCEPTION_DEFINES_H 1 + +#if ! __cpp_exceptions +// Iff -fno-exceptions, transform error handling code to work without it. +# define __try if (true) +# define __catch(X) if (false) +# define __throw_exception_again +#else +// Else proceed normally. +# define __try try +# define __catch(X) catch(X) +# define __throw_exception_again throw +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1032bbc0032dc416aca72537971b69310df69e22 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_defines.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h new file mode 100644 index 0000000000000000000000000000000000000000..6433f059e9c4f73a5b093bb05485a8d97ded156b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h @@ -0,0 +1,288 @@ +// Exception Handling support header (exception_ptr class) for -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _EXCEPTION_PTR_H +#define _EXCEPTION_PTR_H + +#pragma GCC visibility push(default) + +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +# include +#endif + +#ifdef _GLIBCXX_EH_PTR_RELOPS_COMPAT +# define _GLIBCXX_EH_PTR_USED __attribute__((__used__)) +#else +# define _GLIBCXX_EH_PTR_USED +#endif + +extern "C++" { + +namespace std +{ + class type_info; + + /** + * @addtogroup exceptions + * @{ + */ + + namespace __exception_ptr + { + class exception_ptr; + } + + using __exception_ptr::exception_ptr; + + /** Obtain an exception_ptr to the currently handled exception. If there + * is none, or the currently handled exception is foreign, return the null + * value. + */ + exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT; + + template + exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; + + /// Throw the object pointed to by the exception_ptr. + void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); + + namespace __exception_ptr + { + using std::rethrow_exception; + + /** + * @brief An opaque pointer to an arbitrary exception. + * @ingroup exceptions + */ + class exception_ptr + { + void* _M_exception_object; + + explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT; + + void _M_addref() _GLIBCXX_USE_NOEXCEPT; + void _M_release() _GLIBCXX_USE_NOEXCEPT; + + void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__)); + + friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT; + friend void std::rethrow_exception(exception_ptr); + template + friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; + + public: + exception_ptr() _GLIBCXX_USE_NOEXCEPT; + + exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + exception_ptr(nullptr_t) noexcept + : _M_exception_object(nullptr) + { } + + exception_ptr(exception_ptr&& __o) noexcept + : _M_exception_object(__o._M_exception_object) + { __o._M_exception_object = nullptr; } +#endif + +#if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT) + typedef void (exception_ptr::*__safe_bool)(); + + // For construction from nullptr or 0. + exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT; +#endif + + exception_ptr& + operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + exception_ptr& + operator=(exception_ptr&& __o) noexcept + { + exception_ptr(static_cast(__o)).swap(*this); + return *this; + } +#endif + + ~exception_ptr() _GLIBCXX_USE_NOEXCEPT; + + void + swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#ifdef _GLIBCXX_EH_PTR_COMPAT + // Retained for compatibility with CXXABI_1.3. + void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__const__)); + bool operator!() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT; +#endif + +#if __cplusplus >= 201103L + explicit operator bool() const noexcept + { return _M_exception_object; } +#endif + +#if __cpp_impl_three_way_comparison >= 201907L \ + && ! defined _GLIBCXX_EH_PTR_RELOPS_COMPAT + friend bool + operator==(const exception_ptr&, const exception_ptr&) noexcept = default; +#else + friend _GLIBCXX_EH_PTR_USED bool + operator==(const exception_ptr& __x, const exception_ptr& __y) + _GLIBCXX_USE_NOEXCEPT + { return __x._M_exception_object == __y._M_exception_object; } + + friend _GLIBCXX_EH_PTR_USED bool + operator!=(const exception_ptr& __x, const exception_ptr& __y) + _GLIBCXX_USE_NOEXCEPT + { return __x._M_exception_object != __y._M_exception_object; } +#endif + + const class std::type_info* + __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + }; + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::exception_ptr() _GLIBCXX_USE_NOEXCEPT + : _M_exception_object(0) + { } + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::exception_ptr(const exception_ptr& __other) + _GLIBCXX_USE_NOEXCEPT + : _M_exception_object(__other._M_exception_object) + { + if (_M_exception_object) + _M_addref(); + } + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT + { + if (_M_exception_object) + _M_release(); + } + + _GLIBCXX_EH_PTR_USED + inline exception_ptr& + exception_ptr::operator=(const exception_ptr& __other) _GLIBCXX_USE_NOEXCEPT + { + exception_ptr(__other).swap(*this); + return *this; + } + + _GLIBCXX_EH_PTR_USED + inline void + exception_ptr::swap(exception_ptr &__other) _GLIBCXX_USE_NOEXCEPT + { + void *__tmp = _M_exception_object; + _M_exception_object = __other._M_exception_object; + __other._M_exception_object = __tmp; + } + + /// @relates exception_ptr + inline void + swap(exception_ptr& __lhs, exception_ptr& __rhs) + { __lhs.swap(__rhs); } + + /// @cond undocumented + template + _GLIBCXX_CDTOR_CALLABI + inline void + __dest_thunk(void* __x) + { static_cast<_Ex*>(__x)->~_Ex(); } + /// @endcond + + } // namespace __exception_ptr + + /// Obtain an exception_ptr pointing to a copy of the supplied object. +#if (__cplusplus >= 201103L && __cpp_rtti) || __cpp_exceptions + template + exception_ptr + make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT + { +#if __cplusplus >= 201103L && __cpp_rtti + using _Ex2 = typename decay<_Ex>::type; + void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); + (void) __cxxabiv1::__cxa_init_primary_exception( + __e, const_cast(&typeid(_Ex)), + __exception_ptr::__dest_thunk<_Ex2>); + __try + { + ::new (__e) _Ex2(__ex); + return exception_ptr(__e); + } + __catch(...) + { + __cxxabiv1::__cxa_free_exception(__e); + return current_exception(); + } +#else + try + { + throw __ex; + } + catch(...) + { + return current_exception(); + } +#endif + } +#else // no RTTI and no exceptions + // This is always_inline so the linker will never use this useless definition + // instead of a working one compiled with RTTI and/or exceptions enabled. + template + __attribute__ ((__always_inline__)) + exception_ptr + make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT + { return exception_ptr(); } +#endif + +#undef _GLIBCXX_EH_PTR_USED + + /// @} group exceptions +} // namespace std + +} // extern "C++" + +#pragma GCC visibility pop + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0a1f9655d81eeb6dd72b7445d6c8864dd4560d9f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@exception_ptr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h new file mode 100644 index 0000000000000000000000000000000000000000..bbb1740296b9d86dc279d543417c60731d1b3a0f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h @@ -0,0 +1,1544 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/forward_list.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{forward_list} + */ + +#ifndef _FORWARD_LIST_H +#define _FORWARD_LIST_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * @brief A helper basic node class for %forward_list. + * This is just a linked list with nothing inside it. + * There are purely list shuffling utility methods here. + */ + struct _Fwd_list_node_base + { + _Fwd_list_node_base() = default; + _Fwd_list_node_base(_Fwd_list_node_base&& __x) noexcept + : _M_next(__x._M_next) + { __x._M_next = nullptr; } + + _Fwd_list_node_base(const _Fwd_list_node_base&) = delete; + _Fwd_list_node_base& operator=(const _Fwd_list_node_base&) = delete; + + _Fwd_list_node_base& + operator=(_Fwd_list_node_base&& __x) noexcept + { + _M_next = __x._M_next; + __x._M_next = nullptr; + return *this; + } + + _Fwd_list_node_base* _M_next = nullptr; + + _Fwd_list_node_base* + _M_transfer_after(_Fwd_list_node_base* __begin, + _Fwd_list_node_base* __end) noexcept + { + _Fwd_list_node_base* __keep = __begin->_M_next; + if (__end) + { + __begin->_M_next = __end->_M_next; + __end->_M_next = _M_next; + } + else + __begin->_M_next = nullptr; + _M_next = __keep; + return __end; + } + + void + _M_reverse_after() noexcept + { + _Fwd_list_node_base* __tail = _M_next; + if (!__tail) + return; + while (_Fwd_list_node_base* __temp = __tail->_M_next) + { + _Fwd_list_node_base* __keep = _M_next; + _M_next = __temp; + __tail->_M_next = __temp->_M_next; + _M_next->_M_next = __keep; + } + } + }; + + /** + * @brief A helper node class for %forward_list. + * This is just a linked list with uninitialized storage for a + * data value in each node. + * There is a sorting utility method. + */ + template + struct _Fwd_list_node + : public _Fwd_list_node_base + { + _Fwd_list_node() = default; + + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + + _Tp* + _M_valptr() noexcept + { return _M_storage._M_ptr(); } + + const _Tp* + _M_valptr() const noexcept + { return _M_storage._M_ptr(); } + }; + + /** + * @brief A forward_list::iterator. + * + * All the functions are op overloads. + */ + template + struct _Fwd_list_iterator + { + typedef _Fwd_list_iterator<_Tp> _Self; + typedef _Fwd_list_node<_Tp> _Node; + + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_iterator() noexcept + : _M_node() { } + + explicit + _Fwd_list_iterator(_Fwd_list_node_base* __n) noexcept + : _M_node(__n) { } + + [[__nodiscard__]] + reference + operator*() const noexcept + { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + [[__nodiscard__]] + pointer + operator->() const noexcept + { return static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + _Self& + operator++() noexcept + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) noexcept + { + _Self __tmp(*this); + _M_node = _M_node->_M_next; + return __tmp; + } + + /** + * @brief Forward list iterator equality comparison. + */ + [[__nodiscard__]] + friend bool + operator==(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Forward list iterator inequality comparison. + */ + [[__nodiscard__]] + friend bool + operator!=(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node != __y._M_node; } +#endif + + _Self + _M_next() const noexcept + { + if (_M_node) + return _Fwd_list_iterator(_M_node->_M_next); + else + return _Fwd_list_iterator(nullptr); + } + + _Fwd_list_node_base* _M_node; + }; + + /** + * @brief A forward_list::const_iterator. + * + * All the functions are op overloads. + */ + template + struct _Fwd_list_const_iterator + { + typedef _Fwd_list_const_iterator<_Tp> _Self; + typedef const _Fwd_list_node<_Tp> _Node; + typedef _Fwd_list_iterator<_Tp> iterator; + + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_const_iterator() noexcept + : _M_node() { } + + explicit + _Fwd_list_const_iterator(const _Fwd_list_node_base* __n) noexcept + : _M_node(__n) { } + + _Fwd_list_const_iterator(const iterator& __iter) noexcept + : _M_node(__iter._M_node) { } + + [[__nodiscard__]] + reference + operator*() const noexcept + { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + [[__nodiscard__]] + pointer + operator->() const noexcept + { return static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + _Self& + operator++() noexcept + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) noexcept + { + _Self __tmp(*this); + _M_node = _M_node->_M_next; + return __tmp; + } + + /** + * @brief Forward list const_iterator equality comparison. + */ + [[__nodiscard__]] + friend bool + operator==(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Forward list const_iterator inequality comparison. + */ + [[__nodiscard__]] + friend bool + operator!=(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node != __y._M_node; } +#endif + + _Self + _M_next() const noexcept + { + if (this->_M_node) + return _Fwd_list_const_iterator(_M_node->_M_next); + else + return _Fwd_list_const_iterator(nullptr); + } + + const _Fwd_list_node_base* _M_node; + }; + + /** + * @brief Base class for %forward_list. + */ + template + struct _Fwd_list_base + { + protected: + typedef __alloc_rebind<_Alloc, _Fwd_list_node<_Tp>> _Node_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; + + struct _Fwd_list_impl + : public _Node_alloc_type + { + _Fwd_list_node_base _M_head; + + _Fwd_list_impl() + noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value) + : _Node_alloc_type(), _M_head() + { } + + _Fwd_list_impl(_Fwd_list_impl&&) = default; + + _Fwd_list_impl(_Fwd_list_impl&& __fl, _Node_alloc_type&& __a) + : _Node_alloc_type(std::move(__a)), _M_head(std::move(__fl._M_head)) + { } + + _Fwd_list_impl(_Node_alloc_type&& __a) + : _Node_alloc_type(std::move(__a)), _M_head() + { } + }; + + _Fwd_list_impl _M_impl; + + public: + typedef _Fwd_list_iterator<_Tp> iterator; + typedef _Fwd_list_const_iterator<_Tp> const_iterator; + typedef _Fwd_list_node<_Tp> _Node; + + _Node_alloc_type& + _M_get_Node_allocator() noexcept + { return this->_M_impl; } + + const _Node_alloc_type& + _M_get_Node_allocator() const noexcept + { return this->_M_impl; } + + _Fwd_list_base() = default; + + _Fwd_list_base(_Node_alloc_type&& __a) + : _M_impl(std::move(__a)) { } + + // When allocators are always equal. + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a, + std::true_type) + : _M_impl(std::move(__lst._M_impl), std::move(__a)) + { } + + // When allocators are not always equal. + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a); + + _Fwd_list_base(_Fwd_list_base&&) = default; + + ~_Fwd_list_base() + { _M_erase_after(&_M_impl._M_head, nullptr); } + + protected: + _Node* + _M_get_node() + { + auto __ptr = _Node_alloc_traits::allocate(_M_get_Node_allocator(), 1); + return std::__to_address(__ptr); + } + + template + _Node* + _M_create_node(_Args&&... __args) + { + _Node* __node = this->_M_get_node(); + __try + { + ::new ((void*)__node) _Node; + _Node_alloc_traits::construct(_M_get_Node_allocator(), + __node->_M_valptr(), + std::forward<_Args>(__args)...); + } + __catch(...) + { + this->_M_put_node(__node); + __throw_exception_again; + } + return __node; + } + + template + _Fwd_list_node_base* + _M_insert_after(const_iterator __pos, _Args&&... __args); + + void + _M_put_node(_Node* __p) + { + typedef typename _Node_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__p); + _Node_alloc_traits::deallocate(_M_get_Node_allocator(), __ptr, 1); + } + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos); + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos, + _Fwd_list_node_base* __last); + }; + + /** + * @brief A standard container with linear time access to elements, + * and fixed time insertion/deletion at any point in the sequence. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * sequence, including the + * optional sequence requirements with the + * %exception of @c at and @c operator[]. + * + * This is a @e singly @e linked %list. Traversal up the + * %list requires linear time, but adding and removing elements (or + * @e nodes) is done in constant time, regardless of where the + * change takes place. Unlike std::vector and std::deque, + * random-access iterators are not provided, so subscripting ( @c + * [] ) access is not allowed. For algorithms which only need + * sequential access, this lack makes no difference. + * + * Also unlike the other standard containers, std::forward_list provides + * specialized algorithms %unique to linked lists, such as + * splicing, sorting, and in-place reversal. + */ + template> + class forward_list : private _Fwd_list_base<_Tp, _Alloc> + { + static_assert(is_same::type, _Tp>::value, + "std::forward_list must have a non-const, non-volatile value_type"); +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::forward_list must have the same value_type as its allocator"); +#endif + + private: + typedef _Fwd_list_base<_Tp, _Alloc> _Base; + typedef _Fwd_list_node_base _Node_base; + typedef typename _Base::_Node _Node; + typedef typename _Base::_Node_alloc_type _Node_alloc_type; + typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; + typedef allocator_traits<__alloc_rebind<_Alloc, _Tp>> _Alloc_traits; + + public: + // types: + typedef _Tp value_type; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + // 23.3.4.2 construct/copy/destroy: + + /** + * @brief Creates a %forward_list with no elements. + */ + forward_list() = default; + + /** + * @brief Creates a %forward_list with no elements. + * @param __al An allocator object. + */ + explicit + forward_list(const _Alloc& __al) noexcept + : _Base(_Node_alloc_type(__al)) + { } + + /** + * @brief Copy constructor with allocator argument. + * @param __list Input list to copy. + * @param __al An allocator object. + */ + forward_list(const forward_list& __list, + const __type_identity_t<_Alloc>& __al) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__list.begin(), __list.end()); } + + private: + forward_list(forward_list&& __list, _Node_alloc_type&& __al, + false_type) + : _Base(std::move(__list), std::move(__al)) + { + // If __list is not empty it means its allocator is not equal to __a, + // so we need to move from each element individually. + insert_after(cbefore_begin(), + std::__make_move_if_noexcept_iterator(__list.begin()), + std::__make_move_if_noexcept_iterator(__list.end())); + } + + forward_list(forward_list&& __list, _Node_alloc_type&& __al, + true_type) + noexcept + : _Base(std::move(__list), _Node_alloc_type(__al), true_type{}) + { } + + public: + /** + * @brief Move constructor with allocator argument. + * @param __list Input list to move. + * @param __al An allocator object. + */ + forward_list(forward_list&& __list, + const __type_identity_t<_Alloc>& __al) + noexcept(_Node_alloc_traits::_S_always_equal()) + : forward_list(std::move(__list), _Node_alloc_type(__al), + typename _Node_alloc_traits::is_always_equal{}) + { } + + /** + * @brief Creates a %forward_list with default constructed elements. + * @param __n The number of elements to initially create. + * @param __al An allocator object. + * + * This constructor creates the %forward_list with @a __n default + * constructed elements. + */ + explicit + forward_list(size_type __n, const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %forward_list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __al An allocator object. + * + * This constructor fills the %forward_list with @a __n copies of + * @a __value. + */ + forward_list(size_type __n, const _Tp& __value, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_fill_initialize(__n, __value); } + + /** + * @brief Builds a %forward_list from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __al An allocator object. + * + * Create a %forward_list consisting of copies of the elements from + * [@a __first,@a __last). This is linear in N (where N is + * distance(@a __first,@a __last)). + */ + template> + forward_list(_InputIterator __first, _InputIterator __last, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__first, __last); } + + /** + * @brief The %forward_list copy constructor. + * @param __list A %forward_list of identical element and allocator + * types. + */ + forward_list(const forward_list& __list) + : _Base(_Node_alloc_traits::_S_select_on_copy( + __list._M_get_Node_allocator())) + { _M_range_initialize(__list.begin(), __list.end()); } + + /** + * @brief The %forward_list move constructor. + * @param __list A %forward_list of identical element and allocator + * types. + * + * The newly-created %forward_list contains the exact contents of the + * moved instance. The contents of the moved instance are a valid, but + * unspecified %forward_list. + */ + forward_list(forward_list&&) = default; + + /** + * @brief Builds a %forward_list from an initializer_list + * @param __il An initializer_list of value_type. + * @param __al An allocator object. + * + * Create a %forward_list consisting of copies of the elements + * in the initializer_list @a __il. This is linear in __il.size(). + */ + forward_list(std::initializer_list<_Tp> __il, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__il.begin(), __il.end()); } + + /** + * @brief The forward_list dtor. + */ + ~forward_list() noexcept + { } + + /** + * @brief The %forward_list assignment operator. + * @param __list A %forward_list of identical element and allocator + * types. + * + * All the elements of @a __list are copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + forward_list& + operator=(const forward_list& __list); + + /** + * @brief The %forward_list move assignment operator. + * @param __list A %forward_list of identical element and allocator + * types. + * + * The contents of @a __list are moved into this %forward_list + * (without copying, if the allocators permit it). + * + * Afterwards @a __list is a valid, but unspecified %forward_list + * + * Whether the allocator is moved depends on the allocator traits. + */ + forward_list& + operator=(forward_list&& __list) + noexcept(_Node_alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Node_alloc_traits::_S_propagate_on_move_assign() + || _Node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__list), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief The %forward_list initializer list assignment operator. + * @param __il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a __il. This is linear in + * __il.size(). + */ + forward_list& + operator=(std::initializer_list<_Tp> __il) + { + assign(__il); + return *this; + } + + /** + * @brief Assigns a range to a %forward_list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %forward_list with copies of the elements + * in the range [@a __first,@a __last). + * + * Note that the assignment completely changes the %forward_list and + * that the number of elements of the resulting %forward_list is the + * same as the number of elements assigned. + */ + template> + void + assign(_InputIterator __first, _InputIterator __last) + { + typedef is_assignable<_Tp, decltype(*__first)> __assignable; + _M_assign(__first, __last, __assignable()); + } + + /** + * @brief Assigns a given value to a %forward_list. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %forward_list with @a __n copies of the + * given value. Note that the assignment completely changes the + * %forward_list, and that the resulting %forward_list has __n + * elements. + */ + void + assign(size_type __n, const _Tp& __val) + { _M_assign_n(__n, __val, is_copy_assignable<_Tp>()); } + + /** + * @brief Assigns an initializer_list to a %forward_list. + * @param __il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a __il. This is linear in + * il.size(). + */ + void + assign(std::initializer_list<_Tp> __il) + { assign(__il.begin(), __il.end()); } + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const noexcept + { return allocator_type(this->_M_get_Node_allocator()); } + + // 23.3.4.3 iterators: + + /** + * Returns a read/write iterator that points before the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + [[__nodiscard__]] + iterator + before_begin() noexcept + { return iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + before_begin() const noexcept + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read/write iterator that points to the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + [[__nodiscard__]] + iterator + begin() noexcept + { return iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + begin() const noexcept + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + iterator + end() noexcept + { return iterator(nullptr); } + + /** + * Returns a read-only iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + end() const noexcept + { return const_iterator(nullptr); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + cbefore_begin() const noexcept + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %forward_list. Iteration is done in + * ordinary element order. + */ + [[__nodiscard__]] + const_iterator + cend() const noexcept + { return const_iterator(nullptr); } + + /** + * Returns true if the %forward_list is empty. (Thus begin() would + * equal end().) + */ + [[__nodiscard__]] + bool + empty() const noexcept + { return this->_M_impl._M_head._M_next == nullptr; } + + /** + * Returns the largest possible number of elements of %forward_list. + */ + [[__nodiscard__]] + size_type + max_size() const noexcept + { return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); } + + // 23.3.4.4 element access: + + /** + * Returns a read/write reference to the data at the first + * element of the %forward_list. + */ + [[__nodiscard__]] + reference + front() + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return *__front->_M_valptr(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %forward_list. + */ + [[__nodiscard__]] + const_reference + front() const + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return *__front->_M_valptr(); + } + + // 23.3.4.5 modifiers: + + /** + * @brief Constructs object in %forward_list at the front of the + * list. + * @param __args Arguments. + * + * This function will insert an object of type Tp constructed + * with Tp(std::forward(args)...) at the front of the list + * Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args) + { + this->_M_insert_after(cbefore_begin(), + std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } + + /** + * @brief Add data to the front of the %forward_list. + * @param __val Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %forward_list and assigns the given + * data to it. Due to the nature of a %forward_list this operation + * can be done in constant time, and does not invalidate iterators + * and references. + */ + void + push_front(const _Tp& __val) + { this->_M_insert_after(cbefore_begin(), __val); } + + /** + * + */ + void + push_front(_Tp&& __val) + { this->_M_insert_after(cbefore_begin(), std::move(__val)); } + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %forward_list + * by one. Due to the nature of a %forward_list this operation can + * be done in constant time, and only invalidates iterators/references + * to the element being removed. + * + * Note that no data is returned, and if the first element's data + * is needed, it should be retrieved before pop_front() is + * called. + */ + void + pop_front() + { this->_M_erase_after(&this->_M_impl._M_head); } + + /** + * @brief Constructs object in %forward_list after the specified + * iterator. + * @param __pos A const_iterator into the %forward_list. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) after the specified + * location. Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template + iterator + emplace_after(const_iterator __pos, _Args&&... __args) + { return iterator(this->_M_insert_after(__pos, + std::forward<_Args>(__args)...)); } + + /** + * @brief Inserts given value into %forward_list after specified + * iterator. + * @param __pos An iterator into the %forward_list. + * @param __val Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value after + * the specified location. Due to the nature of a %forward_list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, const _Tp& __val) + { return iterator(this->_M_insert_after(__pos, __val)); } + + /** + * + */ + iterator + insert_after(const_iterator __pos, _Tp&& __val) + { return iterator(this->_M_insert_after(__pos, std::move(__val))); } + + /** + * @brief Inserts a number of copies of given data into the + * %forward_list. + * @param __pos An iterator into the %forward_list. + * @param __n Number of elements to be inserted. + * @param __val Data to be inserted. + * @return An iterator pointing to the last inserted copy of + * @a val or @a pos if @a n == 0. + * + * This function will insert a specified number of copies of the + * given data after the location specified by @a pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, size_type __n, const _Tp& __val); + + /** + * @brief Inserts a range into the %forward_list. + * @param __pos An iterator into the %forward_list. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator pointing to the last inserted element or + * @a __pos if @a __first == @a __last. + * + * This function will insert copies of the data in the range + * [@a __first,@a __last) into the %forward_list after the + * location specified by @a __pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template> + iterator + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last); + + /** + * @brief Inserts the contents of an initializer_list into + * %forward_list after the specified iterator. + * @param __pos An iterator into the %forward_list. + * @param __il An initializer_list of value_type. + * @return An iterator pointing to the last inserted element + * or @a __pos if @a __il is empty. + * + * This function will insert copies of the data in the + * initializer_list @a __il into the %forward_list before the location + * specified by @a __pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) + { return insert_after(__pos, __il.begin(), __il.end()); } + + /** + * @brief Removes the element pointed to by the iterator following + * @c pos. + * @param __pos Iterator pointing before element to be erased. + * @return An iterator pointing to the element following the one + * that was erased, or end() if no such element exists. + * + * This function will erase the element at the given position and + * thus shorten the %forward_list by one. + * + * Due to the nature of a %forward_list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. The user is also cautioned that + * this function only erases the element, and that if the element + * is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos) + { return iterator(this->_M_erase_after(const_cast<_Node_base*> + (__pos._M_node))); } + + /** + * @brief Remove a range of elements. + * @param __pos Iterator pointing before the first element to be + * erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return @ __last. + * + * This function will erase the elements in the range + * @a (__pos,__last) and shorten the %forward_list accordingly. + * + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos, const_iterator __last) + { return iterator(this->_M_erase_after(const_cast<_Node_base*> + (__pos._M_node), + const_cast<_Node_base*> + (__last._M_node))); } + + /** + * @brief Swaps data with another %forward_list. + * @param __list A %forward_list of the same element and allocator + * types. + * + * This exchanges the elements between two lists in constant + * time. Note that the global std::swap() function is + * specialized such that std::swap(l1,l2) will feed to this + * function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(forward_list& __list) noexcept + { + std::swap(this->_M_impl._M_head._M_next, + __list._M_impl._M_head._M_next); + _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), + __list._M_get_Node_allocator()); + } + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param __sz Number of elements the %forward_list should contain. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current number of elements the %forward_list + * is truncated, otherwise the %forward_list is extended and the + * new elements are default constructed. + */ + void + resize(size_type __sz); + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param __sz Number of elements the %forward_list should contain. + * @param __val Data with which new elements should be populated. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current number of elements the %forward_list + * is truncated, otherwise the %forward_list is extended and new + * elements are populated with given data. + */ + void + resize(size_type __sz, const value_type& __val); + + /** + * @brief Erases all the elements. + * + * Note that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { this->_M_erase_after(&this->_M_impl._M_head, nullptr); } + + // 23.3.4.6 forward_list operations: + + /** + * @brief Insert contents of another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * + * The elements of @a list are inserted in constant time after + * the element referenced by @a pos. @a list becomes an empty + * list. + * + * Requires this != @a x. + */ + void + splice_after(const_iterator __pos, forward_list&& __list) noexcept + { + if (!__list.empty()) + _M_splice_after(__pos, __list.before_begin(), __list.end()); + } + + void + splice_after(const_iterator __pos, forward_list& __list) noexcept + { splice_after(__pos, std::move(__list)); } + + /** + * @brief Insert element from another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * @param __i Iterator referencing the element before the element + * to move. + * + * Removes the element in list @a list referenced by @a i and + * inserts it into the current list after @a pos. + */ + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __i) noexcept; + + void + splice_after(const_iterator __pos, forward_list& __list, + const_iterator __i) noexcept + { splice_after(__pos, std::move(__list), __i); } + + /** + * @brief Insert range from another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * @param __before Iterator referencing before the start of range + * in list. + * @param __last Iterator referencing the end of range in list. + * + * Removes elements in the range (__before,__last) and inserts them + * after @a __pos in constant time. + * + * Undefined if @a __pos is in (__before,__last). + * @{ + */ + void + splice_after(const_iterator __pos, forward_list&&, + const_iterator __before, const_iterator __last) noexcept + { _M_splice_after(__pos, __before, __last); } + + void + splice_after(const_iterator __pos, forward_list&, + const_iterator __before, const_iterator __last) noexcept + { _M_splice_after(__pos, __before, __last); } + /// @} + + private: +#if __cplusplus > 201703L +# define __cpp_lib_list_remove_return_type 201806L + using __remove_return_type = size_type; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +#else + using __remove_return_type = void; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG +#endif + public: + + /** + * @brief Remove all elements equal to value. + * @param __val The value to remove. + * + * Removes every element in the list equal to @a __val. + * Remaining elements stay in list order. Note that this + * function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __val); + + /** + * @brief Remove all elements satisfying a predicate. + * @param __pred Unary predicate function or object. + * + * Removes every element in the list for which the predicate + * returns true. Remaining elements stay in list order. Note + * that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + template + __remove_return_type + remove_if(_Pred __pred); + + /** + * @brief Remove consecutive duplicate elements. + * + * For each consecutive set of elements with the same value, + * remove all but the first one. Remaining elements stay in + * list order. Note that this function only erases the + * elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique() + { return unique(std::equal_to<_Tp>()); } + +#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + + /** + * @brief Remove consecutive elements satisfying a predicate. + * @param __binary_pred Binary predicate function or object. + * + * For each consecutive set of elements [first,last) that + * satisfy predicate(first,i) where i is an iterator in + * [first,last), remove all but the first one. Remaining + * elements stay in list order. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + template + __remove_return_type + unique(_BinPred __binary_pred); + + /** + * @brief Merge sorted lists. + * @param __list Sorted list to merge. + * + * Assumes that both @a list and this list are sorted according to + * operator<(). Merges elements of @a __list into this list in + * sorted order, leaving @a __list empty when complete. Elements in + * this list precede elements in @a __list that are equal. + */ + void + merge(forward_list&& __list) + { merge(std::move(__list), std::less<_Tp>()); } + + void + merge(forward_list& __list) + { merge(std::move(__list)); } + + /** + * @brief Merge sorted lists according to comparison function. + * @param __list Sorted list to merge. + * @param __comp Comparison function defining sort order. + * + * Assumes that both @a __list and this list are sorted according to + * comp. Merges elements of @a __list into this list + * in sorted order, leaving @a __list empty when complete. Elements + * in this list precede elements in @a __list that are equivalent + * according to comp(). + */ + template + void + merge(forward_list&& __list, _Comp __comp); + + template + void + merge(forward_list& __list, _Comp __comp) + { merge(std::move(__list), __comp); } + + /** + * @brief Sort the elements of the list. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + void + sort() + { sort(std::less<_Tp>()); } + + /** + * @brief Sort the forward_list using a comparison function. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + template + void + sort(_Comp __comp); + + /** + * @brief Reverse the elements in list. + * + * Reverse the order of elements in the list in linear time. + */ + void + reverse() noexcept + { this->_M_impl._M_head._M_reverse_after(); } + + private: + // Called by the range constructor to implement [23.3.4.2]/9 + template + void + _M_range_initialize(_InputIterator __first, _InputIterator __last); + + // Called by forward_list(n,v,a), and the range constructor when it + // turns out to be the same thing. + void + _M_fill_initialize(size_type __n, const value_type& __value); + + // Called by splice_after and insert_after. + iterator + _M_splice_after(const_iterator __pos, const_iterator __before, + const_iterator __last); + + // Called by forward_list(n). + void + _M_default_initialize(size_type __n); + + // Called by resize(sz). + void + _M_default_insert_after(const_iterator __pos, size_type __n); + + // Called by operator=(forward_list&&) + void + _M_move_assign(forward_list&& __list, true_type) noexcept + { + clear(); + this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next; + __list._M_impl._M_head._M_next = nullptr; + std::__alloc_on_move(this->_M_get_Node_allocator(), + __list._M_get_Node_allocator()); + } + + // Called by operator=(forward_list&&) + void + _M_move_assign(forward_list&& __list, false_type) + { + if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator()) + _M_move_assign(std::move(__list), true_type()); + else + // The rvalue's allocator cannot be moved, or is not equal, + // so we need to individually move each element. + this->assign(std::make_move_iterator(__list.begin()), + std::make_move_iterator(__list.end())); + } + + // Called by assign(_InputIterator, _InputIterator) if _Tp is + // CopyAssignable. + template + void + _M_assign(_InputIterator __first, _InputIterator __last, true_type) + { + auto __prev = before_begin(); + auto __curr = begin(); + auto __end = end(); + while (__curr != __end && __first != __last) + { + *__curr = *__first; + ++__prev; + ++__curr; + ++__first; + } + if (__first != __last) + insert_after(__prev, __first, __last); + else if (__curr != __end) + erase_after(__prev, __end); + } + + // Called by assign(_InputIterator, _InputIterator) if _Tp is not + // CopyAssignable. + template + void + _M_assign(_InputIterator __first, _InputIterator __last, false_type) + { + clear(); + insert_after(cbefore_begin(), __first, __last); + } + + // Called by assign(size_type, const _Tp&) if Tp is CopyAssignable + void + _M_assign_n(size_type __n, const _Tp& __val, true_type) + { + auto __prev = before_begin(); + auto __curr = begin(); + auto __end = end(); + while (__curr != __end && __n > 0) + { + *__curr = __val; + ++__prev; + ++__curr; + --__n; + } + if (__n > 0) + insert_after(__prev, __n, __val); + else if (__curr != __end) + erase_after(__prev, __end); + } + + // Called by assign(size_type, const _Tp&) if Tp is non-CopyAssignable + void + _M_assign_n(size_type __n, const _Tp& __val, false_type) + { + clear(); + insert_after(cbefore_begin(), __n, __val); + } + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> forward_list<_ValT, _Allocator>; +#endif + + /** + * @brief Forward list equality comparison. + * @param __lx A %forward_list + * @param __ly A %forward_list of the same type as @a __lx. + * @return True iff the elements of the forward lists are equal. + * + * This is an equivalence relation. It is linear in the number of + * elements of the forward lists. Deques are considered equivalent + * if corresponding elements compare equal. + */ + template + [[__nodiscard__]] + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly); + +#if __cpp_lib_three_way_comparison + /** + * @brief Forward list ordering relation. + * @param __x A `forward_list`. + * @param __y A `forward_list` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + [[nodiscard]] + inline __detail::__synth3way_t<_Tp> + operator<=>(const forward_list<_Tp, _Alloc>& __x, + const forward_list<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Forward list ordering relation. + * @param __lx A %forward_list. + * @param __ly A %forward_list of the same type as @a __lx. + * @return True iff @a __lx is lexicographically less than @a __ly. + * + * This is a total ordering relation. It is linear in the number of + * elements of the forward lists. The elements must be comparable + * with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + [[__nodiscard__]] + inline bool + operator<(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return std::lexicographical_compare(__lx.cbegin(), __lx.cend(), + __ly.cbegin(), __ly.cend()); } + + /// Based on operator== + template + [[__nodiscard__]] + inline bool + operator!=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx == __ly); } + + /// Based on operator< + template + [[__nodiscard__]] + inline bool + operator>(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return (__ly < __lx); } + + /// Based on operator< + template + [[__nodiscard__]] + inline bool + operator>=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx < __ly); } + + /// Based on operator< + template + [[__nodiscard__]] + inline bool + operator<=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__ly < __lx); } +#endif // three-way comparison + + /// See std::forward_list::swap(). + template + inline void + swap(forward_list<_Tp, _Alloc>& __lx, + forward_list<_Tp, _Alloc>& __ly) + noexcept(noexcept(__lx.swap(__ly))) + { __lx.swap(__ly); } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _FORWARD_LIST_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..50b58bb7af8717a5df10e9f818d71f059cb907af Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc new file mode 100644 index 0000000000000000000000000000000000000000..b0a65457404c2743df779386b5fcca71e43811a3 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc @@ -0,0 +1,517 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/forward_list.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{forward_list} + */ + +#ifndef _FORWARD_LIST_TCC +#define _FORWARD_LIST_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + _Fwd_list_base<_Tp, _Alloc>:: + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { + if (__lst._M_get_Node_allocator() == _M_get_Node_allocator()) + this->_M_impl._M_head = std::move(__lst._M_impl._M_head); + } + + template + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_insert_after(const_iterator __pos, _Args&&... __args) + { + _Fwd_list_node_base* __to + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + _Node* __thing = _M_create_node(std::forward<_Args>(__args)...); + __thing->_M_next = __to->_M_next; + __to->_M_next = __thing; + return __to->_M_next; + } + + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + __pos->_M_next = __curr->_M_next; + _Node_alloc_traits::destroy(_M_get_Node_allocator(), + __curr->_M_valptr()); + __curr->~_Node(); + _M_put_node(__curr); + return __pos->_M_next; + } + + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos, + _Fwd_list_node_base* __last) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + while (__curr != __last) + { + _Node* __temp = __curr; + __curr = static_cast<_Node*>(__curr->_M_next); + _Node_alloc_traits::destroy(_M_get_Node_allocator(), + __temp->_M_valptr()); + __temp->~_Node(); + _M_put_node(__temp); + } + __pos->_M_next = __last; + return __last; + } + + // Called by the range constructor to implement [23.3.4.2]/9 + template + template + void + forward_list<_Tp, _Alloc>:: + _M_range_initialize(_InputIterator __first, _InputIterator __last) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __first != __last; ++__first) + { + __to->_M_next = this->_M_create_node(*__first); + __to = __to->_M_next; + } + } + + // Called by forward_list(n,v,a). + template + void + forward_list<_Tp, _Alloc>:: + _M_fill_initialize(size_type __n, const value_type& __value) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __n; --__n) + { + __to->_M_next = this->_M_create_node(__value); + __to = __to->_M_next; + } + } + + template + void + forward_list<_Tp, _Alloc>:: + _M_default_initialize(size_type __n) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __n; --__n) + { + __to->_M_next = this->_M_create_node(); + __to = __to->_M_next; + } + } + + template + forward_list<_Tp, _Alloc>& + forward_list<_Tp, _Alloc>:: + operator=(const forward_list& __list) + { + if (std::__addressof(__list) != this) + { + if (_Node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __list._M_get_Node_allocator(); + if (!_Node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // replacement allocator cannot free existing storage + clear(); + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + assign(__list.cbegin(), __list.cend()); + } + return *this; + } + + template + void + forward_list<_Tp, _Alloc>:: + _M_default_insert_after(const_iterator __pos, size_type __n) + { + const_iterator __saved_pos = __pos; + __try + { + for (; __n; --__n) + __pos = emplace_after(__pos); + } + __catch(...) + { + erase_after(__saved_pos, ++__pos); + __throw_exception_again; + } + } + + template + void + forward_list<_Tp, _Alloc>:: + resize(size_type __sz) + { + iterator __k = before_begin(); + + size_type __len = 0; + while (__k._M_next() != end() && __len < __sz) + { + ++__k; + ++__len; + } + if (__len == __sz) + erase_after(__k, end()); + else + _M_default_insert_after(__k, __sz - __len); + } + + template + void + forward_list<_Tp, _Alloc>:: + resize(size_type __sz, const value_type& __val) + { + iterator __k = before_begin(); + + size_type __len = 0; + while (__k._M_next() != end() && __len < __sz) + { + ++__k; + ++__len; + } + if (__len == __sz) + erase_after(__k, end()); + else + insert_after(__k, __sz - __len, __val); + } + + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + _M_splice_after(const_iterator __pos, + const_iterator __before, const_iterator __last) + { + _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); + _Node_base* __b = const_cast<_Node_base*>(__before._M_node); + _Node_base* __end = __b; + + while (__end && __end->_M_next != __last._M_node) + __end = __end->_M_next; + + if (__b != __end) + return iterator(__tmp->_M_transfer_after(__b, __end)); + else + return iterator(__tmp); + } + + template + void + forward_list<_Tp, _Alloc>:: + splice_after(const_iterator __pos, forward_list&&, + const_iterator __i) noexcept + { + const_iterator __j = __i; + ++__j; + + if (__pos == __i || __pos == __j) + return; + + _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); + __tmp->_M_transfer_after(const_cast<_Node_base*>(__i._M_node), + const_cast<_Node_base*>(__j._M_node)); + } + + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + insert_after(const_iterator __pos, size_type __n, const _Tp& __val) + { + if (__n) + { + forward_list __tmp(__n, __val, get_allocator()); + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); + } + else + return iterator(const_cast<_Node_base*>(__pos._M_node)); + } + + template + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last) + { + forward_list __tmp(__first, __last, get_allocator()); + if (!__tmp.empty()) + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); + else + return iterator(const_cast<_Node_base*>(__pos._M_node)); + } + +#if __cplusplus > 201703L +# define _GLIBCXX20_ONLY(__expr) __expr +#else +# define _GLIBCXX20_ONLY(__expr) +#endif + + template + auto + forward_list<_Tp, _Alloc>:: + remove(const _Tp& __val) -> __remove_return_type + { + size_type __removed __attribute__((__unused__)) = 0; + forward_list __to_destroy(get_allocator()); + + auto __prev_it = cbefore_begin(); + while (_Node* __tmp = static_cast<_Node*>(__prev_it._M_node->_M_next)) + if (*__tmp->_M_valptr() == __val) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __prev_it); + _GLIBCXX20_ONLY( __removed++ ); + } + else + ++__prev_it; + + return _GLIBCXX20_ONLY( __removed ); + } + + template + template + auto + forward_list<_Tp, _Alloc>:: + remove_if(_Pred __pred) -> __remove_return_type + { + size_type __removed __attribute__((__unused__)) = 0; + forward_list __to_destroy(get_allocator()); + + auto __prev_it = cbefore_begin(); + while (_Node* __tmp = static_cast<_Node*>(__prev_it._M_node->_M_next)) + if (__pred(*__tmp->_M_valptr())) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __prev_it); + _GLIBCXX20_ONLY( __removed++ ); + } + else + ++__prev_it; + + return _GLIBCXX20_ONLY( __removed ); + } + + template + template + auto + forward_list<_Tp, _Alloc>:: + unique(_BinPred __binary_pred) -> __remove_return_type + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY(0); + + forward_list __to_destroy(get_allocator()); + size_type __removed __attribute__((__unused__)) = 0; + iterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(*__first, *__next)) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __first); + _GLIBCXX20_ONLY( __removed++ ); + } + else + __first = __next; + __next = __first; + } + + return _GLIBCXX20_ONLY( __removed ); + } + +#undef _GLIBCXX20_ONLY + + template + template + void + forward_list<_Tp, _Alloc>:: + merge(forward_list&& __list, _Comp __comp) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3088. forward_list::merge behavior unclear when passed *this + if (std::__addressof(__list) == this) + return; + + _Node_base* __node = &this->_M_impl._M_head; + while (__node->_M_next && __list._M_impl._M_head._M_next) + { + if (__comp(*static_cast<_Node*> + (__list._M_impl._M_head._M_next)->_M_valptr(), + *static_cast<_Node*> + (__node->_M_next)->_M_valptr())) + __node->_M_transfer_after(&__list._M_impl._M_head, + __list._M_impl._M_head._M_next); + __node = __node->_M_next; + } + + if (__list._M_impl._M_head._M_next) + *__node = std::move(__list._M_impl._M_head); + } + + template + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { + // We don't have size() so we need to walk through both lists + // making sure both iterators are valid. + auto __ix = __lx.cbegin(); + auto __iy = __ly.cbegin(); + while (__ix != __lx.cend() && __iy != __ly.cend()) + { + if (!(*__ix == *__iy)) + return false; + ++__ix; + ++__iy; + } + if (__ix == __lx.cend() && __iy == __ly.cend()) + return true; + else + return false; + } + + template + template + void + forward_list<_Tp, _Alloc>:: + sort(_Comp __comp) + { + // If `next' is nullptr, return immediately. + _Node* __list = static_cast<_Node*>(this->_M_impl._M_head._M_next); + if (!__list) + return; + + unsigned long __insize = 1; + + while (1) + { + _Node* __p = __list; + __list = nullptr; + _Node* __tail = nullptr; + + // Count number of merges we do in this pass. + unsigned long __nmerges = 0; + + while (__p) + { + ++__nmerges; + // There exists a merge to be done. + // Step `insize' places along from p. + _Node* __q = __p; + unsigned long __psize = 0; + for (unsigned long __i = 0; __i < __insize; ++__i) + { + ++__psize; + __q = static_cast<_Node*>(__q->_M_next); + if (!__q) + break; + } + + // If q hasn't fallen off end, we have two lists to merge. + unsigned long __qsize = __insize; + + // Now we have two lists; merge them. + while (__psize > 0 || (__qsize > 0 && __q)) + { + // Decide whether next node of merge comes from p or q. + _Node* __e; + if (__psize == 0) + { + // p is empty; e must come from q. + __e = __q; + __q = static_cast<_Node*>(__q->_M_next); + --__qsize; + } + else if (__qsize == 0 || !__q) + { + // q is empty; e must come from p. + __e = __p; + __p = static_cast<_Node*>(__p->_M_next); + --__psize; + } + else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr())) + { + // First node of q is not lower; e must come from p. + __e = __p; + __p = static_cast<_Node*>(__p->_M_next); + --__psize; + } + else + { + // First node of q is lower; e must come from q. + __e = __q; + __q = static_cast<_Node*>(__q->_M_next); + --__qsize; + } + + // Add the next node to the merged list. + if (__tail) + __tail->_M_next = __e; + else + __list = __e; + __tail = __e; + } + + // Now p has stepped `insize' places along, and q has too. + __p = __q; + } + __tail->_M_next = nullptr; + + // If we have done only one merge, we're finished. + // Allow for nmerges == 0, the empty list case. + if (__nmerges <= 1) + { + this->_M_impl._M_head._M_next = __list; + return; + } + + // Otherwise repeat, merging lists twice the size. + __insize *= 2; + } + } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _FORWARD_LIST_TCC */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..ea6bbb9b27a428c1867154ca620b36fe54c3c35e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@forward_list.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc new file mode 100644 index 0000000000000000000000000000000000000000..7ccc887b882668ab685a636c45a45cf443305192 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc @@ -0,0 +1,1102 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/fstream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{fstream} + */ + +// +// ISO C++ 14882: 27.8 File-based streams +// + +#ifndef _FSTREAM_TCC +#define _FSTREAM_TCC 1 + +#pragma GCC system_header + +#include +#include // for swap +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + basic_filebuf<_CharT, _Traits>:: + _M_allocate_internal_buffer() + { + // Allocate internal buffer only if one doesn't already exist + // (either allocated or provided by the user via setbuf). + if (!_M_buf_allocated && !_M_buf) + { + _M_buf = new char_type[_M_buf_size]; + _M_buf_allocated = true; + } + } + + template + void + basic_filebuf<_CharT, _Traits>:: + _M_destroy_internal_buffer() throw() + { + if (_M_buf_allocated) + { + delete [] _M_buf; + _M_buf = 0; + _M_buf_allocated = false; + } + delete [] _M_ext_buf; + _M_ext_buf = 0; + _M_ext_buf_size = 0; + _M_ext_next = 0; + _M_ext_end = 0; + } + + template + basic_filebuf<_CharT, _Traits>:: + basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock), + _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(), + _M_state_last(), _M_buf(0), _M_buf_size(_GLIBCXX_BUFSIZ), + _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(), + _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false), + _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0), + _M_ext_end(0) + { + if (has_facet<__codecvt_type>(this->_M_buf_locale)) + _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale); + } + +#if __cplusplus >= 201103L + template + basic_filebuf<_CharT, _Traits>:: + basic_filebuf(basic_filebuf&& __rhs) + : __streambuf_type(__rhs), + _M_lock(), _M_file(std::move(__rhs._M_file), &_M_lock), + _M_mode(std::__exchange(__rhs._M_mode, ios_base::openmode(0))), + _M_state_beg(std::move(__rhs._M_state_beg)), + _M_state_cur(std::move(__rhs._M_state_cur)), + _M_state_last(std::move(__rhs._M_state_last)), + _M_buf(std::__exchange(__rhs._M_buf, nullptr)), + _M_buf_size(std::__exchange(__rhs._M_buf_size, 1)), + _M_buf_allocated(std::__exchange(__rhs._M_buf_allocated, false)), + _M_reading(std::__exchange(__rhs._M_reading, false)), + _M_writing(std::__exchange(__rhs._M_writing, false)), + _M_pback(__rhs._M_pback), + _M_pback_cur_save(std::__exchange(__rhs._M_pback_cur_save, nullptr)), + _M_pback_end_save(std::__exchange(__rhs._M_pback_end_save, nullptr)), + _M_pback_init(std::__exchange(__rhs._M_pback_init, false)), + _M_codecvt(__rhs._M_codecvt), + _M_ext_buf(std::__exchange(__rhs._M_ext_buf, nullptr)), + _M_ext_buf_size(std::__exchange(__rhs._M_ext_buf_size, 0)), + _M_ext_next(std::__exchange(__rhs._M_ext_next, nullptr)), + _M_ext_end(std::__exchange(__rhs._M_ext_end, nullptr)) + { + __rhs._M_set_buffer(-1); + __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg; + } + + template + basic_filebuf<_CharT, _Traits>& + basic_filebuf<_CharT, _Traits>:: + operator=(basic_filebuf&& __rhs) + { + this->close(); + __streambuf_type::operator=(__rhs); + _M_file.swap(__rhs._M_file); + _M_mode = std::__exchange(__rhs._M_mode, ios_base::openmode(0)); + _M_state_beg = std::move(__rhs._M_state_beg); + _M_state_cur = std::move(__rhs._M_state_cur); + _M_state_last = std::move(__rhs._M_state_last); + _M_buf = std::__exchange(__rhs._M_buf, nullptr); + _M_buf_size = std::__exchange(__rhs._M_buf_size, 1); + _M_buf_allocated = std::__exchange(__rhs._M_buf_allocated, false); + _M_ext_buf = std::__exchange(__rhs._M_ext_buf, nullptr); + _M_ext_buf_size = std::__exchange(__rhs._M_ext_buf_size, 0); + _M_ext_next = std::__exchange(__rhs._M_ext_next, nullptr); + _M_ext_end = std::__exchange(__rhs._M_ext_end, nullptr); + _M_reading = std::__exchange(__rhs._M_reading, false); + _M_writing = std::__exchange(__rhs._M_writing, false); + _M_pback_cur_save = std::__exchange(__rhs._M_pback_cur_save, nullptr); + _M_pback_end_save = std::__exchange(__rhs._M_pback_end_save, nullptr); + _M_pback_init = std::__exchange(__rhs._M_pback_init, false); + __rhs._M_set_buffer(-1); + __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg; + return *this; + } + + template + void + basic_filebuf<_CharT, _Traits>:: + swap(basic_filebuf& __rhs) + { + __streambuf_type::swap(__rhs); + _M_file.swap(__rhs._M_file); + std::swap(_M_mode, __rhs._M_mode); + std::swap(_M_state_beg, __rhs._M_state_beg); + std::swap(_M_state_cur, __rhs._M_state_cur); + std::swap(_M_state_last, __rhs._M_state_last); + std::swap(_M_buf, __rhs._M_buf); + std::swap(_M_buf_size, __rhs._M_buf_size); + std::swap(_M_buf_allocated, __rhs._M_buf_allocated); + std::swap(_M_ext_buf, __rhs._M_ext_buf); + std::swap(_M_ext_buf_size, __rhs._M_ext_buf_size); + std::swap(_M_ext_next, __rhs._M_ext_next); + std::swap(_M_ext_end, __rhs._M_ext_end); + std::swap(_M_reading, __rhs._M_reading); + std::swap(_M_writing, __rhs._M_writing); + std::swap(_M_pback_cur_save, __rhs._M_pback_cur_save); + std::swap(_M_pback_end_save, __rhs._M_pback_end_save); + std::swap(_M_pback_init, __rhs._M_pback_init); + } +#endif + + template + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + basic_filebuf<_CharT, _Traits>:: + open(const char* __s, ios_base::openmode __mode) + { + __filebuf_type *__ret = 0; + if (!this->is_open()) + { + _M_file.open(__s, __mode); + if (this->is_open()) + { + _M_allocate_internal_buffer(); + _M_mode = __mode; + + // Setup initial buffer to 'uncommitted' mode. + _M_reading = false; + _M_writing = false; + _M_set_buffer(-1); + + // Reset to initial state. + _M_state_last = _M_state_cur = _M_state_beg; + + // 27.8.1.3,4 + if ((__mode & ios_base::ate) + && this->seekoff(0, ios_base::end, __mode) + == pos_type(off_type(-1))) + this->close(); + else + __ret = this; + } + } + return __ret; + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + template + basic_filebuf<_CharT, _Traits>* + basic_filebuf<_CharT, _Traits>:: + open(const wchar_t* __s, ios_base::openmode __mode) + { + __filebuf_type *__ret = 0; + if (!this->is_open()) + { + _M_file.open(__s, __mode); + if (this->is_open()) + { + _M_allocate_internal_buffer(); + _M_mode = __mode; + + // Setup initial buffer to 'uncommitted' mode. + _M_reading = false; + _M_writing = false; + _M_set_buffer(-1); + + // Reset to initial state. + _M_state_last = _M_state_cur = _M_state_beg; + + // 27.8.1.3,4 + if ((__mode & ios_base::ate) + && this->seekoff(0, ios_base::end, __mode) + == pos_type(off_type(-1))) + this->close(); + else + __ret = this; + } + } + return __ret; + } +#endif // HAVE__WFOPEN && USE_WCHAR_T + + template + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + basic_filebuf<_CharT, _Traits>:: + close() + { + if (!this->is_open()) + return 0; + + bool __testfail = false; + { + // NB: Do this here so that re-opened filebufs will be cool... + struct __close_sentry + { + basic_filebuf *__fb; + __close_sentry (basic_filebuf *__fbi): __fb(__fbi) { } + ~__close_sentry () + { + __fb->_M_mode = ios_base::openmode(0); + __fb->_M_pback_init = false; + __fb->_M_destroy_internal_buffer(); + __fb->_M_reading = false; + __fb->_M_writing = false; + __fb->_M_set_buffer(-1); + __fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg; + } + } __cs (this); + + __try + { + if (!_M_terminate_output()) + __testfail = true; + } + __catch(...) + { + _M_file.close(); + __throw_exception_again; + } + } + + if (!_M_file.close()) + __testfail = true; + + if (__testfail) + return 0; + else + return this; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + showmanyc() + { + streamsize __ret = -1; + const bool __testin = _M_mode & ios_base::in; + if (__testin && this->is_open()) + { + // For a stateful encoding (-1) the pending sequence might be just + // shift and unshift prefixes with no actual character. + __ret = this->egptr() - this->gptr(); + +#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM + // About this workaround, see libstdc++/20806. + const bool __testbinary = _M_mode & ios_base::binary; + if (__check_facet(_M_codecvt).encoding() >= 0 + && __testbinary) +#else + if (__check_facet(_M_codecvt).encoding() >= 0) +#endif + __ret += _M_file.showmanyc() / _M_codecvt->max_length(); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + underflow() + { + int_type __ret = traits_type::eof(); + const bool __testin = _M_mode & ios_base::in; + if (__testin) + { + if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + // Check for pback madness, and if so switch back to the + // normal buffers and jet outta here before expensive + // fileops happen... + _M_destroy_pback(); + + if (this->gptr() < this->egptr()) + return traits_type::to_int_type(*this->gptr()); + + // Get and convert input sequence. + const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; + + // Will be set to true if ::read() returns 0 indicating EOF. + bool __got_eof = false; + // Number of internal characters produced. + streamsize __ilen = 0; + codecvt_base::result __r = codecvt_base::ok; + if (__check_facet(_M_codecvt).always_noconv()) + { + __ilen = _M_file.xsgetn(reinterpret_cast(this->eback()), + __buflen); + if (__ilen == 0) + __got_eof = true; + } + else + { + // Worst-case number of external bytes. + // XXX Not done encoding() == -1. + const int __enc = _M_codecvt->encoding(); + streamsize __blen; // Minimum buffer size. + streamsize __rlen; // Number of chars to read. + if (__enc > 0) + __blen = __rlen = __buflen * __enc; + else + { + __blen = __buflen + _M_codecvt->max_length() - 1; + __rlen = __buflen; + } + const streamsize __remainder = _M_ext_end - _M_ext_next; + __rlen = __rlen > __remainder ? __rlen - __remainder : 0; + + // An imbue in 'read' mode implies first converting the external + // chars already present. + if (_M_reading && this->egptr() == this->eback() && __remainder) + __rlen = 0; + + // Allocate buffer if necessary and move unconverted + // bytes to front. + if (_M_ext_buf_size < __blen) + { + char* __buf = new char[__blen]; + if (__remainder) + __builtin_memcpy(__buf, _M_ext_next, __remainder); + + delete [] _M_ext_buf; + _M_ext_buf = __buf; + _M_ext_buf_size = __blen; + } + else if (__remainder) + __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); + + _M_ext_next = _M_ext_buf; + _M_ext_end = _M_ext_buf + __remainder; + _M_state_last = _M_state_cur; + + do + { + if (__rlen > 0) + { + // Sanity check! + // This may fail if the return value of + // codecvt::max_length() is bogus. + if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size) + { + __throw_ios_failure(__N("basic_filebuf::underflow " + "codecvt::max_length() " + "is not valid")); + } + streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen); + if (__elen == 0) + __got_eof = true; + else if (__elen == -1) + break; + _M_ext_end += __elen; + } + + char_type* __iend = this->eback(); + if (_M_ext_next < _M_ext_end) + __r = _M_codecvt->in(_M_state_cur, _M_ext_next, + _M_ext_end, _M_ext_next, + this->eback(), + this->eback() + __buflen, __iend); + if (__r == codecvt_base::noconv) + { + size_t __avail = _M_ext_end - _M_ext_buf; + __ilen = std::min(__avail, __buflen); + traits_type::copy(this->eback(), + reinterpret_cast + (_M_ext_buf), __ilen); + _M_ext_next = _M_ext_buf + __ilen; + } + else + __ilen = __iend - this->eback(); + + // _M_codecvt->in may return error while __ilen > 0: this is + // ok, and actually occurs in case of mixed encodings (e.g., + // XML files). + if (__r == codecvt_base::error) + break; + + __rlen = 1; + } + while (__ilen == 0 && !__got_eof); + } + + if (__ilen > 0) + { + _M_set_buffer(__ilen); + _M_reading = true; + __ret = traits_type::to_int_type(*this->gptr()); + } + else if (__got_eof) + { + // If the actual end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without an + // intervening seek. + _M_set_buffer(-1); + _M_reading = false; + // However, reaching it while looping on partial means that + // the file has got an incomplete character. + if (__r == codecvt_base::partial) + __throw_ios_failure(__N("basic_filebuf::underflow " + "incomplete character in file")); + } + else if (__r == codecvt_base::error) + __throw_ios_failure(__N("basic_filebuf::underflow " + "invalid byte sequence in file")); + else + __throw_ios_failure(__N("basic_filebuf::underflow " + "error reading the file"), errno); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + pbackfail(int_type __i) + { + int_type __ret = traits_type::eof(); + const bool __testin = _M_mode & ios_base::in; + if (__testin) + { + if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + // Remember whether the pback buffer is active, otherwise below + // we may try to store in it a second char (libstdc++/9761). + const bool __testpb = _M_pback_init; + const bool __testeof = traits_type::eq_int_type(__i, __ret); + int_type __tmp; + if (this->eback() < this->gptr()) + { + this->gbump(-1); + __tmp = traits_type::to_int_type(*this->gptr()); + } + else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1))) + { + __tmp = this->underflow(); + if (traits_type::eq_int_type(__tmp, __ret)) + return __ret; + } + else + { + // At the beginning of the buffer, need to make a + // putback position available. But the seek may fail + // (f.i., at the beginning of a file, see + // libstdc++/9439) and in that case we return + // traits_type::eof(). + return __ret; + } + + // Try to put back __i into input sequence in one of three ways. + // Order these tests done in is unspecified by the standard. + if (!__testeof && traits_type::eq_int_type(__i, __tmp)) + __ret = __i; + else if (__testeof) + __ret = traits_type::not_eof(__i); + else if (!__testpb) + { + _M_create_pback(); + _M_reading = true; + *this->gptr() = traits_type::to_char_type(__i); + __ret = __i; + } + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + overflow(int_type __c) + { + int_type __ret = traits_type::eof(); + const bool __testeof = traits_type::eq_int_type(__c, __ret); + const bool __testout = (_M_mode & ios_base::out + || _M_mode & ios_base::app); + if (__testout) + { + if (_M_reading) + { + _M_destroy_pback(); + const int __gptr_off = _M_get_ext_pos(_M_state_last); + if (_M_seek(__gptr_off, ios_base::cur, _M_state_last) + == pos_type(off_type(-1))) + return __ret; + } + if (this->pbase() < this->pptr()) + { + // If appropriate, append the overflow char. + if (!__testeof) + { + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + } + + // Convert pending sequence to external representation, + // and output. + if (_M_convert_to_external(this->pbase(), + this->pptr() - this->pbase())) + { + _M_set_buffer(0); + __ret = traits_type::not_eof(__c); + } + } + else if (_M_buf_size > 1) + { + // Overflow in 'uncommitted' mode: set _M_writing, set + // the buffer to the initial 'write' mode, and put __c + // into the buffer. + _M_set_buffer(0); + _M_writing = true; + if (!__testeof) + { + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + } + __ret = traits_type::not_eof(__c); + } + else + { + // Unbuffered. + char_type __conv = traits_type::to_char_type(__c); + if (__testeof || _M_convert_to_external(&__conv, 1)) + { + _M_writing = true; + __ret = traits_type::not_eof(__c); + } + } + } + return __ret; + } + + template + bool + basic_filebuf<_CharT, _Traits>:: + _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) + { + // Sizes of external and pending output. + streamsize __elen; + streamsize __plen; + if (__check_facet(_M_codecvt).always_noconv()) + { + __elen = _M_file.xsputn(reinterpret_cast(__ibuf), __ilen); + __plen = __ilen; + } + else + { + // Worst-case number of external bytes needed. + // XXX Not done encoding() == -1. + streamsize __blen = __ilen * _M_codecvt->max_length(); + char* __buf = static_cast(__builtin_alloca(__blen)); + + char* __bend; + const char_type* __iend; + codecvt_base::result __r; + __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, + __iend, __buf, __buf + __blen, __bend); + + if (__r == codecvt_base::ok || __r == codecvt_base::partial) + __blen = __bend - __buf; + else if (__r == codecvt_base::noconv) + { + // Same as the always_noconv case above. + __buf = reinterpret_cast(__ibuf); + __blen = __ilen; + } + else + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " + "conversion error")); + + __elen = _M_file.xsputn(__buf, __blen); + __plen = __blen; + + // Try once more for partial conversions. + if (__r == codecvt_base::partial && __elen == __plen) + { + const char_type* __iresume = __iend; + streamsize __rlen = this->pptr() - __iend; + __r = _M_codecvt->out(_M_state_cur, __iresume, + __iresume + __rlen, __iend, __buf, + __buf + __blen, __bend); + if (__r != codecvt_base::error) + { + __rlen = __bend - __buf; + __elen = _M_file.xsputn(__buf, __rlen); + __plen = __rlen; + } + else + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " + "conversion error")); + } + } + return __elen == __plen; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + xsgetn(_CharT* __s, streamsize __n) + { + // Clear out pback buffer before going on to the real deal... + streamsize __ret = 0; + if (_M_pback_init) + { + if (__n > 0 && this->gptr() == this->eback()) + { + *__s++ = *this->gptr(); // emulate non-underflowing sbumpc + this->gbump(1); + __ret = 1; + --__n; + } + _M_destroy_pback(); + } + else if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + + // Optimization in the always_noconv() case, to be generalized in the + // future: when __n > __buflen we read directly instead of using the + // buffer repeatedly. + const bool __testin = _M_mode & ios_base::in; + const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; + + if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() + && __testin) + { + // First, copy the chars already present in the buffer. + const streamsize __avail = this->egptr() - this->gptr(); + if (__avail != 0) + { + traits_type::copy(__s, this->gptr(), __avail); + __s += __avail; + this->setg(this->eback(), this->gptr() + __avail, this->egptr()); + __ret += __avail; + __n -= __avail; + } + + // Need to loop in case of short reads (relatively common + // with pipes). + streamsize __len; + for (;;) + { + __len = _M_file.xsgetn(reinterpret_cast(__s), __n); + if (__len == -1) + __throw_ios_failure(__N("basic_filebuf::xsgetn " + "error reading the file"), errno); + if (__len == 0) + break; + + __n -= __len; + __ret += __len; + if (__n == 0) + break; + + __s += __len; + } + + if (__n == 0) + { + // Set _M_reading. Buffer is already in initial 'read' mode. + _M_reading = true; + } + else if (__len == 0) + { + // If end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without + // an intervening seek. + _M_set_buffer(-1); + _M_reading = false; + } + } + else + __ret += __streambuf_type::xsgetn(__s, __n); + + return __ret; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + xsputn(const _CharT* __s, streamsize __n) + { + streamsize __ret = 0; + // Optimization in the always_noconv() case, to be generalized in the + // future: when __n is sufficiently large we write directly instead of + // using the buffer. + const bool __testout = (_M_mode & ios_base::out + || _M_mode & ios_base::app); + if (__check_facet(_M_codecvt).always_noconv() + && __testout && !_M_reading) + { + // Measurement would reveal the best choice. + const streamsize __chunk = 1ul << 10; + streamsize __bufavail = this->epptr() - this->pptr(); + + // Don't mistake 'uncommitted' mode buffered with unbuffered. + if (!_M_writing && _M_buf_size > 1) + __bufavail = _M_buf_size - 1; + + const streamsize __limit = std::min(__chunk, __bufavail); + if (__n >= __limit) + { + const streamsize __buffill = this->pptr() - this->pbase(); + const char* __buf = reinterpret_cast(this->pbase()); + __ret = _M_file.xsputn_2(__buf, __buffill, + reinterpret_cast(__s), + __n); + if (__ret == __buffill + __n) + { + _M_set_buffer(0); + _M_writing = true; + } + if (__ret > __buffill) + __ret -= __buffill; + else + __ret = 0; + } + else + __ret = __streambuf_type::xsputn(__s, __n); + } + else + __ret = __streambuf_type::xsputn(__s, __n); + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::__streambuf_type* + basic_filebuf<_CharT, _Traits>:: + setbuf(char_type* __s, streamsize __n) + { + if (!this->is_open()) + { + if (__s == 0 && __n == 0) + _M_buf_size = 1; + else if (__s && __n > 0) + { + // This is implementation-defined behavior, and assumes that + // an external char_type array of length __n exists and has + // been pre-allocated. If this is not the case, things will + // quickly blow up. When __n > 1, __n - 1 positions will be + // used for the get area, __n - 1 for the put area and 1 + // position to host the overflow char of a full put area. + // When __n == 1, 1 position will be used for the get area + // and 0 for the put area, as in the unbuffered case above. + _M_buf = __s; + _M_buf_size = __n; + } + } + return this; + } + + + // According to 27.8.1.4 p11 - 13, seekoff should ignore the last + // argument (of type openmode). + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) + { + int __width = 0; + if (_M_codecvt) + __width = _M_codecvt->encoding(); + if (__width < 0) + __width = 0; + + pos_type __ret = pos_type(off_type(-1)); + const bool __testfail = __off != 0 && __width <= 0; + if (this->is_open() && !__testfail) + { + // tellg and tellp queries do not affect any state, unless + // ! always_noconv and the put sequence is not empty. + // In that case, determining the position requires converting the + // put sequence. That doesn't use ext_buf, so requires a flush. + bool __no_movement = __way == ios_base::cur && __off == 0 + && (!_M_writing || _M_codecvt->always_noconv()); + + // Ditch any pback buffers to avoid confusion. + if (!__no_movement) + _M_destroy_pback(); + + // Correct state at destination. Note that this is the correct + // state for the current position during output, because + // codecvt::unshift() returns the state to the initial state. + // This is also the correct state at the end of the file because + // an unshift sequence should have been written at the end. + __state_type __state = _M_state_beg; + off_type __computed_off = __off * __width; + if (_M_reading && __way == ios_base::cur) + { + __state = _M_state_last; + __computed_off += _M_get_ext_pos(__state); + } + if (!__no_movement) + __ret = _M_seek(__computed_off, __way, __state); + else + { + if (_M_writing) + __computed_off = this->pptr() - this->pbase(); + + off_type __file_off = _M_file.seekoff(0, ios_base::cur); + if (__file_off != off_type(-1)) + { + __ret = __file_off + __computed_off; + __ret.state(__state); + } + } + } + return __ret; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 171. Strange seekpos() semantics due to joint position + // According to the resolution of DR 171, seekpos should ignore the last + // argument (of type openmode). + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + seekpos(pos_type __pos, ios_base::openmode) + { + pos_type __ret = pos_type(off_type(-1)); + if (this->is_open()) + { + // Ditch any pback buffers to avoid confusion. + _M_destroy_pback(); + __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state()); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state) + { + pos_type __ret = pos_type(off_type(-1)); + if (_M_terminate_output()) + { + off_type __file_off = _M_file.seekoff(__off, __way); + if (__file_off != off_type(-1)) + { + _M_reading = false; + _M_writing = false; + _M_ext_next = _M_ext_end = _M_ext_buf; + _M_set_buffer(-1); + _M_state_cur = __state; + __ret = __file_off; + __ret.state(_M_state_cur); + } + } + return __ret; + } + + // Returns the distance from the end of the ext buffer to the point + // corresponding to gptr(). This is a negative value. Updates __state + // from eback() correspondence to gptr(). + template + int basic_filebuf<_CharT, _Traits>:: + _M_get_ext_pos(__state_type& __state) + { + if (_M_codecvt->always_noconv()) + return this->gptr() - this->egptr(); + else + { + // Calculate offset from _M_ext_buf that corresponds to + // gptr(). Precondition: __state == _M_state_last, which + // corresponds to eback(). + const int __gptr_off = + _M_codecvt->length(__state, _M_ext_buf, _M_ext_next, + this->gptr() - this->eback()); + return _M_ext_buf + __gptr_off - _M_ext_end; + } + } + + template + bool + basic_filebuf<_CharT, _Traits>:: + _M_terminate_output() + { + // Part one: update the output sequence. + bool __testvalid = true; + if (this->pbase() < this->pptr()) + { + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __testvalid = false; + } + + // Part two: output unshift sequence. + if (_M_writing && !__check_facet(_M_codecvt).always_noconv() + && __testvalid) + { + // Note: this value is arbitrary, since there is no way to + // get the length of the unshift sequence from codecvt, + // without calling unshift. + const size_t __blen = 128; + char __buf[__blen]; + codecvt_base::result __r; + streamsize __ilen = 0; + + do + { + char* __next; + __r = _M_codecvt->unshift(_M_state_cur, __buf, + __buf + __blen, __next); + if (__r == codecvt_base::error) + __testvalid = false; + else if (__r == codecvt_base::ok || + __r == codecvt_base::partial) + { + __ilen = __next - __buf; + if (__ilen > 0) + { + const streamsize __elen = _M_file.xsputn(__buf, __ilen); + if (__elen != __ilen) + __testvalid = false; + } + } + } + while (__r == codecvt_base::partial && __ilen > 0 && __testvalid); + + if (__testvalid) + { + // This second call to overflow() is required by the standard, + // but it's not clear why it's needed, since the output buffer + // should be empty by this point (it should have been emptied + // in the first call to overflow()). + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __testvalid = false; + } + } + return __testvalid; + } + + template + int + basic_filebuf<_CharT, _Traits>:: + sync() + { + // Make sure that the internal buffer resyncs its idea of + // the file position with the external file. + int __ret = 0; + if (this->pbase() < this->pptr()) + { + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __ret = -1; + } + return __ret; + } + + template + void + basic_filebuf<_CharT, _Traits>:: + imbue(const locale& __loc) + { + bool __testvalid = true; + + const __codecvt_type* _M_codecvt_tmp = 0; + if (__builtin_expect(has_facet<__codecvt_type>(__loc), true)) + _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc); + + if (this->is_open()) + { + // encoding() == -1 is ok only at the beginning. + if ((_M_reading || _M_writing) + && __check_facet(_M_codecvt).encoding() == -1) + __testvalid = false; + else + { + if (_M_reading) + { + if (__check_facet(_M_codecvt).always_noconv()) + { + if (_M_codecvt_tmp + && !__check_facet(_M_codecvt_tmp).always_noconv()) + __testvalid = this->seekoff(0, ios_base::cur, _M_mode) + != pos_type(off_type(-1)); + } + else + { + // External position corresponding to gptr(). + _M_ext_next = _M_ext_buf + + _M_codecvt->length(_M_state_last, _M_ext_buf, + _M_ext_next, + this->gptr() - this->eback()); + const streamsize __remainder = _M_ext_end - _M_ext_next; + if (__remainder) + __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); + + _M_ext_next = _M_ext_buf; + _M_ext_end = _M_ext_buf + __remainder; + _M_set_buffer(-1); + _M_state_last = _M_state_cur = _M_state_beg; + } + } + else if (_M_writing && (__testvalid = _M_terminate_output())) + _M_set_buffer(-1); + } + } + + if (__testvalid) + _M_codecvt = _M_codecvt_tmp; + else + _M_codecvt = 0; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_filebuf; + extern template class basic_ifstream; + extern template class basic_ofstream; + extern template class basic_fstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_filebuf; + extern template class basic_ifstream; + extern template class basic_ofstream; + extern template class basic_fstream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..109ac525ae8029e7546974a7c6ef27895578ac53 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@fstream.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h new file mode 100644 index 0000000000000000000000000000000000000000..a78a17b2e049588418e05ae94380c7d5f1b06a3a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h @@ -0,0 +1,118 @@ +// Function-Based Exception Support -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/functexcept.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + * + * This header provides support for -fno-exceptions. + */ + +// +// ISO C++ 14882: 19.1 Exception classes +// + +#ifndef _FUNCTEXCEPT_H +#define _FUNCTEXCEPT_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Helper for exception objects in + void + __throw_bad_exception(void) __attribute__((__noreturn__)); + + // Helper for exception objects in + void + __throw_bad_alloc(void) __attribute__((__noreturn__)); + + void + __throw_bad_array_new_length(void) __attribute__((__noreturn__)); + + // Helper for exception objects in + void + __throw_bad_cast(void) __attribute__((__noreturn__)); + + void + __throw_bad_typeid(void) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_logic_error(const char*) __attribute__((__noreturn__)); + + void + __throw_domain_error(const char*) __attribute__((__noreturn__)); + + void + __throw_invalid_argument(const char*) __attribute__((__noreturn__)); + + void + __throw_length_error(const char*) __attribute__((__noreturn__)); + + void + __throw_out_of_range(const char*) __attribute__((__noreturn__)); + + void + __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__)) + __attribute__((__format__(__gnu_printf__, 1, 2))); + + void + __throw_runtime_error(const char*) __attribute__((__noreturn__)); + + void + __throw_range_error(const char*) __attribute__((__noreturn__)); + + void + __throw_overflow_error(const char*) __attribute__((__noreturn__)); + + void + __throw_underflow_error(const char*) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_ios_failure(const char*) __attribute__((__noreturn__)); + + void + __throw_ios_failure(const char*, int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_system_error(int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_future_error(int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_bad_function_call() __attribute__((__noreturn__)); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a8dba6e9c0023c34f31cf663def7dbc6b05f1d03 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functexcept.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h new file mode 100644 index 0000000000000000000000000000000000000000..c00113eff838283f509a798bf7beaaca7d314a4e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h @@ -0,0 +1,298 @@ +// functional_hash.h header -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/functional_hash.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _FUNCTIONAL_HASH_H +#define _FUNCTIONAL_HASH_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @defgroup hashes Hashes + * @ingroup functors + * + * Hashing functors taking a variable type and returning a @c std::size_t. + * + * @{ + */ + + template + struct __hash_base + { + typedef _Result result_type _GLIBCXX17_DEPRECATED; + typedef _Arg argument_type _GLIBCXX17_DEPRECATED; + }; + + /// Primary class template hash. + template + struct hash; + + template + struct __poison_hash + { + static constexpr bool __enable_hash_call = false; + private: + // Private rather than deleted to be non-trivially-copyable. + __poison_hash(__poison_hash&&); + ~__poison_hash(); + }; + + template + struct __poison_hash<_Tp, __void_t()(declval<_Tp>()))>> + { + static constexpr bool __enable_hash_call = true; + }; + + // Helper struct for SFINAE-poisoning non-enum types. + template::value> + struct __hash_enum + { + private: + // Private rather than deleted to be non-trivially-copyable. + __hash_enum(__hash_enum&&); + ~__hash_enum(); + }; + + // Helper struct for hash with enum types. + template + struct __hash_enum<_Tp, true> : public __hash_base + { + size_t + operator()(_Tp __val) const noexcept + { + using __type = typename underlying_type<_Tp>::type; + return hash<__type>{}(static_cast<__type>(__val)); + } + }; + + /// Primary class template hash, usable for enum types only. + // Use with non-enum types still SFINAES. + template + struct hash : __hash_enum<_Tp> + { }; + + /// Partial specializations for pointer types. + template + struct hash<_Tp*> : public __hash_base + { + size_t + operator()(_Tp* __p) const noexcept + { return reinterpret_cast(__p); } + }; + + // Explicit specializations for integer types. +#define _Cxx_hashtable_define_trivial_hash(_Tp) \ + template<> \ + struct hash<_Tp> : public __hash_base \ + { \ + size_t \ + operator()(_Tp __val) const noexcept \ + { return static_cast(__val); } \ + }; + + /// Explicit specialization for bool. + _Cxx_hashtable_define_trivial_hash(bool) + + /// Explicit specialization for char. + _Cxx_hashtable_define_trivial_hash(char) + + /// Explicit specialization for signed char. + _Cxx_hashtable_define_trivial_hash(signed char) + + /// Explicit specialization for unsigned char. + _Cxx_hashtable_define_trivial_hash(unsigned char) + + /// Explicit specialization for wchar_t. + _Cxx_hashtable_define_trivial_hash(wchar_t) + +#ifdef _GLIBCXX_USE_CHAR8_T + /// Explicit specialization for char8_t. + _Cxx_hashtable_define_trivial_hash(char8_t) +#endif + + /// Explicit specialization for char16_t. + _Cxx_hashtable_define_trivial_hash(char16_t) + + /// Explicit specialization for char32_t. + _Cxx_hashtable_define_trivial_hash(char32_t) + + /// Explicit specialization for short. + _Cxx_hashtable_define_trivial_hash(short) + + /// Explicit specialization for int. + _Cxx_hashtable_define_trivial_hash(int) + + /// Explicit specialization for long. + _Cxx_hashtable_define_trivial_hash(long) + + /// Explicit specialization for long long. + _Cxx_hashtable_define_trivial_hash(long long) + + /// Explicit specialization for unsigned short. + _Cxx_hashtable_define_trivial_hash(unsigned short) + + /// Explicit specialization for unsigned int. + _Cxx_hashtable_define_trivial_hash(unsigned int) + + /// Explicit specialization for unsigned long. + _Cxx_hashtable_define_trivial_hash(unsigned long) + + /// Explicit specialization for unsigned long long. + _Cxx_hashtable_define_trivial_hash(unsigned long long) + +#ifdef __GLIBCXX_TYPE_INT_N_0 + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0) + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1) + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2) + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3) + __extension__ + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned) +#endif + +#undef _Cxx_hashtable_define_trivial_hash + + struct _Hash_impl + { + static size_t + hash(const void* __ptr, size_t __clength, + size_t __seed = static_cast(0xc70f6907UL)) + { return _Hash_bytes(__ptr, __clength, __seed); } + + template + static size_t + hash(const _Tp& __val) + { return hash(&__val, sizeof(__val)); } + + template + static size_t + __hash_combine(const _Tp& __val, size_t __hash) + { return hash(&__val, sizeof(__val), __hash); } + }; + + // A hash function similar to FNV-1a (see PR59406 for how it differs). + struct _Fnv_hash_impl + { + static size_t + hash(const void* __ptr, size_t __clength, + size_t __seed = static_cast(2166136261UL)) + { return _Fnv_hash_bytes(__ptr, __clength, __seed); } + + template + static size_t + hash(const _Tp& __val) + { return hash(&__val, sizeof(__val)); } + + template + static size_t + __hash_combine(const _Tp& __val, size_t __hash) + { return hash(&__val, sizeof(__val), __hash); } + }; + + /// Specialization for float. + template<> + struct hash : public __hash_base + { + size_t + operator()(float __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0; + } + }; + + /// Specialization for double. + template<> + struct hash : public __hash_base + { + size_t + operator()(double __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0; + } + }; + + /// Specialization for long double. + template<> + struct hash + : public __hash_base + { + _GLIBCXX_PURE size_t + operator()(long double __val) const noexcept; + }; + +#if __cplusplus >= 201703L + template<> + struct hash : public __hash_base + { + size_t + operator()(nullptr_t) const noexcept + { return 0; } + }; +#endif + + /// @} group hashes + + // Hint about performance of hash functor. If not fast the hash-based + // containers will cache the hash code. + // Default behavior is to consider that hashers are fast unless specified + // otherwise. + template + struct __is_fast_hash : public std::true_type + { }; + + template<> + struct __is_fast_hash> : public std::false_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _FUNCTIONAL_HASH_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d4fe0e1fc2b7253ee439c8a962bd9df10706650f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@functional_hash.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h new file mode 100644 index 0000000000000000000000000000000000000000..6c09c056c9acc2d267965e1bafcc13627e877d69 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h @@ -0,0 +1,185 @@ +// The template and inlines for the -*- C++ -*- gslice class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/gslice.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _GSLICE_H +#define _GSLICE_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Class defining multi-dimensional subset of an array. + * + * The slice class represents a multi-dimensional subset of an array, + * specified by three parameter sets: start offset, size array, and stride + * array. The start offset is the index of the first element of the array + * that is part of the subset. The size and stride array describe each + * dimension of the slice. Size is the number of elements in that + * dimension, and stride is the distance in the array between successive + * elements in that dimension. Each dimension's size and stride is taken + * to begin at an array element described by the previous dimension. The + * size array and stride array must be the same size. + * + * For example, if you have offset==3, stride[0]==11, size[1]==3, + * stride[1]==3, then slice[0,0]==array[3], slice[0,1]==array[6], + * slice[0,2]==array[9], slice[1,0]==array[14], slice[1,1]==array[17], + * slice[1,2]==array[20]. + */ + class gslice + { + public: + /// Construct an empty slice. + gslice(); + + /** + * @brief Construct a slice. + * + * Constructs a slice with as many dimensions as the length of the @a l + * and @a s arrays. + * + * @param __o Offset in array of first element. + * @param __l Array of dimension lengths. + * @param __s Array of dimension strides between array elements. + */ + gslice(size_t __o, const valarray& __l, + const valarray& __s); + + // XXX: the IS says the copy-ctor and copy-assignment operators are + // synthesized by the compiler but they are just unsuitable + // for a ref-counted semantic + /// Copy constructor. + gslice(const gslice&); + + /// Destructor. + ~gslice(); + + // XXX: See the note above. + /// Assignment operator. + gslice& operator=(const gslice&); + + /// Return array offset of first slice element. + size_t start() const; + + /// Return array of sizes of slice dimensions. + valarray size() const; + + /// Return array of array strides for each dimension. + valarray stride() const; + + private: + struct _Indexer + { + size_t _M_count; + size_t _M_start; + valarray _M_size; + valarray _M_stride; + valarray _M_index; // Linear array of referenced indices + + _Indexer() + : _M_count(1), _M_start(0), _M_size(), _M_stride(), _M_index() {} + + _Indexer(size_t, const valarray&, + const valarray&); + + void + _M_increment_use() + { ++_M_count; } + + size_t + _M_decrement_use() + { return --_M_count; } + }; + + _Indexer* _M_index; + + template friend class valarray; + }; + + inline size_t + gslice::start() const + { return _M_index ? _M_index->_M_start : 0; } + + inline valarray + gslice::size() const + { return _M_index ? _M_index->_M_size : valarray(); } + + inline valarray + gslice::stride() const + { return _M_index ? _M_index->_M_stride : valarray(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 543. valarray slice default constructor + inline + gslice::gslice() + : _M_index(new gslice::_Indexer()) {} + + inline + gslice::gslice(size_t __o, const valarray& __l, + const valarray& __s) + : _M_index(new gslice::_Indexer(__o, __l, __s)) {} + + inline + gslice::gslice(const gslice& __g) + : _M_index(__g._M_index) + { if (_M_index) _M_index->_M_increment_use(); } + + inline + gslice::~gslice() + { + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + } + + inline gslice& + gslice::operator=(const gslice& __g) + { + if (__g._M_index) + __g._M_index->_M_increment_use(); + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + _M_index = __g._M_index; + return *this; + } + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GSLICE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bc741abb380892b55efaf806f49d10c939d3c868 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h new file mode 100644 index 0000000000000000000000000000000000000000..22413ce809b78bd412113a7b0043d624312e5f58 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h @@ -0,0 +1,223 @@ +// The template and inlines for the -*- C++ -*- gslice_array class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/gslice_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _GSLICE_ARRAY_H +#define _GSLICE_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to multi-dimensional subset of an array. + * + * A gslice_array is a reference to the actual elements of an array + * specified by a gslice. The way to get a gslice_array is to call + * operator[](gslice) on a valarray. The returned gslice_array then + * permits carrying operations out on the referenced subset of elements in + * the original valarray. For example, operator+=(valarray) will add + * values to the subset of elements in the underlying valarray this + * gslice_array refers to. + * + * @param Tp Element type. + */ + template + class gslice_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + gslice_array(const gslice_array&); + + /// Assignment operator. Assigns slice elements to corresponding + /// elements of @a a. + gslice_array& operator=(const gslice_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp&) const; + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + _Array<_Tp> _M_array; + const valarray& _M_index; + + friend class valarray<_Tp>; + + gslice_array(_Array<_Tp>, const valarray&); + +#if __cplusplus < 201103L + // not implemented + gslice_array(); +#else + public: + gslice_array() = delete; +#endif + }; + + template + inline + gslice_array<_Tp>::gslice_array(_Array<_Tp> __a, + const valarray& __i) + : _M_array(__a), _M_index(__i) {} + + template + inline + gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a) + : _M_array(__a._M_array), _M_index(__a._M_index) {} + + template + inline gslice_array<_Tp>& + gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a) + { + std::__valarray_copy(_Array<_Tp>(__a._M_array), + _Array(__a._M_index), _M_index.size(), + _M_array, _Array(_M_index)); + return *this; + } + + template + inline void + gslice_array<_Tp>::operator=(const _Tp& __t) const + { + std::__valarray_fill(_M_array, _Array(_M_index), + _M_index.size(), __t); + } + + template + inline void + gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { + std::__valarray_copy(_Array<_Tp>(__v), __v.size(), + _M_array, _Array(_M_index)); + } + + template + template + inline void + gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const + { + std::__valarray_copy (__e, _M_index.size(), _M_array, + _Array(_M_index)); + } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _Array(_M_index), \ + _Array<_Tp>(__v), __v.size()); \ + } \ + \ + template \ + template \ + inline void \ + gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _Array(_M_index), __e,\ + _M_index.size()); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GSLICE_ARRAY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..29ea5713a0215ee6bbb4a60b6a8fca258f421221 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@gslice_array.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h new file mode 100644 index 0000000000000000000000000000000000000000..dd4b9713abd078e27d2771422177e776e4b16b57 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h @@ -0,0 +1,59 @@ +// Declarations for hash functions. -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hash_bytes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _HASH_BYTES_H +#define _HASH_BYTES_H 1 + +#pragma GCC system_header + +#include + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Hash function implementation for the nontrivial specialization. + // All of them are based on a primitive that hashes a pointer to a + // byte array. The actual hash algorithm is not guaranteed to stay + // the same from release to release -- it may be updated or tuned to + // improve hash quality or speed. + size_t + _Hash_bytes(const void* __ptr, size_t __len, size_t __seed); + + // A similar hash primitive, using the FNV hash algorithm. This + // algorithm is guaranteed to stay the same from release to release. + // (although it might not produce the same values on different + // machines.) + size_t + _Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7d33385674f4611daaf0250988fe9b95e4ecdf86 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hash_bytes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h new file mode 100644 index 0000000000000000000000000000000000000000..edc151ef15b1d798e8bff29cd387cd54add0f9af --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h @@ -0,0 +1,2700 @@ +// hashtable.h header -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hashtable.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_map, unordered_set} + */ + +#ifndef _HASHTABLE_H +#define _HASHTABLE_H 1 + +#pragma GCC system_header + +#include +#include +#if __cplusplus > 201402L +# include +#endif +#include +#include // equal_to, _Identity, _Select1st + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +/// @cond undocumented + + template + using __cache_default + = __not_<__and_, + // Mandatory to have erase not throwing. + __is_nothrow_invocable>>; + + // Helper to conditionally delete the default constructor. + // The _Hash_node_base type is used to distinguish this specialization + // from any other potentially-overlapping subobjects of the hashtable. + template + using _Hashtable_enable_default_ctor + = _Enable_default_constructor<__and_, + is_default_constructible<_Hash>, + is_default_constructible<_Allocator>>{}, + __detail::_Hash_node_base>; + + /** + * Primary class template _Hashtable. + * + * @ingroup hashtable-detail + * + * @tparam _Value CopyConstructible type. + * + * @tparam _Key CopyConstructible type. + * + * @tparam _Alloc An allocator type + * ([lib.allocator.requirements]) whose _Alloc::value_type is + * _Value. As a conforming extension, we allow for + * _Alloc::value_type != _Value. + * + * @tparam _ExtractKey Function object that takes an object of type + * _Value and returns a value of type _Key. + * + * @tparam _Equal Function object that takes two objects of type k + * and returns a bool-like value that is true if the two objects + * are considered equal. + * + * @tparam _Hash The hash function. A unary function object with + * argument type _Key and result type size_t. Return values should + * be distributed over the entire range [0, numeric_limits:::max()]. + * + * @tparam _RangeHash The range-hashing function (in the terminology of + * Tavori and Dreizin). A binary function object whose argument + * types and result type are all size_t. Given arguments r and N, + * the return value is in the range [0, N). + * + * @tparam _Unused Not used. + * + * @tparam _RehashPolicy Policy class with three members, all of + * which govern the bucket count. _M_next_bkt(n) returns a bucket + * count no smaller than n. _M_bkt_for_elements(n) returns a + * bucket count appropriate for an element count of n. + * _M_need_rehash(n_bkt, n_elt, n_ins) determines whether, if the + * current bucket count is n_bkt and the current element count is + * n_elt, we need to increase the bucket count for n_ins insertions. + * If so, returns make_pair(true, n), where n is the new bucket count. If + * not, returns make_pair(false, ) + * + * @tparam _Traits Compile-time class with three boolean + * std::integral_constant members: __cache_hash_code, __constant_iterators, + * __unique_keys. + * + * Each _Hashtable data structure has: + * + * - _Bucket[] _M_buckets + * - _Hash_node_base _M_before_begin + * - size_type _M_bucket_count + * - size_type _M_element_count + * + * with _Bucket being _Hash_node_base* and _Hash_node containing: + * + * - _Hash_node* _M_next + * - Tp _M_value + * - size_t _M_hash_code if cache_hash_code is true + * + * In terms of Standard containers the hashtable is like the aggregation of: + * + * - std::forward_list<_Node> containing the elements + * - std::vector::iterator> representing the buckets + * + * The non-empty buckets contain the node before the first node in the + * bucket. This design makes it possible to implement something like a + * std::forward_list::insert_after on container insertion and + * std::forward_list::erase_after on container erase + * calls. _M_before_begin is equivalent to + * std::forward_list::before_begin. Empty buckets contain + * nullptr. Note that one of the non-empty buckets contains + * &_M_before_begin which is not a dereferenceable node so the + * node pointer in a bucket shall never be dereferenced, only its + * next node can be. + * + * Walking through a bucket's nodes requires a check on the hash code to + * see if each node is still in the bucket. Such a design assumes a + * quite efficient hash functor and is one of the reasons it is + * highly advisable to set __cache_hash_code to true. + * + * The container iterators are simply built from nodes. This way + * incrementing the iterator is perfectly efficient independent of + * how many empty buckets there are in the container. + * + * On insert we compute the element's hash code and use it to find the + * bucket index. If the element must be inserted in an empty bucket + * we add it at the beginning of the singly linked list and make the + * bucket point to _M_before_begin. The bucket that used to point to + * _M_before_begin, if any, is updated to point to its new before + * begin node. + * + * On erase, the simple iterator design requires using the hash + * functor to get the index of the bucket to update. For this + * reason, when __cache_hash_code is set to false the hash functor must + * not throw and this is enforced by a static assertion. + * + * Functionality is implemented by decomposition into base classes, + * where the derived _Hashtable class is used in _Map_base, + * _Insert, _Rehash_base, and _Equality base classes to access the + * "this" pointer. _Hashtable_base is used in the base classes as a + * non-recursive, fully-completed-type so that detailed nested type + * information, such as iterator type and node type, can be + * used. This is similar to the "Curiously Recurring Template + * Pattern" (CRTP) technique, but uses a reconstructed, not + * explicitly passed, template pattern. + * + * Base class templates are: + * - __detail::_Hashtable_base + * - __detail::_Map_base + * - __detail::_Insert + * - __detail::_Rehash_base + * - __detail::_Equality + */ + template + class _Hashtable + : public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _Traits>, + public __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + private __detail::_Hashtable_alloc< + __alloc_rebind<_Alloc, + __detail::_Hash_node<_Value, + _Traits::__hash_cached::value>>>, + private _Hashtable_enable_default_ctor<_Equal, _Hash, _Alloc> + { + static_assert(is_same::type, _Value>::value, + "unordered container must have a non-const, non-volatile value_type"); +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same{}, + "unordered container must have the same value_type as its allocator"); +#endif + + using __traits_type = _Traits; + using __hash_cached = typename __traits_type::__hash_cached; + using __constant_iterators = typename __traits_type::__constant_iterators; + using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>; + using __node_alloc_type = __alloc_rebind<_Alloc, __node_type>; + + using __hashtable_alloc = __detail::_Hashtable_alloc<__node_alloc_type>; + + using __node_value_type = + __detail::_Hash_node_value<_Value, __hash_cached::value>; + using __node_ptr = typename __hashtable_alloc::__node_ptr; + using __value_alloc_traits = + typename __hashtable_alloc::__value_alloc_traits; + using __node_alloc_traits = + typename __hashtable_alloc::__node_alloc_traits; + using __node_base = typename __hashtable_alloc::__node_base; + using __node_base_ptr = typename __hashtable_alloc::__node_base_ptr; + using __buckets_ptr = typename __hashtable_alloc::__buckets_ptr; + + using __insert_base = __detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, + _RangeHash, _Unused, + _RehashPolicy, _Traits>; + using __enable_default_ctor + = _Hashtable_enable_default_ctor<_Equal, _Hash, _Alloc>; + + public: + typedef _Key key_type; + typedef _Value value_type; + typedef _Alloc allocator_type; + typedef _Equal key_equal; + + // mapped_type, if present, comes from _Map_base. + // hasher, if present, comes from _Hash_code_base/_Hashtable_base. + typedef typename __value_alloc_traits::pointer pointer; + typedef typename __value_alloc_traits::const_pointer const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + using iterator = typename __insert_base::iterator; + + using const_iterator = typename __insert_base::const_iterator; + + using local_iterator = __detail::_Local_iterator; + + using const_local_iterator = __detail::_Local_const_iterator< + key_type, _Value, + _ExtractKey, _Hash, _RangeHash, _Unused, + __constant_iterators::value, __hash_cached::value>; + + private: + using __rehash_type = _RehashPolicy; + using __rehash_state = typename __rehash_type::_State; + + using __unique_keys = typename __traits_type::__unique_keys; + + using __hashtable_base = __detail:: + _Hashtable_base<_Key, _Value, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, _Traits>; + + using __hash_code_base = typename __hashtable_base::__hash_code_base; + using __hash_code = typename __hashtable_base::__hash_code; + using __ireturn_type = typename __insert_base::__ireturn_type; + + using __map_base = __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __rehash_base = __detail::_Rehash_base<_Key, _Value, _Alloc, + _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __eq_base = __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __reuse_or_alloc_node_gen_t = + __detail::_ReuseOrAllocNode<__node_alloc_type>; + using __alloc_node_gen_t = + __detail::_AllocNode<__node_alloc_type>; + using __node_builder_t = + __detail::_NodeBuilder<_ExtractKey>; + + // Simple RAII type for managing a node containing an element + struct _Scoped_node + { + // Take ownership of a node with a constructed element. + _Scoped_node(__node_ptr __n, __hashtable_alloc* __h) + : _M_h(__h), _M_node(__n) { } + + // Allocate a node and construct an element within it. + template + _Scoped_node(__hashtable_alloc* __h, _Args&&... __args) + : _M_h(__h), + _M_node(__h->_M_allocate_node(std::forward<_Args>(__args)...)) + { } + + // Destroy element and deallocate node. + ~_Scoped_node() { if (_M_node) _M_h->_M_deallocate_node(_M_node); }; + + _Scoped_node(const _Scoped_node&) = delete; + _Scoped_node& operator=(const _Scoped_node&) = delete; + + __hashtable_alloc* _M_h; + __node_ptr _M_node; + }; + + template + static constexpr + __conditional_t::value, + const value_type&, value_type&&> + __fwd_value_for(value_type& __val) noexcept + { return std::move(__val); } + + // Compile-time diagnostics. + + // _Hash_code_base has everything protected, so use this derived type to + // access it. + struct __hash_code_base_access : __hash_code_base + { using __hash_code_base::_M_bucket_index; }; + + // To get bucket index we need _RangeHash not to throw. + static_assert(is_nothrow_default_constructible<_RangeHash>::value, + "Functor used to map hash code to bucket index" + " must be nothrow default constructible"); + static_assert(noexcept( + std::declval()((std::size_t)0, (std::size_t)0)), + "Functor used to map hash code to bucket index must be" + " noexcept"); + + // To compute bucket index we also need _ExtratKey not to throw. + static_assert(is_nothrow_default_constructible<_ExtractKey>::value, + "_ExtractKey must be nothrow default constructible"); + static_assert(noexcept( + std::declval()(std::declval<_Value>())), + "_ExtractKey functor must be noexcept invocable"); + + template + friend struct __detail::_Map_base; + + template + friend struct __detail::_Insert_base; + + template + friend struct __detail::_Insert; + + template + friend struct __detail::_Equality; + + public: + using size_type = typename __hashtable_base::size_type; + using difference_type = typename __hashtable_base::difference_type; + +#if __cplusplus > 201402L + using node_type = _Node_handle<_Key, _Value, __node_alloc_type>; + using insert_return_type = _Node_insert_return; +#endif + + private: + __buckets_ptr _M_buckets = &_M_single_bucket; + size_type _M_bucket_count = 1; + __node_base _M_before_begin; + size_type _M_element_count = 0; + _RehashPolicy _M_rehash_policy; + + // A single bucket used when only need for 1 bucket. Especially + // interesting in move semantic to leave hashtable with only 1 bucket + // which is not allocated so that we can have those operations noexcept + // qualified. + // Note that we can't leave hashtable with 0 bucket without adding + // numerous checks in the code to avoid 0 modulus. + __node_base_ptr _M_single_bucket = nullptr; + + void + _M_update_bbegin() + { + if (_M_begin()) + _M_buckets[_M_bucket_index(*_M_begin())] = &_M_before_begin; + } + + void + _M_update_bbegin(__node_ptr __n) + { + _M_before_begin._M_nxt = __n; + _M_update_bbegin(); + } + + bool + _M_uses_single_bucket(__buckets_ptr __bkts) const + { return __builtin_expect(__bkts == &_M_single_bucket, false); } + + bool + _M_uses_single_bucket() const + { return _M_uses_single_bucket(_M_buckets); } + + static constexpr size_t + __small_size_threshold() noexcept + { + return + __detail::_Hashtable_hash_traits<_Hash>::__small_size_threshold(); + } + + __hashtable_alloc& + _M_base_alloc() { return *this; } + + __buckets_ptr + _M_allocate_buckets(size_type __bkt_count) + { + if (__builtin_expect(__bkt_count == 1, false)) + { + _M_single_bucket = nullptr; + return &_M_single_bucket; + } + + return __hashtable_alloc::_M_allocate_buckets(__bkt_count); + } + + void + _M_deallocate_buckets(__buckets_ptr __bkts, size_type __bkt_count) + { + if (_M_uses_single_bucket(__bkts)) + return; + + __hashtable_alloc::_M_deallocate_buckets(__bkts, __bkt_count); + } + + void + _M_deallocate_buckets() + { _M_deallocate_buckets(_M_buckets, _M_bucket_count); } + + // Gets bucket begin, deals with the fact that non-empty buckets contain + // their before begin node. + __node_ptr + _M_bucket_begin(size_type __bkt) const; + + __node_ptr + _M_begin() const + { return static_cast<__node_ptr>(_M_before_begin._M_nxt); } + + // Assign *this using another _Hashtable instance. Whether elements + // are copied or moved depends on the _Ht reference. + template + void + _M_assign_elements(_Ht&&); + + template + void + _M_assign(_Ht&&, const _NodeGenerator&); + + void + _M_move_assign(_Hashtable&&, true_type); + + void + _M_move_assign(_Hashtable&&, false_type); + + void + _M_reset() noexcept; + + _Hashtable(const _Hash& __h, const _Equal& __eq, + const allocator_type& __a) + : __hashtable_base(__h, __eq), + __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(_Enable_default_constructor_tag{}) + { } + + template + static constexpr bool + _S_nothrow_move() + { +#if __cplusplus <= 201402L + return __and_<__bool_constant<_No_realloc>, + is_nothrow_copy_constructible<_Hash>, + is_nothrow_copy_constructible<_Equal>>::value; +#else + if constexpr (_No_realloc) + if constexpr (is_nothrow_copy_constructible<_Hash>()) + return is_nothrow_copy_constructible<_Equal>(); + return false; +#endif + } + + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + true_type /* alloc always equal */) + noexcept(_S_nothrow_move()); + + _Hashtable(_Hashtable&&, __node_alloc_type&&, + false_type /* alloc always equal */); + + template + _Hashtable(_InputIterator __first, _InputIterator __last, + size_type __bkt_count_hint, + const _Hash&, const _Equal&, const allocator_type&, + true_type __uks); + + template + _Hashtable(_InputIterator __first, _InputIterator __last, + size_type __bkt_count_hint, + const _Hash&, const _Equal&, const allocator_type&, + false_type __uks); + + public: + // Constructor, destructor, assignment, swap + _Hashtable() = default; + + _Hashtable(const _Hashtable&); + + _Hashtable(const _Hashtable&, const allocator_type&); + + explicit + _Hashtable(size_type __bkt_count_hint, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()); + + // Use delegating constructors. + _Hashtable(_Hashtable&& __ht) + noexcept(_S_nothrow_move()) + : _Hashtable(std::move(__ht), std::move(__ht._M_node_allocator()), + true_type{}) + { } + + _Hashtable(_Hashtable&& __ht, const allocator_type& __a) + noexcept(_S_nothrow_move<__node_alloc_traits::_S_always_equal()>()) + : _Hashtable(std::move(__ht), __node_alloc_type(__a), + typename __node_alloc_traits::is_always_equal{}) + { } + + explicit + _Hashtable(const allocator_type& __a) + : __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(_Enable_default_constructor_tag{}) + { } + + template + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint = 0, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Hashtable(__f, __l, __bkt_count_hint, __hf, __eql, __a, + __unique_keys{}) + { } + + _Hashtable(initializer_list __l, + size_type __bkt_count_hint = 0, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Hashtable(__l.begin(), __l.end(), __bkt_count_hint, + __hf, __eql, __a, __unique_keys{}) + { } + + _Hashtable& + operator=(const _Hashtable& __ht); + + _Hashtable& + operator=(_Hashtable&& __ht) + noexcept(__node_alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Hash>::value + && is_nothrow_move_assignable<_Equal>::value) + { + constexpr bool __move_storage = + __node_alloc_traits::_S_propagate_on_move_assign() + || __node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__ht), __bool_constant<__move_storage>()); + return *this; + } + + _Hashtable& + operator=(initializer_list __l) + { + __reuse_or_alloc_node_gen_t __roan(_M_begin(), *this); + _M_before_begin._M_nxt = nullptr; + clear(); + + // We consider that all elements of __l are going to be inserted. + auto __l_bkt_count = _M_rehash_policy._M_bkt_for_elements(__l.size()); + + // Do not shrink to keep potential user reservation. + if (_M_bucket_count < __l_bkt_count) + rehash(__l_bkt_count); + + this->_M_insert_range(__l.begin(), __l.end(), __roan, __unique_keys{}); + return *this; + } + + ~_Hashtable() noexcept; + + void + swap(_Hashtable&) + noexcept(__and_<__is_nothrow_swappable<_Hash>, + __is_nothrow_swappable<_Equal>>::value); + + // Basic container operations + iterator + begin() noexcept + { return iterator(_M_begin()); } + + const_iterator + begin() const noexcept + { return const_iterator(_M_begin()); } + + iterator + end() noexcept + { return iterator(nullptr); } + + const_iterator + end() const noexcept + { return const_iterator(nullptr); } + + const_iterator + cbegin() const noexcept + { return const_iterator(_M_begin()); } + + const_iterator + cend() const noexcept + { return const_iterator(nullptr); } + + size_type + size() const noexcept + { return _M_element_count; } + + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return size() == 0; } + + allocator_type + get_allocator() const noexcept + { return allocator_type(this->_M_node_allocator()); } + + size_type + max_size() const noexcept + { return __node_alloc_traits::max_size(this->_M_node_allocator()); } + + // Observers + key_equal + key_eq() const + { return this->_M_eq(); } + + // hash_function, if present, comes from _Hash_code_base. + + // Bucket operations + size_type + bucket_count() const noexcept + { return _M_bucket_count; } + + size_type + max_bucket_count() const noexcept + { return max_size(); } + + size_type + bucket_size(size_type __bkt) const + { return std::distance(begin(__bkt), end(__bkt)); } + + size_type + bucket(const key_type& __k) const + { return _M_bucket_index(this->_M_hash_code(__k)); } + + local_iterator + begin(size_type __bkt) + { + return local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + local_iterator + end(size_type __bkt) + { return local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + const_local_iterator + begin(size_type __bkt) const + { + return const_local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + const_local_iterator + end(size_type __bkt) const + { return const_local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + // DR 691. + const_local_iterator + cbegin(size_type __bkt) const + { + return const_local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + const_local_iterator + cend(size_type __bkt) const + { return const_local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + float + load_factor() const noexcept + { + return static_cast(size()) / static_cast(bucket_count()); + } + + // max_load_factor, if present, comes from _Rehash_base. + + // Generalization of max_load_factor. Extension, not found in + // TR1. Only useful if _RehashPolicy is something other than + // the default. + const _RehashPolicy& + __rehash_policy() const + { return _M_rehash_policy; } + + void + __rehash_policy(const _RehashPolicy& __pol) + { _M_rehash_policy = __pol; } + + // Lookup. + iterator + find(const key_type& __k); + + const_iterator + find(const key_type& __k) const; + + size_type + count(const key_type& __k) const; + + std::pair + equal_range(const key_type& __k); + + std::pair + equal_range(const key_type& __k) const; + +#if __cplusplus >= 202002L +#define __cpp_lib_generic_unordered_lookup 201811L + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + iterator + _M_find_tr(const _Kt& __k); + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + const_iterator + _M_find_tr(const _Kt& __k) const; + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + size_type + _M_count_tr(const _Kt& __k) const; + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + pair + _M_equal_range_tr(const _Kt& __k); + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + pair + _M_equal_range_tr(const _Kt& __k) const; +#endif // C++20 + + private: + // Bucket index computation helpers. + size_type + _M_bucket_index(const __node_value_type& __n) const noexcept + { return __hash_code_base::_M_bucket_index(__n, _M_bucket_count); } + + size_type + _M_bucket_index(__hash_code __c) const + { return __hash_code_base::_M_bucket_index(__c, _M_bucket_count); } + + __node_base_ptr + _M_find_before_node(const key_type&); + + // Find and insert helper functions and types + // Find the node before the one matching the criteria. + __node_base_ptr + _M_find_before_node(size_type, const key_type&, __hash_code) const; + + template + __node_base_ptr + _M_find_before_node_tr(size_type, const _Kt&, __hash_code) const; + + __node_ptr + _M_find_node(size_type __bkt, const key_type& __key, + __hash_code __c) const + { + __node_base_ptr __before_n = _M_find_before_node(__bkt, __key, __c); + if (__before_n) + return static_cast<__node_ptr>(__before_n->_M_nxt); + return nullptr; + } + + template + __node_ptr + _M_find_node_tr(size_type __bkt, const _Kt& __key, + __hash_code __c) const + { + auto __before_n = _M_find_before_node_tr(__bkt, __key, __c); + if (__before_n) + return static_cast<__node_ptr>(__before_n->_M_nxt); + return nullptr; + } + + // Insert a node at the beginning of a bucket. + void + _M_insert_bucket_begin(size_type, __node_ptr); + + // Remove the bucket first node + void + _M_remove_bucket_begin(size_type __bkt, __node_ptr __next_n, + size_type __next_bkt); + + // Get the node before __n in the bucket __bkt + __node_base_ptr + _M_get_previous_node(size_type __bkt, __node_ptr __n); + + pair + _M_compute_hash_code(const_iterator __hint, const key_type& __k) const; + + // Insert node __n with hash code __code, in bucket __bkt if no + // rehash (assumes no element with same key already present). + // Takes ownership of __n if insertion succeeds, throws otherwise. + iterator + _M_insert_unique_node(size_type __bkt, __hash_code, + __node_ptr __n, size_type __n_elt = 1); + + // Insert node __n with key __k and hash code __code. + // Takes ownership of __n if insertion succeeds, throws otherwise. + iterator + _M_insert_multi_node(__node_ptr __hint, + __hash_code __code, __node_ptr __n); + + template + std::pair + _M_emplace(true_type __uks, _Args&&... __args); + + template + iterator + _M_emplace(false_type __uks, _Args&&... __args) + { return _M_emplace(cend(), __uks, std::forward<_Args>(__args)...); } + + // Emplace with hint, useless when keys are unique. + template + iterator + _M_emplace(const_iterator, true_type __uks, _Args&&... __args) + { return _M_emplace(__uks, std::forward<_Args>(__args)...).first; } + + template + iterator + _M_emplace(const_iterator, false_type __uks, _Args&&... __args); + + template + std::pair + _M_insert_unique(_Kt&&, _Arg&&, const _NodeGenerator&); + + template + static __conditional_t< + __and_<__is_nothrow_invocable<_Hash&, const key_type&>, + __not_<__is_nothrow_invocable<_Hash&, _Kt>>>::value, + key_type, _Kt&&> + _S_forward_key(_Kt&& __k) + { return std::forward<_Kt>(__k); } + + static const key_type& + _S_forward_key(const key_type& __k) + { return __k; } + + static key_type&& + _S_forward_key(key_type&& __k) + { return std::move(__k); } + + template + std::pair + _M_insert(_Arg&& __arg, const _NodeGenerator& __node_gen, + true_type /* __uks */) + { + return _M_insert_unique( + _S_forward_key(_ExtractKey{}(std::forward<_Arg>(__arg))), + std::forward<_Arg>(__arg), __node_gen); + } + + template + iterator + _M_insert(_Arg&& __arg, const _NodeGenerator& __node_gen, + false_type __uks) + { + return _M_insert(cend(), std::forward<_Arg>(__arg), __node_gen, + __uks); + } + + // Insert with hint, not used when keys are unique. + template + iterator + _M_insert(const_iterator, _Arg&& __arg, + const _NodeGenerator& __node_gen, true_type __uks) + { + return + _M_insert(std::forward<_Arg>(__arg), __node_gen, __uks).first; + } + + // Insert with hint when keys are not unique. + template + iterator + _M_insert(const_iterator, _Arg&&, + const _NodeGenerator&, false_type __uks); + + size_type + _M_erase(true_type __uks, const key_type&); + + size_type + _M_erase(false_type __uks, const key_type&); + + iterator + _M_erase(size_type __bkt, __node_base_ptr __prev_n, __node_ptr __n); + + public: + // Emplace + template + __ireturn_type + emplace(_Args&&... __args) + { return _M_emplace(__unique_keys{}, std::forward<_Args>(__args)...); } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + return _M_emplace(__hint, __unique_keys{}, + std::forward<_Args>(__args)...); + } + + // Insert member functions via inheritance. + + // Erase + iterator + erase(const_iterator); + + // LWG 2059. + iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + size_type + erase(const key_type& __k) + { return _M_erase(__unique_keys{}, __k); } + + iterator + erase(const_iterator, const_iterator); + + void + clear() noexcept; + + // Set number of buckets keeping it appropriate for container's number + // of elements. + void rehash(size_type __bkt_count); + + // DR 1189. + // reserve, if present, comes from _Rehash_base. + +#if __cplusplus > 201402L + /// Re-insert an extracted node into a container with unique keys. + insert_return_type + _M_reinsert_node(node_type&& __nh) + { + insert_return_type __ret; + if (__nh.empty()) + __ret.position = end(); + else + { + __glibcxx_assert(get_allocator() == __nh.get_allocator()); + + const key_type& __k = __nh._M_key(); + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + if (__node_ptr __n = _M_find_node(__bkt, __k, __code)) + { + __ret.node = std::move(__nh); + __ret.position = iterator(__n); + __ret.inserted = false; + } + else + { + __ret.position + = _M_insert_unique_node(__bkt, __code, __nh._M_ptr); + __nh._M_ptr = nullptr; + __ret.inserted = true; + } + } + return __ret; + } + + /// Re-insert an extracted node into a container with equivalent keys. + iterator + _M_reinsert_node_multi(const_iterator __hint, node_type&& __nh) + { + if (__nh.empty()) + return end(); + + __glibcxx_assert(get_allocator() == __nh.get_allocator()); + + const key_type& __k = __nh._M_key(); + auto __code = this->_M_hash_code(__k); + auto __ret + = _M_insert_multi_node(__hint._M_cur, __code, __nh._M_ptr); + __nh._M_ptr = nullptr; + return __ret; + } + + private: + node_type + _M_extract_node(size_t __bkt, __node_base_ptr __prev_n) + { + __node_ptr __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n->_M_next(), + __n->_M_nxt ? _M_bucket_index(*__n->_M_next()) : 0); + else if (__n->_M_nxt) + { + size_type __next_bkt = _M_bucket_index(*__n->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __prev_n; + } + + __prev_n->_M_nxt = __n->_M_nxt; + __n->_M_nxt = nullptr; + --_M_element_count; + return { __n, this->_M_node_allocator() }; + } + + public: + // Extract a node. + node_type + extract(const_iterator __pos) + { + size_t __bkt = _M_bucket_index(*__pos._M_cur); + return _M_extract_node(__bkt, + _M_get_previous_node(__bkt, __pos._M_cur)); + } + + /// Extract a node. + node_type + extract(const _Key& __k) + { + node_type __nh; + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + if (__node_base_ptr __prev_node = _M_find_before_node(__bkt, __k, __code)) + __nh = _M_extract_node(__bkt, __prev_node); + return __nh; + } + + /// Merge from a compatible container into one with unique keys. + template + void + _M_merge_unique(_Compatible_Hashtable& __src) + { + static_assert(is_same_v, "Node types are compatible"); + __glibcxx_assert(get_allocator() == __src.get_allocator()); + + auto __n_elt = __src.size(); + for (auto __i = __src.cbegin(), __end = __src.cend(); __i != __end;) + { + auto __pos = __i++; + const key_type& __k = _ExtractKey{}(*__pos); + __hash_code __code + = this->_M_hash_code(__src.hash_function(), *__pos._M_cur); + size_type __bkt = _M_bucket_index(__code); + if (_M_find_node(__bkt, __k, __code) == nullptr) + { + auto __nh = __src.extract(__pos); + _M_insert_unique_node(__bkt, __code, __nh._M_ptr, __n_elt); + __nh._M_ptr = nullptr; + __n_elt = 1; + } + else if (__n_elt != 1) + --__n_elt; + } + } + + /// Merge from a compatible container into one with equivalent keys. + template + void + _M_merge_multi(_Compatible_Hashtable& __src) + { + static_assert(is_same_v, "Node types are compatible"); + __glibcxx_assert(get_allocator() == __src.get_allocator()); + + __node_ptr __hint = nullptr; + this->reserve(size() + __src.size()); + for (auto __i = __src.cbegin(), __end = __src.cend(); __i != __end;) + { + auto __pos = __i++; + __hash_code __code + = this->_M_hash_code(__src.hash_function(), *__pos._M_cur); + auto __nh = __src.extract(__pos); + __hint = _M_insert_multi_node(__hint, __code, __nh._M_ptr)._M_cur; + __nh._M_ptr = nullptr; + } + } +#endif // C++17 + + private: + // Helper rehash method used when keys are unique. + void _M_rehash_aux(size_type __bkt_count, true_type __uks); + + // Helper rehash method used when keys can be non-unique. + void _M_rehash_aux(size_type __bkt_count, false_type __uks); + + // Unconditionally change size of bucket array to n, restore + // hash policy state to __state on exception. + void _M_rehash(size_type __bkt_count, const __rehash_state& __state); + }; + + // Definitions of class template _Hashtable's out-of-line member functions. + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_bucket_begin(size_type __bkt) const + -> __node_ptr + { + __node_base_ptr __n = _M_buckets[__bkt]; + return __n ? static_cast<__node_ptr>(__n->_M_nxt) : nullptr; + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, const allocator_type& __a) + : _Hashtable(__h, __eq, __a) + { + auto __bkt_count = _M_rehash_policy._M_next_bkt(__bkt_count_hint); + if (__bkt_count > _M_bucket_count) + { + _M_buckets = _M_allocate_buckets(__bkt_count); + _M_bucket_count = __bkt_count; + } + } + + template + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, + const allocator_type& __a, true_type /* __uks */) + : _Hashtable(__bkt_count_hint, __h, __eq, __a) + { + for (; __f != __l; ++__f) + this->insert(*__f); + } + + template + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, + const allocator_type& __a, false_type /* __uks */) + : _Hashtable(__h, __eq, __a) + { + auto __nb_elems = __detail::__distance_fw(__f, __l); + auto __bkt_count = + _M_rehash_policy._M_next_bkt( + std::max(_M_rehash_policy._M_bkt_for_elements(__nb_elems), + __bkt_count_hint)); + + if (__bkt_count > _M_bucket_count) + { + _M_buckets = _M_allocate_buckets(__bkt_count); + _M_bucket_count = __bkt_count; + } + + for (; __f != __l; ++__f) + this->insert(*__f); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + operator=(const _Hashtable& __ht) + -> _Hashtable& + { + if (&__ht == this) + return *this; + + if (__node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_node_allocator(); + auto& __that_alloc = __ht._M_node_allocator(); + if (!__node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // Replacement allocator cannot free existing storage. + this->_M_deallocate_nodes(_M_begin()); + _M_before_begin._M_nxt = nullptr; + _M_deallocate_buckets(); + _M_buckets = nullptr; + std::__alloc_on_copy(__this_alloc, __that_alloc); + __hashtable_base::operator=(__ht); + _M_bucket_count = __ht._M_bucket_count; + _M_element_count = __ht._M_element_count; + _M_rehash_policy = __ht._M_rehash_policy; + __alloc_node_gen_t __alloc_node_gen(*this); + __try + { + _M_assign(__ht, __alloc_node_gen); + } + __catch(...) + { + // _M_assign took care of deallocating all memory. Now we + // must make sure this instance remains in a usable state. + _M_reset(); + __throw_exception_again; + } + return *this; + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + + // Reuse allocated buckets and nodes. + _M_assign_elements(__ht); + return *this; + } + + template + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_assign_elements(_Ht&& __ht) + { + __buckets_ptr __former_buckets = nullptr; + std::size_t __former_bucket_count = _M_bucket_count; + const __rehash_state& __former_state = _M_rehash_policy._M_state(); + + if (_M_bucket_count != __ht._M_bucket_count) + { + __former_buckets = _M_buckets; + _M_buckets = _M_allocate_buckets(__ht._M_bucket_count); + _M_bucket_count = __ht._M_bucket_count; + } + else + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + + __try + { + __hashtable_base::operator=(std::forward<_Ht>(__ht)); + _M_element_count = __ht._M_element_count; + _M_rehash_policy = __ht._M_rehash_policy; + __reuse_or_alloc_node_gen_t __roan(_M_begin(), *this); + _M_before_begin._M_nxt = nullptr; + _M_assign(std::forward<_Ht>(__ht), __roan); + if (__former_buckets) + _M_deallocate_buckets(__former_buckets, __former_bucket_count); + } + __catch(...) + { + if (__former_buckets) + { + // Restore previous buckets. + _M_deallocate_buckets(); + _M_rehash_policy._M_reset(__former_state); + _M_buckets = __former_buckets; + _M_bucket_count = __former_bucket_count; + } + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + __throw_exception_again; + } + } + + template + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_assign(_Ht&& __ht, const _NodeGenerator& __node_gen) + { + __buckets_ptr __buckets = nullptr; + if (!_M_buckets) + _M_buckets = __buckets = _M_allocate_buckets(_M_bucket_count); + + __try + { + if (!__ht._M_before_begin._M_nxt) + return; + + // First deal with the special first node pointed to by + // _M_before_begin. + __node_ptr __ht_n = __ht._M_begin(); + __node_ptr __this_n + = __node_gen(__fwd_value_for<_Ht>(__ht_n->_M_v())); + this->_M_copy_code(*__this_n, *__ht_n); + _M_update_bbegin(__this_n); + + // Then deal with other nodes. + __node_ptr __prev_n = __this_n; + for (__ht_n = __ht_n->_M_next(); __ht_n; __ht_n = __ht_n->_M_next()) + { + __this_n = __node_gen(__fwd_value_for<_Ht>(__ht_n->_M_v())); + __prev_n->_M_nxt = __this_n; + this->_M_copy_code(*__this_n, *__ht_n); + size_type __bkt = _M_bucket_index(*__this_n); + if (!_M_buckets[__bkt]) + _M_buckets[__bkt] = __prev_n; + __prev_n = __this_n; + } + } + __catch(...) + { + clear(); + if (__buckets) + _M_deallocate_buckets(); + __throw_exception_again; + } + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_reset() noexcept + { + _M_rehash_policy._M_reset(); + _M_bucket_count = 1; + _M_single_bucket = nullptr; + _M_buckets = &_M_single_bucket; + _M_before_begin._M_nxt = nullptr; + _M_element_count = 0; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_move_assign(_Hashtable&& __ht, true_type) + { + if (__builtin_expect(std::__addressof(__ht) == this, false)) + return; + + this->_M_deallocate_nodes(_M_begin()); + _M_deallocate_buckets(); + __hashtable_base::operator=(std::move(__ht)); + _M_rehash_policy = __ht._M_rehash_policy; + if (!__ht._M_uses_single_bucket()) + _M_buckets = __ht._M_buckets; + else + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + + _M_bucket_count = __ht._M_bucket_count; + _M_before_begin._M_nxt = __ht._M_before_begin._M_nxt; + _M_element_count = __ht._M_element_count; + std::__alloc_on_move(this->_M_node_allocator(), __ht._M_node_allocator()); + + // Fix bucket containing the _M_before_begin pointer that can't be moved. + _M_update_bbegin(); + __ht._M_reset(); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_move_assign(_Hashtable&& __ht, false_type) + { + if (__ht._M_node_allocator() == this->_M_node_allocator()) + _M_move_assign(std::move(__ht), true_type{}); + else + { + // Can't move memory, move elements then. + _M_assign_elements(std::move(__ht)); + __ht.clear(); + } + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(const _Hashtable& __ht) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc( + __node_alloc_traits::_S_select_on_copy(__ht._M_node_allocator())), + __enable_default_ctor(__ht), + _M_buckets(nullptr), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + __alloc_node_gen_t __alloc_node_gen(*this); + _M_assign(__ht, __alloc_node_gen); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + true_type /* alloc always equal */) + noexcept(_S_nothrow_move()) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(std::move(__a)), + __enable_default_ctor(__ht), + _M_buckets(__ht._M_buckets), + _M_bucket_count(__ht._M_bucket_count), + _M_before_begin(__ht._M_before_begin._M_nxt), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + // Update buckets if __ht is using its single bucket. + if (__ht._M_uses_single_bucket()) + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + + // Fix bucket containing the _M_before_begin pointer that can't be moved. + _M_update_bbegin(); + + __ht._M_reset(); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(const _Hashtable& __ht, const allocator_type& __a) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(__ht), + _M_buckets(), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + __alloc_node_gen_t __alloc_node_gen(*this); + _M_assign(__ht, __alloc_node_gen); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + false_type /* alloc always equal */) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(std::move(__a)), + __enable_default_ctor(__ht), + _M_buckets(nullptr), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + if (__ht._M_node_allocator() == this->_M_node_allocator()) + { + if (__ht._M_uses_single_bucket()) + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + else + _M_buckets = __ht._M_buckets; + + // Fix bucket containing the _M_before_begin pointer that can't be + // moved. + _M_update_bbegin(__ht._M_begin()); + + __ht._M_reset(); + } + else + { + __alloc_node_gen_t __alloc_gen(*this); + + using _Fwd_Ht = __conditional_t< + __move_if_noexcept_cond::value, + const _Hashtable&, _Hashtable&&>; + _M_assign(std::forward<_Fwd_Ht>(__ht), __alloc_gen); + __ht.clear(); + } + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + ~_Hashtable() noexcept + { + // Getting a bucket index from a node shall not throw because it is used + // in methods (erase, swap...) that shall not throw. Need a complete + // type to check this, so do it in the destructor not at class scope. + static_assert(noexcept(declval() + ._M_bucket_index(declval(), + (std::size_t)0)), + "Cache the hash code or qualify your functors involved" + " in hash code and bucket index computation with noexcept"); + + clear(); + _M_deallocate_buckets(); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + swap(_Hashtable& __x) + noexcept(__and_<__is_nothrow_swappable<_Hash>, + __is_nothrow_swappable<_Equal>>::value) + { + // The only base class with member variables is hash_code_base. + // We define _Hash_code_base::_M_swap because different + // specializations have different members. + this->_M_swap(__x); + + std::__alloc_on_swap(this->_M_node_allocator(), __x._M_node_allocator()); + std::swap(_M_rehash_policy, __x._M_rehash_policy); + + // Deal properly with potentially moved instances. + if (this->_M_uses_single_bucket()) + { + if (!__x._M_uses_single_bucket()) + { + _M_buckets = __x._M_buckets; + __x._M_buckets = &__x._M_single_bucket; + } + } + else if (__x._M_uses_single_bucket()) + { + __x._M_buckets = _M_buckets; + _M_buckets = &_M_single_bucket; + } + else + std::swap(_M_buckets, __x._M_buckets); + + std::swap(_M_bucket_count, __x._M_bucket_count); + std::swap(_M_before_begin._M_nxt, __x._M_before_begin._M_nxt); + std::swap(_M_element_count, __x._M_element_count); + std::swap(_M_single_bucket, __x._M_single_bucket); + + // Fix buckets containing the _M_before_begin pointers that can't be + // swapped. + _M_update_bbegin(); + __x._M_update_bbegin(); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + find(const key_type& __k) + -> iterator + { + if (size() <= __small_size_threshold()) + { + for (auto __it = begin(); __it != end(); ++__it) + if (this->_M_key_equals(__k, *__it._M_cur)) + return __it; + return end(); + } + + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + return iterator(_M_find_node(__bkt, __k, __code)); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + find(const key_type& __k) const + -> const_iterator + { + if (size() <= __small_size_threshold()) + { + for (auto __it = begin(); __it != end(); ++__it) + if (this->_M_key_equals(__k, *__it._M_cur)) + return __it; + return end(); + } + + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + return const_iterator(_M_find_node(__bkt, __k, __code)); + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_tr(const _Kt& __k) + -> iterator + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + return iterator(_M_find_node_tr(__bkt, __k, __code)); + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_tr(const _Kt& __k) const + -> const_iterator + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + return const_iterator(_M_find_node_tr(__bkt, __k, __code)); + } +#endif + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + count(const key_type& __k) const + -> size_type + { + auto __it = find(__k); + if (!__it._M_cur) + return 0; + + if (__unique_keys::value) + return 1; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + size_type __result = 1; + for (auto __ref = __it++; + __it._M_cur && this->_M_node_equals(*__ref._M_cur, *__it._M_cur); + ++__it) + ++__result; + + return __result; + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_count_tr(const _Kt& __k) const + -> size_type + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + if (!__n) + return 0; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + iterator __it(__n); + size_type __result = 1; + for (++__it; + __it._M_cur && this->_M_equals_tr(__k, __code, *__it._M_cur); + ++__it) + ++__result; + + return __result; + } +#endif + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + equal_range(const key_type& __k) + -> pair + { + auto __ite = find(__k); + if (!__ite._M_cur) + return { __ite, __ite }; + + auto __beg = __ite++; + if (__unique_keys::value) + return { __beg, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + while (__ite._M_cur && this->_M_node_equals(*__beg._M_cur, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + equal_range(const key_type& __k) const + -> pair + { + auto __ite = find(__k); + if (!__ite._M_cur) + return { __ite, __ite }; + + auto __beg = __ite++; + if (__unique_keys::value) + return { __beg, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + while (__ite._M_cur && this->_M_node_equals(*__beg._M_cur, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_equal_range_tr(const _Kt& __k) + -> pair + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + iterator __ite(__n); + if (!__n) + return { __ite, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + auto __beg = __ite++; + while (__ite._M_cur && this->_M_equals_tr(__k, __code, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_equal_range_tr(const _Kt& __k) const + -> pair + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + const_iterator __ite(__n); + if (!__n) + return { __ite, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + auto __beg = __ite++; + while (__ite._M_cur && this->_M_equals_tr(__k, __code, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } +#endif + + // Find the node before the one whose key compares equal to k. + // Return nullptr if no node is found. + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_before_node(const key_type& __k) + -> __node_base_ptr + { + __node_base_ptr __prev_p = &_M_before_begin; + if (!__prev_p->_M_nxt) + return nullptr; + + for (__node_ptr __p = static_cast<__node_ptr>(__prev_p->_M_nxt); + __p != nullptr; + __p = __p->_M_next()) + { + if (this->_M_key_equals(__k, *__p)) + return __prev_p; + + __prev_p = __p; + } + + return nullptr; + } + + // Find the node before the one whose key compares equal to k in the bucket + // bkt. Return nullptr if no node is found. + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_before_node(size_type __bkt, const key_type& __k, + __hash_code __code) const + -> __node_base_ptr + { + __node_base_ptr __prev_p = _M_buckets[__bkt]; + if (!__prev_p) + return nullptr; + + for (__node_ptr __p = static_cast<__node_ptr>(__prev_p->_M_nxt);; + __p = __p->_M_next()) + { + if (this->_M_equals(__k, __code, *__p)) + return __prev_p; + + if (!__p->_M_nxt || _M_bucket_index(*__p->_M_next()) != __bkt) + break; + __prev_p = __p; + } + + return nullptr; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_before_node_tr(size_type __bkt, const _Kt& __k, + __hash_code __code) const + -> __node_base_ptr + { + __node_base_ptr __prev_p = _M_buckets[__bkt]; + if (!__prev_p) + return nullptr; + + for (__node_ptr __p = static_cast<__node_ptr>(__prev_p->_M_nxt);; + __p = __p->_M_next()) + { + if (this->_M_equals_tr(__k, __code, *__p)) + return __prev_p; + + if (!__p->_M_nxt || _M_bucket_index(*__p->_M_next()) != __bkt) + break; + __prev_p = __p; + } + + return nullptr; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_bucket_begin(size_type __bkt, __node_ptr __node) + { + if (_M_buckets[__bkt]) + { + // Bucket is not empty, we just need to insert the new node + // after the bucket before begin. + __node->_M_nxt = _M_buckets[__bkt]->_M_nxt; + _M_buckets[__bkt]->_M_nxt = __node; + } + else + { + // The bucket is empty, the new node is inserted at the + // beginning of the singly-linked list and the bucket will + // contain _M_before_begin pointer. + __node->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __node; + + if (__node->_M_nxt) + // We must update former begin bucket that is pointing to + // _M_before_begin. + _M_buckets[_M_bucket_index(*__node->_M_next())] = __node; + + _M_buckets[__bkt] = &_M_before_begin; + } + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_remove_bucket_begin(size_type __bkt, __node_ptr __next, + size_type __next_bkt) + { + if (!__next || __next_bkt != __bkt) + { + // Bucket is now empty + // First update next bucket if any + if (__next) + _M_buckets[__next_bkt] = _M_buckets[__bkt]; + + // Second update before begin node if necessary + if (&_M_before_begin == _M_buckets[__bkt]) + _M_before_begin._M_nxt = __next; + _M_buckets[__bkt] = nullptr; + } + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_get_previous_node(size_type __bkt, __node_ptr __n) + -> __node_base_ptr + { + __node_base_ptr __prev_n = _M_buckets[__bkt]; + while (__prev_n->_M_nxt != __n) + __prev_n = __prev_n->_M_nxt; + return __prev_n; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_emplace(true_type /* __uks */, _Args&&... __args) + -> pair + { + // First build the node to get access to the hash code + _Scoped_node __node { this, std::forward<_Args>(__args)... }; + const key_type& __k = _ExtractKey{}(__node._M_node->_M_v()); + if (size() <= __small_size_threshold()) + { + for (auto __it = begin(); __it != end(); ++__it) + if (this->_M_key_equals(__k, *__it._M_cur)) + // There is already an equivalent node, no insertion + return { __it, false }; + } + + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + if (size() > __small_size_threshold()) + if (__node_ptr __p = _M_find_node(__bkt, __k, __code)) + // There is already an equivalent node, no insertion + return { iterator(__p), false }; + + // Insert the node + auto __pos = _M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __pos, true }; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_emplace(const_iterator __hint, false_type /* __uks */, + _Args&&... __args) + -> iterator + { + // First build the node to get its hash code. + _Scoped_node __node { this, std::forward<_Args>(__args)... }; + const key_type& __k = _ExtractKey{}(__node._M_node->_M_v()); + + auto __res = this->_M_compute_hash_code(__hint, __k); + auto __pos + = _M_insert_multi_node(__res.first._M_cur, __res.second, + __node._M_node); + __node._M_node = nullptr; + return __pos; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_compute_hash_code(const_iterator __hint, const key_type& __k) const + -> pair + { + if (size() <= __small_size_threshold()) + { + if (__hint != cend()) + { + for (auto __it = __hint; __it != cend(); ++__it) + if (this->_M_key_equals(__k, *__it._M_cur)) + return { __it, this->_M_hash_code(*__it._M_cur) }; + } + + for (auto __it = cbegin(); __it != __hint; ++__it) + if (this->_M_key_equals(__k, *__it._M_cur)) + return { __it, this->_M_hash_code(*__it._M_cur) }; + } + + return { __hint, this->_M_hash_code(__k) }; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_unique_node(size_type __bkt, __hash_code __code, + __node_ptr __node, size_type __n_elt) + -> iterator + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, + __n_elt); + + if (__do_rehash.first) + { + _M_rehash(__do_rehash.second, __saved_state); + __bkt = _M_bucket_index(__code); + } + + this->_M_store_code(*__node, __code); + + // Always insert at the beginning of the bucket. + _M_insert_bucket_begin(__bkt, __node); + ++_M_element_count; + return iterator(__node); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_multi_node(__node_ptr __hint, + __hash_code __code, __node_ptr __node) + -> iterator + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, 1); + + if (__do_rehash.first) + _M_rehash(__do_rehash.second, __saved_state); + + this->_M_store_code(*__node, __code); + const key_type& __k = _ExtractKey{}(__node->_M_v()); + size_type __bkt = _M_bucket_index(__code); + + // Find the node before an equivalent one or use hint if it exists and + // if it is equivalent. + __node_base_ptr __prev + = __builtin_expect(__hint != nullptr, false) + && this->_M_equals(__k, __code, *__hint) + ? __hint + : _M_find_before_node(__bkt, __k, __code); + + if (__prev) + { + // Insert after the node before the equivalent one. + __node->_M_nxt = __prev->_M_nxt; + __prev->_M_nxt = __node; + if (__builtin_expect(__prev == __hint, false)) + // hint might be the last bucket node, in this case we need to + // update next bucket. + if (__node->_M_nxt + && !this->_M_equals(__k, __code, *__node->_M_next())) + { + size_type __next_bkt = _M_bucket_index(*__node->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __node; + } + } + else + // The inserted node has no equivalent in the hashtable. We must + // insert the new node at the beginning of the bucket to preserve + // equivalent elements' relative positions. + _M_insert_bucket_begin(__bkt, __node); + ++_M_element_count; + return iterator(__node); + } + + // Insert v if no element with its key is already present. + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_unique(_Kt&& __k, _Arg&& __v, + const _NodeGenerator& __node_gen) + -> pair + { + if (size() <= __small_size_threshold()) + for (auto __it = begin(); __it != end(); ++__it) + if (this->_M_key_equals_tr(__k, *__it._M_cur)) + return { __it, false }; + + __hash_code __code = this->_M_hash_code_tr(__k); + size_type __bkt = _M_bucket_index(__code); + + if (size() > __small_size_threshold()) + if (__node_ptr __node = _M_find_node_tr(__bkt, __k, __code)) + return { iterator(__node), false }; + + _Scoped_node __node { + __node_builder_t::_S_build(std::forward<_Kt>(__k), + std::forward<_Arg>(__v), + __node_gen), + this + }; + auto __pos + = _M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __pos, true }; + } + + // Insert v unconditionally. + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert(const_iterator __hint, _Arg&& __v, + const _NodeGenerator& __node_gen, + false_type /* __uks */) + -> iterator + { + // First allocate new node so that we don't do anything if it throws. + _Scoped_node __node{ __node_gen(std::forward<_Arg>(__v)), this }; + + // Second compute the hash code so that we don't rehash if it throws. + auto __res = this->_M_compute_hash_code( + __hint, _ExtractKey{}(__node._M_node->_M_v())); + + auto __pos + = _M_insert_multi_node(__res.first._M_cur, __res.second, + __node._M_node); + __node._M_node = nullptr; + return __pos; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + erase(const_iterator __it) + -> iterator + { + __node_ptr __n = __it._M_cur; + std::size_t __bkt = _M_bucket_index(*__n); + + // Look for previous node to unlink it from the erased one, this + // is why we need buckets to contain the before begin to make + // this search fast. + __node_base_ptr __prev_n = _M_get_previous_node(__bkt, __n); + return _M_erase(__bkt, __prev_n, __n); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(size_type __bkt, __node_base_ptr __prev_n, __node_ptr __n) + -> iterator + { + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n->_M_next(), + __n->_M_nxt ? _M_bucket_index(*__n->_M_next()) : 0); + else if (__n->_M_nxt) + { + size_type __next_bkt = _M_bucket_index(*__n->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __prev_n; + } + + __prev_n->_M_nxt = __n->_M_nxt; + iterator __result(__n->_M_next()); + this->_M_deallocate_node(__n); + --_M_element_count; + + return __result; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(true_type /* __uks */, const key_type& __k) + -> size_type + { + __node_base_ptr __prev_n; + __node_ptr __n; + std::size_t __bkt; + if (size() <= __small_size_threshold()) + { + __prev_n = _M_find_before_node(__k); + if (!__prev_n) + return 0; + + // We found a matching node, erase it. + __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + __bkt = _M_bucket_index(*__n); + } + else + { + __hash_code __code = this->_M_hash_code(__k); + __bkt = _M_bucket_index(__code); + + // Look for the node before the first matching node. + __prev_n = _M_find_before_node(__bkt, __k, __code); + if (!__prev_n) + return 0; + + // We found a matching node, erase it. + __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + } + + _M_erase(__bkt, __prev_n, __n); + return 1; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(false_type /* __uks */, const key_type& __k) + -> size_type + { + std::size_t __bkt; + __node_base_ptr __prev_n; + __node_ptr __n; + if (size() <= __small_size_threshold()) + { + __prev_n = _M_find_before_node(__k); + if (!__prev_n) + return 0; + + // We found a matching node, erase it. + __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + __bkt = _M_bucket_index(*__n); + } + else + { + __hash_code __code = this->_M_hash_code(__k); + __bkt = _M_bucket_index(__code); + + // Look for the node before the first matching node. + __prev_n = _M_find_before_node(__bkt, __k, __code); + if (!__prev_n) + return 0; + + __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + // We use one loop to find all matching nodes and another to deallocate + // them so that the key stays valid during the first loop. It might be + // invalidated indirectly when destroying nodes. + __node_ptr __n_last = __n->_M_next(); + while (__n_last && this->_M_node_equals(*__n, *__n_last)) + __n_last = __n_last->_M_next(); + + std::size_t __n_last_bkt = __n_last ? _M_bucket_index(*__n_last) : __bkt; + + // Deallocate nodes. + size_type __result = 0; + do + { + __node_ptr __p = __n->_M_next(); + this->_M_deallocate_node(__n); + __n = __p; + ++__result; + } + while (__n != __n_last); + + _M_element_count -= __result; + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n_last, __n_last_bkt); + else if (__n_last_bkt != __bkt) + _M_buckets[__n_last_bkt] = __prev_n; + __prev_n->_M_nxt = __n_last; + return __result; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + erase(const_iterator __first, const_iterator __last) + -> iterator + { + __node_ptr __n = __first._M_cur; + __node_ptr __last_n = __last._M_cur; + if (__n == __last_n) + return iterator(__n); + + std::size_t __bkt = _M_bucket_index(*__n); + + __node_base_ptr __prev_n = _M_get_previous_node(__bkt, __n); + bool __is_bucket_begin = __n == _M_bucket_begin(__bkt); + std::size_t __n_bkt = __bkt; + for (;;) + { + do + { + __node_ptr __tmp = __n; + __n = __n->_M_next(); + this->_M_deallocate_node(__tmp); + --_M_element_count; + if (!__n) + break; + __n_bkt = _M_bucket_index(*__n); + } + while (__n != __last_n && __n_bkt == __bkt); + if (__is_bucket_begin) + _M_remove_bucket_begin(__bkt, __n, __n_bkt); + if (__n == __last_n) + break; + __is_bucket_begin = true; + __bkt = __n_bkt; + } + + if (__n && (__n_bkt != __bkt || __is_bucket_begin)) + _M_buckets[__n_bkt] = __prev_n; + __prev_n->_M_nxt = __n; + return iterator(__n); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + clear() noexcept + { + this->_M_deallocate_nodes(_M_begin()); + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + _M_element_count = 0; + _M_before_begin._M_nxt = nullptr; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + rehash(size_type __bkt_count) + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + __bkt_count + = std::max(_M_rehash_policy._M_bkt_for_elements(_M_element_count + 1), + __bkt_count); + __bkt_count = _M_rehash_policy._M_next_bkt(__bkt_count); + + if (__bkt_count != _M_bucket_count) + _M_rehash(__bkt_count, __saved_state); + else + // No rehash, restore previous state to keep it consistent with + // container state. + _M_rehash_policy._M_reset(__saved_state); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash(size_type __bkt_count, const __rehash_state& __state) + { + __try + { + _M_rehash_aux(__bkt_count, __unique_keys{}); + } + __catch(...) + { + // A failure here means that buckets allocation failed. We only + // have to restore hash policy previous state. + _M_rehash_policy._M_reset(__state); + __throw_exception_again; + } + } + + // Rehash when there is no equivalent elements. + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash_aux(size_type __bkt_count, true_type /* __uks */) + { + __buckets_ptr __new_buckets = _M_allocate_buckets(__bkt_count); + __node_ptr __p = _M_begin(); + _M_before_begin._M_nxt = nullptr; + std::size_t __bbegin_bkt = 0; + while (__p) + { + __node_ptr __next = __p->_M_next(); + std::size_t __bkt + = __hash_code_base::_M_bucket_index(*__p, __bkt_count); + if (!__new_buckets[__bkt]) + { + __p->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __p; + __new_buckets[__bkt] = &_M_before_begin; + if (__p->_M_nxt) + __new_buckets[__bbegin_bkt] = __p; + __bbegin_bkt = __bkt; + } + else + { + __p->_M_nxt = __new_buckets[__bkt]->_M_nxt; + __new_buckets[__bkt]->_M_nxt = __p; + } + + __p = __next; + } + + _M_deallocate_buckets(); + _M_bucket_count = __bkt_count; + _M_buckets = __new_buckets; + } + + // Rehash when there can be equivalent elements, preserve their relative + // order. + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash_aux(size_type __bkt_count, false_type /* __uks */) + { + __buckets_ptr __new_buckets = _M_allocate_buckets(__bkt_count); + __node_ptr __p = _M_begin(); + _M_before_begin._M_nxt = nullptr; + std::size_t __bbegin_bkt = 0; + std::size_t __prev_bkt = 0; + __node_ptr __prev_p = nullptr; + bool __check_bucket = false; + + while (__p) + { + __node_ptr __next = __p->_M_next(); + std::size_t __bkt + = __hash_code_base::_M_bucket_index(*__p, __bkt_count); + + if (__prev_p && __prev_bkt == __bkt) + { + // Previous insert was already in this bucket, we insert after + // the previously inserted one to preserve equivalent elements + // relative order. + __p->_M_nxt = __prev_p->_M_nxt; + __prev_p->_M_nxt = __p; + + // Inserting after a node in a bucket require to check that we + // haven't change the bucket last node, in this case next + // bucket containing its before begin node must be updated. We + // schedule a check as soon as we move out of the sequence of + // equivalent nodes to limit the number of checks. + __check_bucket = true; + } + else + { + if (__check_bucket) + { + // Check if we shall update the next bucket because of + // insertions into __prev_bkt bucket. + if (__prev_p->_M_nxt) + { + std::size_t __next_bkt + = __hash_code_base::_M_bucket_index( + *__prev_p->_M_next(), __bkt_count); + if (__next_bkt != __prev_bkt) + __new_buckets[__next_bkt] = __prev_p; + } + __check_bucket = false; + } + + if (!__new_buckets[__bkt]) + { + __p->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __p; + __new_buckets[__bkt] = &_M_before_begin; + if (__p->_M_nxt) + __new_buckets[__bbegin_bkt] = __p; + __bbegin_bkt = __bkt; + } + else + { + __p->_M_nxt = __new_buckets[__bkt]->_M_nxt; + __new_buckets[__bkt]->_M_nxt = __p; + } + } + __prev_p = __p; + __prev_bkt = __bkt; + __p = __next; + } + + if (__check_bucket && __prev_p->_M_nxt) + { + std::size_t __next_bkt + = __hash_code_base::_M_bucket_index(*__prev_p->_M_next(), + __bkt_count); + if (__next_bkt != __prev_bkt) + __new_buckets[__next_bkt] = __prev_p; + } + + _M_deallocate_buckets(); + _M_bucket_count = __bkt_count; + _M_buckets = __new_buckets; + } + +#if __cplusplus > 201402L + template class _Hash_merge_helper { }; +#endif // C++17 + +#if __cpp_deduction_guides >= 201606 + // Used to constrain deduction guides + template + using _RequireNotAllocatorOrIntegral + = __enable_if_t, __is_allocator<_Hash>>::value>; +#endif + +/// @endcond +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _HASHTABLE_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..20a1b79dfaca0f486e7d915dbee80bc332ebfa63 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..799c3e986b45f727306a6fedbaf1608a19d1cbdc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h @@ -0,0 +1,2041 @@ +// Internal policy header for unordered_set and unordered_map -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hashtable_policy.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + * @headername{unordered_map,unordered_set} + */ + +#ifndef _HASHTABLE_POLICY_H +#define _HASHTABLE_POLICY_H 1 + +#include // for std::tuple, std::forward_as_tuple +#include // for std::min, std::is_permutation. +#include // for __gnu_cxx::__aligned_buffer +#include // for std::__alloc_rebind +#include // for __gnu_cxx::__int_traits + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +/// @cond undocumented + + template + class _Hashtable; + +namespace __detail +{ + /** + * @defgroup hashtable-detail Base and Implementation Classes + * @ingroup unordered_associative_containers + * @{ + */ + template + struct _Hashtable_base; + + // Helper function: return distance(first, last) for forward + // iterators, or 0/1 for input iterators. + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last, + std::input_iterator_tag) + { return __first != __last ? 1 : 0; } + + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last, + std::forward_iterator_tag) + { return std::distance(__first, __last); } + + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last) + { return __distance_fw(__first, __last, + std::__iterator_category(__first)); } + + struct _Identity + { + template + _Tp&& + operator()(_Tp&& __x) const noexcept + { return std::forward<_Tp>(__x); } + }; + + struct _Select1st + { + template + struct __1st_type; + + template + struct __1st_type> + { using type = _Tp; }; + + template + struct __1st_type> + { using type = const _Tp; }; + + template + struct __1st_type<_Pair&> + { using type = typename __1st_type<_Pair>::type&; }; + + template + typename __1st_type<_Tp>::type&& + operator()(_Tp&& __x) const noexcept + { return std::forward<_Tp>(__x).first; } + }; + + template + struct _NodeBuilder; + + template<> + struct _NodeBuilder<_Select1st> + { + template + static auto + _S_build(_Kt&& __k, _Arg&& __arg, const _NodeGenerator& __node_gen) + -> typename _NodeGenerator::__node_type* + { + return __node_gen(std::forward<_Kt>(__k), + std::forward<_Arg>(__arg).second); + } + }; + + template<> + struct _NodeBuilder<_Identity> + { + template + static auto + _S_build(_Kt&& __k, _Arg&&, const _NodeGenerator& __node_gen) + -> typename _NodeGenerator::__node_type* + { return __node_gen(std::forward<_Kt>(__k)); } + }; + + template + struct _Hashtable_alloc; + + // Functor recycling a pool of nodes and using allocation once the pool is + // empty. + template + struct _ReuseOrAllocNode + { + private: + using __node_alloc_type = _NodeAlloc; + using __hashtable_alloc = _Hashtable_alloc<__node_alloc_type>; + using __node_alloc_traits = + typename __hashtable_alloc::__node_alloc_traits; + + public: + using __node_type = typename __hashtable_alloc::__node_type; + + _ReuseOrAllocNode(__node_type* __nodes, __hashtable_alloc& __h) + : _M_nodes(__nodes), _M_h(__h) { } + _ReuseOrAllocNode(const _ReuseOrAllocNode&) = delete; + + ~_ReuseOrAllocNode() + { _M_h._M_deallocate_nodes(_M_nodes); } + + template + __node_type* + operator()(_Args&&... __args) const + { + if (_M_nodes) + { + __node_type* __node = _M_nodes; + _M_nodes = _M_nodes->_M_next(); + __node->_M_nxt = nullptr; + auto& __a = _M_h._M_node_allocator(); + __node_alloc_traits::destroy(__a, __node->_M_valptr()); + __try + { + __node_alloc_traits::construct(__a, __node->_M_valptr(), + std::forward<_Args>(__args)...); + } + __catch(...) + { + _M_h._M_deallocate_node_ptr(__node); + __throw_exception_again; + } + return __node; + } + return _M_h._M_allocate_node(std::forward<_Args>(__args)...); + } + + private: + mutable __node_type* _M_nodes; + __hashtable_alloc& _M_h; + }; + + // Functor similar to the previous one but without any pool of nodes to + // recycle. + template + struct _AllocNode + { + private: + using __hashtable_alloc = _Hashtable_alloc<_NodeAlloc>; + + public: + using __node_type = typename __hashtable_alloc::__node_type; + + _AllocNode(__hashtable_alloc& __h) + : _M_h(__h) { } + + template + __node_type* + operator()(_Args&&... __args) const + { return _M_h._M_allocate_node(std::forward<_Args>(__args)...); } + + private: + __hashtable_alloc& _M_h; + }; + + // Auxiliary types used for all instantiations of _Hashtable nodes + // and iterators. + + /** + * struct _Hashtable_traits + * + * Important traits for hash tables. + * + * @tparam _Cache_hash_code Boolean value. True if the value of + * the hash function is stored along with the value. This is a + * time-space tradeoff. Storing it may improve lookup speed by + * reducing the number of times we need to call the _Hash or _Equal + * functors. + * + * @tparam _Constant_iterators Boolean value. True if iterator and + * const_iterator are both constant iterator types. This is true + * for unordered_set and unordered_multiset, false for + * unordered_map and unordered_multimap. + * + * @tparam _Unique_keys Boolean value. True if the return value + * of _Hashtable::count(k) is always at most one, false if it may + * be an arbitrary number. This is true for unordered_set and + * unordered_map, false for unordered_multiset and + * unordered_multimap. + */ + template + struct _Hashtable_traits + { + using __hash_cached = __bool_constant<_Cache_hash_code>; + using __constant_iterators = __bool_constant<_Constant_iterators>; + using __unique_keys = __bool_constant<_Unique_keys>; + }; + + /** + * struct _Hashtable_hash_traits + * + * Important traits for hash tables depending on associated hasher. + * + */ + template + struct _Hashtable_hash_traits + { + static constexpr std::size_t + __small_size_threshold() noexcept + { return std::__is_fast_hash<_Hash>::value ? 0 : 20; } + }; + + /** + * struct _Hash_node_base + * + * Nodes, used to wrap elements stored in the hash table. A policy + * template parameter of class template _Hashtable controls whether + * nodes also store a hash code. In some cases (e.g. strings) this + * may be a performance win. + */ + struct _Hash_node_base + { + _Hash_node_base* _M_nxt; + + _Hash_node_base() noexcept : _M_nxt() { } + + _Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { } + }; + + /** + * struct _Hash_node_value_base + * + * Node type with the value to store. + */ + template + struct _Hash_node_value_base + { + typedef _Value value_type; + + __gnu_cxx::__aligned_buffer<_Value> _M_storage; + + _Value* + _M_valptr() noexcept + { return _M_storage._M_ptr(); } + + const _Value* + _M_valptr() const noexcept + { return _M_storage._M_ptr(); } + + _Value& + _M_v() noexcept + { return *_M_valptr(); } + + const _Value& + _M_v() const noexcept + { return *_M_valptr(); } + }; + + /** + * Primary template struct _Hash_node_code_cache. + */ + template + struct _Hash_node_code_cache + { }; + + /** + * Specialization for node with cache, struct _Hash_node_code_cache. + */ + template<> + struct _Hash_node_code_cache + { std::size_t _M_hash_code; }; + + template + struct _Hash_node_value + : _Hash_node_value_base<_Value> + , _Hash_node_code_cache<_Cache_hash_code> + { }; + + /** + * Primary template struct _Hash_node. + */ + template + struct _Hash_node + : _Hash_node_base + , _Hash_node_value<_Value, _Cache_hash_code> + { + _Hash_node* + _M_next() const noexcept + { return static_cast<_Hash_node*>(this->_M_nxt); } + }; + + /// Base class for node iterators. + template + struct _Node_iterator_base + { + using __node_type = _Hash_node<_Value, _Cache_hash_code>; + + __node_type* _M_cur; + + _Node_iterator_base() : _M_cur(nullptr) { } + _Node_iterator_base(__node_type* __p) noexcept + : _M_cur(__p) { } + + void + _M_incr() noexcept + { _M_cur = _M_cur->_M_next(); } + + friend bool + operator==(const _Node_iterator_base& __x, const _Node_iterator_base& __y) + noexcept + { return __x._M_cur == __y._M_cur; } + +#if __cpp_impl_three_way_comparison < 201907L + friend bool + operator!=(const _Node_iterator_base& __x, const _Node_iterator_base& __y) + noexcept + { return __x._M_cur != __y._M_cur; } +#endif + }; + + /// Node iterators, used to iterate through all the hashtable. + template + struct _Node_iterator + : public _Node_iterator_base<_Value, __cache> + { + private: + using __base_type = _Node_iterator_base<_Value, __cache>; + using __node_type = typename __base_type::__node_type; + + public: + using value_type = _Value; + using difference_type = std::ptrdiff_t; + using iterator_category = std::forward_iterator_tag; + + using pointer = __conditional_t<__constant_iterators, + const value_type*, value_type*>; + + using reference = __conditional_t<__constant_iterators, + const value_type&, value_type&>; + + _Node_iterator() = default; + + explicit + _Node_iterator(__node_type* __p) noexcept + : __base_type(__p) { } + + reference + operator*() const noexcept + { return this->_M_cur->_M_v(); } + + pointer + operator->() const noexcept + { return this->_M_cur->_M_valptr(); } + + _Node_iterator& + operator++() noexcept + { + this->_M_incr(); + return *this; + } + + _Node_iterator + operator++(int) noexcept + { + _Node_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /// Node const_iterators, used to iterate through all the hashtable. + template + struct _Node_const_iterator + : public _Node_iterator_base<_Value, __cache> + { + private: + using __base_type = _Node_iterator_base<_Value, __cache>; + using __node_type = typename __base_type::__node_type; + + public: + typedef _Value value_type; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + typedef const value_type* pointer; + typedef const value_type& reference; + + _Node_const_iterator() = default; + + explicit + _Node_const_iterator(__node_type* __p) noexcept + : __base_type(__p) { } + + _Node_const_iterator(const _Node_iterator<_Value, __constant_iterators, + __cache>& __x) noexcept + : __base_type(__x._M_cur) { } + + reference + operator*() const noexcept + { return this->_M_cur->_M_v(); } + + pointer + operator->() const noexcept + { return this->_M_cur->_M_valptr(); } + + _Node_const_iterator& + operator++() noexcept + { + this->_M_incr(); + return *this; + } + + _Node_const_iterator + operator++(int) noexcept + { + _Node_const_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + // Many of class template _Hashtable's template parameters are policy + // classes. These are defaults for the policies. + + /// Default range hashing function: use division to fold a large number + /// into the range [0, N). + struct _Mod_range_hashing + { + typedef std::size_t first_argument_type; + typedef std::size_t second_argument_type; + typedef std::size_t result_type; + + result_type + operator()(first_argument_type __num, + second_argument_type __den) const noexcept + { return __num % __den; } + }; + + /// Default ranged hash function H. In principle it should be a + /// function object composed from objects of type H1 and H2 such that + /// h(k, N) = h2(h1(k), N), but that would mean making extra copies of + /// h1 and h2. So instead we'll just use a tag to tell class template + /// hashtable to do that composition. + struct _Default_ranged_hash { }; + + /// Default value for rehash policy. Bucket size is (usually) the + /// smallest prime that keeps the load factor small enough. + struct _Prime_rehash_policy + { + using __has_load_factor = true_type; + + _Prime_rehash_policy(float __z = 1.0) noexcept + : _M_max_load_factor(__z), _M_next_resize(0) { } + + float + max_load_factor() const noexcept + { return _M_max_load_factor; } + + // Return a bucket size no smaller than n. + std::size_t + _M_next_bkt(std::size_t __n) const; + + // Return a bucket count appropriate for n elements + std::size_t + _M_bkt_for_elements(std::size_t __n) const + { return __builtin_ceil(__n / (double)_M_max_load_factor); } + + // __n_bkt is current bucket count, __n_elt is current element count, + // and __n_ins is number of elements to be inserted. Do we need to + // increase bucket count? If so, return make_pair(true, n), where n + // is the new bucket count. If not, return make_pair(false, 0). + std::pair + _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt, + std::size_t __n_ins) const; + + typedef std::size_t _State; + + _State + _M_state() const + { return _M_next_resize; } + + void + _M_reset() noexcept + { _M_next_resize = 0; } + + void + _M_reset(_State __state) + { _M_next_resize = __state; } + + static const std::size_t _S_growth_factor = 2; + + float _M_max_load_factor; + mutable std::size_t _M_next_resize; + }; + + /// Range hashing function assuming that second arg is a power of 2. + struct _Mask_range_hashing + { + typedef std::size_t first_argument_type; + typedef std::size_t second_argument_type; + typedef std::size_t result_type; + + result_type + operator()(first_argument_type __num, + second_argument_type __den) const noexcept + { return __num & (__den - 1); } + }; + + /// Compute closest power of 2 not less than __n + inline std::size_t + __clp2(std::size_t __n) noexcept + { + using __gnu_cxx::__int_traits; + // Equivalent to return __n ? std::bit_ceil(__n) : 0; + if (__n < 2) + return __n; + const unsigned __lz = sizeof(size_t) > sizeof(long) + ? __builtin_clzll(__n - 1ull) + : __builtin_clzl(__n - 1ul); + // Doing two shifts avoids undefined behaviour when __lz == 0. + return (size_t(1) << (__int_traits::__digits - __lz - 1)) << 1; + } + + /// Rehash policy providing power of 2 bucket numbers. Avoids modulo + /// operations. + struct _Power2_rehash_policy + { + using __has_load_factor = true_type; + + _Power2_rehash_policy(float __z = 1.0) noexcept + : _M_max_load_factor(__z), _M_next_resize(0) { } + + float + max_load_factor() const noexcept + { return _M_max_load_factor; } + + // Return a bucket size no smaller than n (as long as n is not above the + // highest power of 2). + std::size_t + _M_next_bkt(std::size_t __n) noexcept + { + if (__n == 0) + // Special case on container 1st initialization with 0 bucket count + // hint. We keep _M_next_resize to 0 to make sure that next time we + // want to add an element allocation will take place. + return 1; + + const auto __max_width = std::min(sizeof(size_t), 8); + const auto __max_bkt = size_t(1) << (__max_width * __CHAR_BIT__ - 1); + std::size_t __res = __clp2(__n); + + if (__res == 0) + __res = __max_bkt; + else if (__res == 1) + // If __res is 1 we force it to 2 to make sure there will be an + // allocation so that nothing need to be stored in the initial + // single bucket + __res = 2; + + if (__res == __max_bkt) + // Set next resize to the max value so that we never try to rehash again + // as we already reach the biggest possible bucket number. + // Note that it might result in max_load_factor not being respected. + _M_next_resize = size_t(-1); + else + _M_next_resize + = __builtin_floor(__res * (double)_M_max_load_factor); + + return __res; + } + + // Return a bucket count appropriate for n elements + std::size_t + _M_bkt_for_elements(std::size_t __n) const noexcept + { return __builtin_ceil(__n / (double)_M_max_load_factor); } + + // __n_bkt is current bucket count, __n_elt is current element count, + // and __n_ins is number of elements to be inserted. Do we need to + // increase bucket count? If so, return make_pair(true, n), where n + // is the new bucket count. If not, return make_pair(false, 0). + std::pair + _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt, + std::size_t __n_ins) noexcept + { + if (__n_elt + __n_ins > _M_next_resize) + { + // If _M_next_resize is 0 it means that we have nothing allocated so + // far and that we start inserting elements. In this case we start + // with an initial bucket size of 11. + double __min_bkts + = std::max(__n_elt + __n_ins, _M_next_resize ? 0 : 11) + / (double)_M_max_load_factor; + if (__min_bkts >= __n_bkt) + return { true, + _M_next_bkt(std::max(__builtin_floor(__min_bkts) + 1, + __n_bkt * _S_growth_factor)) }; + + _M_next_resize + = __builtin_floor(__n_bkt * (double)_M_max_load_factor); + return { false, 0 }; + } + else + return { false, 0 }; + } + + typedef std::size_t _State; + + _State + _M_state() const noexcept + { return _M_next_resize; } + + void + _M_reset() noexcept + { _M_next_resize = 0; } + + void + _M_reset(_State __state) noexcept + { _M_next_resize = __state; } + + static const std::size_t _S_growth_factor = 2; + + float _M_max_load_factor; + std::size_t _M_next_resize; + }; + + // Base classes for std::_Hashtable. We define these base classes + // because in some cases we want to do different things depending on + // the value of a policy class. In some cases the policy class + // affects which member functions and nested typedefs are defined; + // we handle that by specializing base class templates. Several of + // the base class templates need to access other members of class + // template _Hashtable, so we use a variant of the "Curiously + // Recurring Template Pattern" (CRTP) technique. + + /** + * Primary class template _Map_base. + * + * If the hashtable has a value type of the form pair and + * a key extraction policy (_ExtractKey) that returns the first part + * of the pair, the hashtable gets a mapped_type typedef. If it + * satisfies those criteria and also has unique keys, then it also + * gets an operator[]. + */ + template + struct _Map_base { }; + + /// Partial specialization, __unique_keys set to false, std::pair value type. + template + struct _Map_base<_Key, pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + { + using mapped_type = _Val; + }; + + /// Partial specialization, __unique_keys set to true. + template + struct _Map_base<_Key, pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true> + { + private: + using __hashtable_base = _Hashtable_base<_Key, pair, + _Select1st, _Equal, _Hash, + _RangeHash, _Unused, + _Traits>; + + using __hashtable = _Hashtable<_Key, pair, _Alloc, + _Select1st, _Equal, _Hash, _RangeHash, + _Unused, _RehashPolicy, _Traits>; + + using __hash_code = typename __hashtable_base::__hash_code; + + public: + using key_type = typename __hashtable_base::key_type; + using mapped_type = _Val; + + mapped_type& + operator[](const key_type& __k); + + mapped_type& + operator[](key_type&& __k); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 761. unordered_map needs an at() member function. + mapped_type& + at(const key_type& __k) + { + auto __ite = static_cast<__hashtable*>(this)->find(__k); + if (!__ite._M_cur) + __throw_out_of_range(__N("unordered_map::at")); + return __ite->second; + } + + const mapped_type& + at(const key_type& __k) const + { + auto __ite = static_cast(this)->find(__k); + if (!__ite._M_cur) + __throw_out_of_range(__N("unordered_map::at")); + return __ite->second; + } + }; + + template + auto + _Map_base<_Key, pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + operator[](const key_type& __k) + -> mapped_type& + { + __hashtable* __h = static_cast<__hashtable*>(this); + __hash_code __code = __h->_M_hash_code(__k); + std::size_t __bkt = __h->_M_bucket_index(__code); + if (auto __node = __h->_M_find_node(__bkt, __k, __code)) + return __node->_M_v().second; + + typename __hashtable::_Scoped_node __node { + __h, + std::piecewise_construct, + std::tuple(__k), + std::tuple<>() + }; + auto __pos + = __h->_M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return __pos->second; + } + + template + auto + _Map_base<_Key, pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + operator[](key_type&& __k) + -> mapped_type& + { + __hashtable* __h = static_cast<__hashtable*>(this); + __hash_code __code = __h->_M_hash_code(__k); + std::size_t __bkt = __h->_M_bucket_index(__code); + if (auto __node = __h->_M_find_node(__bkt, __k, __code)) + return __node->_M_v().second; + + typename __hashtable::_Scoped_node __node { + __h, + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::tuple<>() + }; + auto __pos + = __h->_M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return __pos->second; + } + + // Partial specialization for unordered_map, see PR 104174. + template + struct _Map_base, + _Alloc, _Select1st, _Equal, _Hash, + _RangeHash, _Unused, _RehashPolicy, _Traits, __uniq> + : _Map_base<_Key, pair, _Alloc, _Select1st, _Equal, _Hash, + _RangeHash, _Unused, _RehashPolicy, _Traits, __uniq> + { }; + + /** + * Primary class template _Insert_base. + * + * Defines @c insert member functions appropriate to all _Hashtables. + */ + template + struct _Insert_base + { + protected: + using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey, + _Equal, _Hash, _RangeHash, + _Unused, _Traits>; + + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, + _Unused, _RehashPolicy, _Traits>; + + using __hash_cached = typename _Traits::__hash_cached; + using __constant_iterators = typename _Traits::__constant_iterators; + + using __hashtable_alloc = _Hashtable_alloc< + __alloc_rebind<_Alloc, _Hash_node<_Value, + __hash_cached::value>>>; + + using value_type = typename __hashtable_base::value_type; + using size_type = typename __hashtable_base::size_type; + + using __unique_keys = typename _Traits::__unique_keys; + using __node_alloc_type = typename __hashtable_alloc::__node_alloc_type; + using __node_gen_type = _AllocNode<__node_alloc_type>; + + __hashtable& + _M_conjure_hashtable() + { return *(static_cast<__hashtable*>(this)); } + + template + void + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter&, true_type __uks); + + template + void + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter&, false_type __uks); + + public: + using iterator = _Node_iterator<_Value, __constant_iterators::value, + __hash_cached::value>; + + using const_iterator = _Node_const_iterator<_Value, + __constant_iterators::value, + __hash_cached::value>; + + using __ireturn_type = __conditional_t<__unique_keys::value, + std::pair, + iterator>; + + __ireturn_type + insert(const value_type& __v) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__v, __node_gen, __unique_keys{}); + } + + iterator + insert(const_iterator __hint, const value_type& __v) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__hint, __v, __node_gen, __unique_keys{}); + } + + template + std::pair + try_emplace(const_iterator, _KType&& __k, _Args&&... __args) + { + __hashtable& __h = _M_conjure_hashtable(); + auto __code = __h._M_hash_code(__k); + std::size_t __bkt = __h._M_bucket_index(__code); + if (auto __node = __h._M_find_node(__bkt, __k, __code)) + return { iterator(__node), false }; + + typename __hashtable::_Scoped_node __node { + &__h, + std::piecewise_construct, + std::forward_as_tuple(std::forward<_KType>(__k)), + std::forward_as_tuple(std::forward<_Args>(__args)...) + }; + auto __it + = __h._M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __it, true }; + } + + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return _M_insert_range(__first, __last, __node_gen, __unique_keys{}); + } + }; + + template + template + void + _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>:: + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter& __node_gen, true_type __uks) + { + __hashtable& __h = _M_conjure_hashtable(); + for (; __first != __last; ++__first) + __h._M_insert(*__first, __node_gen, __uks); + } + + template + template + void + _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>:: + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter& __node_gen, false_type __uks) + { + using __rehash_type = typename __hashtable::__rehash_type; + using __rehash_state = typename __hashtable::__rehash_state; + using pair_type = std::pair; + + size_type __n_elt = __detail::__distance_fw(__first, __last); + if (__n_elt == 0) + return; + + __hashtable& __h = _M_conjure_hashtable(); + __rehash_type& __rehash = __h._M_rehash_policy; + const __rehash_state& __saved_state = __rehash._M_state(); + pair_type __do_rehash = __rehash._M_need_rehash(__h._M_bucket_count, + __h._M_element_count, + __n_elt); + + if (__do_rehash.first) + __h._M_rehash(__do_rehash.second, __saved_state); + + for (; __first != __last; ++__first) + __h._M_insert(*__first, __node_gen, __uks); + } + + /** + * Primary class template _Insert. + * + * Defines @c insert member functions that depend on _Hashtable policies, + * via partial specializations. + */ + template + struct _Insert; + + /// Specialization. + template + struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits, true> + : public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits> + { + using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using value_type = typename __base_type::value_type; + using iterator = typename __base_type::iterator; + using const_iterator = typename __base_type::const_iterator; + using __ireturn_type = typename __base_type::__ireturn_type; + + using __unique_keys = typename __base_type::__unique_keys; + using __hashtable = typename __base_type::__hashtable; + using __node_gen_type = typename __base_type::__node_gen_type; + + using __base_type::insert; + + __ireturn_type + insert(value_type&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(std::move(__v), __node_gen, __unique_keys{}); + } + + iterator + insert(const_iterator __hint, value_type&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__hint, std::move(__v), __node_gen, + __unique_keys{}); + } + }; + + /// Specialization. + template + struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + : public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits> + { + using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + using value_type = typename __base_type::value_type; + using iterator = typename __base_type::iterator; + using const_iterator = typename __base_type::const_iterator; + + using __unique_keys = typename __base_type::__unique_keys; + using __hashtable = typename __base_type::__hashtable; + using __ireturn_type = typename __base_type::__ireturn_type; + + using __base_type::insert; + + template + using __is_cons = std::is_constructible; + + template + using _IFcons = std::enable_if<__is_cons<_Pair>::value>; + + template + using _IFconsp = typename _IFcons<_Pair>::type; + + template> + __ireturn_type + insert(_Pair&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + return __h._M_emplace(__unique_keys{}, std::forward<_Pair>(__v)); + } + + template> + iterator + insert(const_iterator __hint, _Pair&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + return __h._M_emplace(__hint, __unique_keys{}, + std::forward<_Pair>(__v)); + } + }; + + template + using __has_load_factor = typename _Policy::__has_load_factor; + + /** + * Primary class template _Rehash_base. + * + * Give hashtable the max_load_factor functions and reserve iff the + * rehash policy supports it. + */ + template> + struct _Rehash_base; + + /// Specialization when rehash policy doesn't provide load factor management. + template + struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, + false_type /* Has load factor */> + { + }; + + /// Specialization when rehash policy provide load factor management. + template + struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, + true_type /* Has load factor */> + { + private: + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + public: + float + max_load_factor() const noexcept + { + const __hashtable* __this = static_cast(this); + return __this->__rehash_policy().max_load_factor(); + } + + void + max_load_factor(float __z) + { + __hashtable* __this = static_cast<__hashtable*>(this); + __this->__rehash_policy(_RehashPolicy(__z)); + } + + void + reserve(std::size_t __n) + { + __hashtable* __this = static_cast<__hashtable*>(this); + __this->rehash(__this->__rehash_policy()._M_bkt_for_elements(__n)); + } + }; + + /** + * Primary class template _Hashtable_ebo_helper. + * + * Helper class using EBO when it is not forbidden (the type is not + * final) and when it is worth it (the type is empty.) + */ + template + struct _Hashtable_ebo_helper; + + /// Specialization using EBO. + template + struct _Hashtable_ebo_helper<_Nm, _Tp, true> + : private _Tp + { + _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } + + template + _Hashtable_ebo_helper(_OtherTp&& __tp) + : _Tp(std::forward<_OtherTp>(__tp)) + { } + + const _Tp& _M_cget() const { return static_cast(*this); } + _Tp& _M_get() { return static_cast<_Tp&>(*this); } + }; + + /// Specialization not using EBO. + template + struct _Hashtable_ebo_helper<_Nm, _Tp, false> + { + _Hashtable_ebo_helper() = default; + + template + _Hashtable_ebo_helper(_OtherTp&& __tp) + : _M_tp(std::forward<_OtherTp>(__tp)) + { } + + const _Tp& _M_cget() const { return _M_tp; } + _Tp& _M_get() { return _M_tp; } + + private: + _Tp _M_tp{}; + }; + + /** + * Primary class template _Local_iterator_base. + * + * Base class for local iterators, used to iterate within a bucket + * but not between buckets. + */ + template + struct _Local_iterator_base; + + /** + * Primary class template _Hash_code_base. + * + * Encapsulates two policy issues that aren't quite orthogonal. + * (1) the difference between using a ranged hash function and using + * the combination of a hash function and a range-hashing function. + * In the former case we don't have such things as hash codes, so + * we have a dummy type as placeholder. + * (2) Whether or not we cache hash codes. Caching hash codes is + * meaningless if we have a ranged hash function. + * + * We also put the key extraction objects here, for convenience. + * Each specialization derives from one or more of the template + * parameters to benefit from Ebo. This is important as this type + * is inherited in some cases by the _Local_iterator_base type used + * to implement local_iterator and const_local_iterator. As with + * any iterator type we prefer to make it as small as possible. + */ + template + struct _Hash_code_base + : private _Hashtable_ebo_helper<1, _Hash> + { + private: + using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>; + + // Gives the local iterator implementation access to _M_bucket_index(). + friend struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>; + + public: + typedef _Hash hasher; + + hasher + hash_function() const + { return _M_hash(); } + + protected: + typedef std::size_t __hash_code; + + // We need the default constructor for the local iterators and _Hashtable + // default constructor. + _Hash_code_base() = default; + + _Hash_code_base(const _Hash& __hash) : __ebo_hash(__hash) { } + + __hash_code + _M_hash_code(const _Key& __k) const + { + static_assert(__is_invocable{}, + "hash function must be invocable with an argument of key type"); + return _M_hash()(__k); + } + + template + __hash_code + _M_hash_code_tr(const _Kt& __k) const + { + static_assert(__is_invocable{}, + "hash function must be invocable with an argument of key type"); + return _M_hash()(__k); + } + + __hash_code + _M_hash_code(const _Hash&, + const _Hash_node_value<_Value, true>& __n) const + { return __n._M_hash_code; } + + // Compute hash code using _Hash as __n _M_hash_code, if present, was + // computed using _H2. + template + __hash_code + _M_hash_code(const _H2&, + const _Hash_node_value<_Value, __cache_hash_code>& __n) const + { return _M_hash_code(_ExtractKey{}(__n._M_v())); } + + __hash_code + _M_hash_code(const _Hash_node_value<_Value, false>& __n) const + { return _M_hash_code(_ExtractKey{}(__n._M_v())); } + + __hash_code + _M_hash_code(const _Hash_node_value<_Value, true>& __n) const + { return __n._M_hash_code; } + + std::size_t + _M_bucket_index(__hash_code __c, std::size_t __bkt_count) const + { return _RangeHash{}(__c, __bkt_count); } + + std::size_t + _M_bucket_index(const _Hash_node_value<_Value, false>& __n, + std::size_t __bkt_count) const + noexcept( noexcept(declval()(declval())) + && noexcept(declval()((__hash_code)0, + (std::size_t)0)) ) + { + return _RangeHash{}(_M_hash_code(_ExtractKey{}(__n._M_v())), + __bkt_count); + } + + std::size_t + _M_bucket_index(const _Hash_node_value<_Value, true>& __n, + std::size_t __bkt_count) const + noexcept( noexcept(declval()((__hash_code)0, + (std::size_t)0)) ) + { return _RangeHash{}(__n._M_hash_code, __bkt_count); } + + void + _M_store_code(_Hash_node_code_cache&, __hash_code) const + { } + + void + _M_copy_code(_Hash_node_code_cache&, + const _Hash_node_code_cache&) const + { } + + void + _M_store_code(_Hash_node_code_cache& __n, __hash_code __c) const + { __n._M_hash_code = __c; } + + void + _M_copy_code(_Hash_node_code_cache& __to, + const _Hash_node_code_cache& __from) const + { __to._M_hash_code = __from._M_hash_code; } + + void + _M_swap(_Hash_code_base& __x) + { std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); } + + const _Hash& + _M_hash() const { return __ebo_hash::_M_cget(); } + }; + + /// Partial specialization used when nodes contain a cached hash code. + template + struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, true> + : public _Node_iterator_base<_Value, true> + { + protected: + using __base_node_iter = _Node_iterator_base<_Value, true>; + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, true>; + + _Local_iterator_base() = default; + _Local_iterator_base(const __hash_code_base&, + _Hash_node<_Value, true>* __p, + std::size_t __bkt, std::size_t __bkt_count) + : __base_node_iter(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count) + { } + + void + _M_incr() + { + __base_node_iter::_M_incr(); + if (this->_M_cur) + { + std::size_t __bkt + = _RangeHash{}(this->_M_cur->_M_hash_code, _M_bucket_count); + if (__bkt != _M_bucket) + this->_M_cur = nullptr; + } + } + + std::size_t _M_bucket; + std::size_t _M_bucket_count; + + public: + std::size_t + _M_get_bucket() const { return _M_bucket; } // for debug mode + }; + + // Uninitialized storage for a _Hash_code_base. + // This type is DefaultConstructible and Assignable even if the + // _Hash_code_base type isn't, so that _Local_iterator_base<..., false> + // can be DefaultConstructible and Assignable. + template::value> + struct _Hash_code_storage + { + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + + _Tp* + _M_h() { return _M_storage._M_ptr(); } + + const _Tp* + _M_h() const { return _M_storage._M_ptr(); } + }; + + // Empty partial specialization for empty _Hash_code_base types. + template + struct _Hash_code_storage<_Tp, true> + { + static_assert( std::is_empty<_Tp>::value, "Type must be empty" ); + + // As _Tp is an empty type there will be no bytes written/read through + // the cast pointer, so no strict-aliasing violation. + _Tp* + _M_h() { return reinterpret_cast<_Tp*>(this); } + + const _Tp* + _M_h() const { return reinterpret_cast(this); } + }; + + template + using __hash_code_for_local_iter + = _Hash_code_storage<_Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>>; + + // Partial specialization used when hash codes are not cached + template + struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false> + : __hash_code_for_local_iter<_Key, _Value, _ExtractKey, _Hash, _RangeHash, + _Unused> + , _Node_iterator_base<_Value, false> + { + protected: + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>; + using __node_iter_base = _Node_iterator_base<_Value, false>; + + _Local_iterator_base() : _M_bucket_count(-1) { } + + _Local_iterator_base(const __hash_code_base& __base, + _Hash_node<_Value, false>* __p, + std::size_t __bkt, std::size_t __bkt_count) + : __node_iter_base(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count) + { _M_init(__base); } + + ~_Local_iterator_base() + { + if (_M_bucket_count != size_t(-1)) + _M_destroy(); + } + + _Local_iterator_base(const _Local_iterator_base& __iter) + : __node_iter_base(__iter._M_cur), _M_bucket(__iter._M_bucket) + , _M_bucket_count(__iter._M_bucket_count) + { + if (_M_bucket_count != size_t(-1)) + _M_init(*__iter._M_h()); + } + + _Local_iterator_base& + operator=(const _Local_iterator_base& __iter) + { + if (_M_bucket_count != -1) + _M_destroy(); + this->_M_cur = __iter._M_cur; + _M_bucket = __iter._M_bucket; + _M_bucket_count = __iter._M_bucket_count; + if (_M_bucket_count != -1) + _M_init(*__iter._M_h()); + return *this; + } + + void + _M_incr() + { + __node_iter_base::_M_incr(); + if (this->_M_cur) + { + std::size_t __bkt = this->_M_h()->_M_bucket_index(*this->_M_cur, + _M_bucket_count); + if (__bkt != _M_bucket) + this->_M_cur = nullptr; + } + } + + std::size_t _M_bucket; + std::size_t _M_bucket_count; + + void + _M_init(const __hash_code_base& __base) + { ::new(this->_M_h()) __hash_code_base(__base); } + + void + _M_destroy() { this->_M_h()->~__hash_code_base(); } + + public: + std::size_t + _M_get_bucket() const { return _M_bucket; } // for debug mode + }; + + /// local iterators + template + struct _Local_iterator + : public _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache> + { + private: + using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache>; + using __hash_code_base = typename __base_type::__hash_code_base; + + public: + using value_type = _Value; + using pointer = __conditional_t<__constant_iterators, + const value_type*, value_type*>; + using reference = __conditional_t<__constant_iterators, + const value_type&, value_type&>; + using difference_type = ptrdiff_t; + using iterator_category = forward_iterator_tag; + + _Local_iterator() = default; + + _Local_iterator(const __hash_code_base& __base, + _Hash_node<_Value, __cache>* __n, + std::size_t __bkt, std::size_t __bkt_count) + : __base_type(__base, __n, __bkt, __bkt_count) + { } + + reference + operator*() const + { return this->_M_cur->_M_v(); } + + pointer + operator->() const + { return this->_M_cur->_M_valptr(); } + + _Local_iterator& + operator++() + { + this->_M_incr(); + return *this; + } + + _Local_iterator + operator++(int) + { + _Local_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /// local const_iterators + template + struct _Local_const_iterator + : public _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache> + { + private: + using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache>; + using __hash_code_base = typename __base_type::__hash_code_base; + + public: + typedef _Value value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Local_const_iterator() = default; + + _Local_const_iterator(const __hash_code_base& __base, + _Hash_node<_Value, __cache>* __n, + std::size_t __bkt, std::size_t __bkt_count) + : __base_type(__base, __n, __bkt, __bkt_count) + { } + + _Local_const_iterator(const _Local_iterator<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, + __constant_iterators, + __cache>& __x) + : __base_type(__x) + { } + + reference + operator*() const + { return this->_M_cur->_M_v(); } + + pointer + operator->() const + { return this->_M_cur->_M_valptr(); } + + _Local_const_iterator& + operator++() + { + this->_M_incr(); + return *this; + } + + _Local_const_iterator + operator++(int) + { + _Local_const_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /** + * Primary class template _Hashtable_base. + * + * Helper class adding management of _Equal functor to + * _Hash_code_base type. + * + * Base class templates are: + * - __detail::_Hash_code_base + * - __detail::_Hashtable_ebo_helper + */ + template + struct _Hashtable_base + : public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, + _Unused, _Traits::__hash_cached::value>, + private _Hashtable_ebo_helper<0, _Equal> + { + public: + typedef _Key key_type; + typedef _Value value_type; + typedef _Equal key_equal; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + using __traits_type = _Traits; + using __hash_cached = typename __traits_type::__hash_cached; + + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, + __hash_cached::value>; + + using __hash_code = typename __hash_code_base::__hash_code; + + private: + using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>; + + static bool + _S_equals(__hash_code, const _Hash_node_code_cache&) + { return true; } + + static bool + _S_node_equals(const _Hash_node_code_cache&, + const _Hash_node_code_cache&) + { return true; } + + static bool + _S_equals(__hash_code __c, const _Hash_node_code_cache& __n) + { return __c == __n._M_hash_code; } + + static bool + _S_node_equals(const _Hash_node_code_cache& __lhn, + const _Hash_node_code_cache& __rhn) + { return __lhn._M_hash_code == __rhn._M_hash_code; } + + protected: + _Hashtable_base() = default; + + _Hashtable_base(const _Hash& __hash, const _Equal& __eq) + : __hash_code_base(__hash), _EqualEBO(__eq) + { } + + bool + _M_key_equals(const _Key& __k, + const _Hash_node_value<_Value, + __hash_cached::value>& __n) const + { + static_assert(__is_invocable{}, + "key equality predicate must be invocable with two arguments of " + "key type"); + return _M_eq()(__k, _ExtractKey{}(__n._M_v())); + } + + template + bool + _M_key_equals_tr(const _Kt& __k, + const _Hash_node_value<_Value, + __hash_cached::value>& __n) const + { + static_assert( + __is_invocable{}, + "key equality predicate must be invocable with two arguments of " + "key type"); + return _M_eq()(__k, _ExtractKey{}(__n._M_v())); + } + + bool + _M_equals(const _Key& __k, __hash_code __c, + const _Hash_node_value<_Value, __hash_cached::value>& __n) const + { return _S_equals(__c, __n) && _M_key_equals(__k, __n); } + + template + bool + _M_equals_tr(const _Kt& __k, __hash_code __c, + const _Hash_node_value<_Value, + __hash_cached::value>& __n) const + { return _S_equals(__c, __n) && _M_key_equals_tr(__k, __n); } + + bool + _M_node_equals( + const _Hash_node_value<_Value, __hash_cached::value>& __lhn, + const _Hash_node_value<_Value, __hash_cached::value>& __rhn) const + { + return _S_node_equals(__lhn, __rhn) + && _M_key_equals(_ExtractKey{}(__lhn._M_v()), __rhn); + } + + void + _M_swap(_Hashtable_base& __x) + { + __hash_code_base::_M_swap(__x); + std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get()); + } + + const _Equal& + _M_eq() const { return _EqualEBO::_M_cget(); } + }; + + /** + * Primary class template _Equality. + * + * This is for implementing equality comparison for unordered + * containers, per N3068, by John Lakos and Pablo Halpern. + * Algorithmically, we follow closely the reference implementations + * therein. + */ + template + struct _Equality; + + /// unordered_map and unordered_set specializations. + template + struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true> + { + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + bool + _M_equal(const __hashtable&) const; + }; + + template + bool + _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + _M_equal(const __hashtable& __other) const + { + using __node_type = typename __hashtable::__node_type; + const __hashtable* __this = static_cast(this); + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end(); ++__itx) + { + std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur); + auto __prev_n = __other._M_buckets[__ybkt]; + if (!__prev_n) + return false; + + for (__node_type* __n = static_cast<__node_type*>(__prev_n->_M_nxt);; + __n = __n->_M_next()) + { + if (__n->_M_v() == *__itx) + break; + + if (!__n->_M_nxt + || __other._M_bucket_index(*__n->_M_next()) != __ybkt) + return false; + } + } + + return true; + } + + /// unordered_multiset and unordered_multimap specializations. + template + struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + { + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + bool + _M_equal(const __hashtable&) const; + }; + + template + bool + _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>:: + _M_equal(const __hashtable& __other) const + { + using __node_type = typename __hashtable::__node_type; + const __hashtable* __this = static_cast(this); + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end();) + { + std::size_t __x_count = 1; + auto __itx_end = __itx; + for (++__itx_end; __itx_end != __this->end() + && __this->key_eq()(_ExtractKey{}(*__itx), + _ExtractKey{}(*__itx_end)); + ++__itx_end) + ++__x_count; + + std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur); + auto __y_prev_n = __other._M_buckets[__ybkt]; + if (!__y_prev_n) + return false; + + __node_type* __y_n = static_cast<__node_type*>(__y_prev_n->_M_nxt); + for (;;) + { + if (__this->key_eq()(_ExtractKey{}(__y_n->_M_v()), + _ExtractKey{}(*__itx))) + break; + + auto __y_ref_n = __y_n; + for (__y_n = __y_n->_M_next(); __y_n; __y_n = __y_n->_M_next()) + if (!__other._M_node_equals(*__y_ref_n, *__y_n)) + break; + + if (!__y_n || __other._M_bucket_index(*__y_n) != __ybkt) + return false; + } + + typename __hashtable::const_iterator __ity(__y_n); + for (auto __ity_end = __ity; __ity_end != __other.end(); ++__ity_end) + if (--__x_count == 0) + break; + + if (__x_count != 0) + return false; + + if (!std::is_permutation(__itx, __itx_end, __ity)) + return false; + + __itx = __itx_end; + } + return true; + } + + /** + * This type deals with all allocation and keeps an allocator instance + * through inheritance to benefit from EBO when possible. + */ + template + struct _Hashtable_alloc : private _Hashtable_ebo_helper<0, _NodeAlloc> + { + private: + using __ebo_node_alloc = _Hashtable_ebo_helper<0, _NodeAlloc>; + + template + struct __get_value_type; + template + struct __get_value_type<_Hash_node<_Val, _Cache_hash_code>> + { using type = _Val; }; + + public: + using __node_type = typename _NodeAlloc::value_type; + using __node_alloc_type = _NodeAlloc; + // Use __gnu_cxx to benefit from _S_always_equal and al. + using __node_alloc_traits = __gnu_cxx::__alloc_traits<__node_alloc_type>; + + using __value_alloc_traits = typename __node_alloc_traits::template + rebind_traits::type>; + + using __node_ptr = __node_type*; + using __node_base = _Hash_node_base; + using __node_base_ptr = __node_base*; + using __buckets_alloc_type = + __alloc_rebind<__node_alloc_type, __node_base_ptr>; + using __buckets_alloc_traits = std::allocator_traits<__buckets_alloc_type>; + using __buckets_ptr = __node_base_ptr*; + + _Hashtable_alloc() = default; + _Hashtable_alloc(const _Hashtable_alloc&) = default; + _Hashtable_alloc(_Hashtable_alloc&&) = default; + + template + _Hashtable_alloc(_Alloc&& __a) + : __ebo_node_alloc(std::forward<_Alloc>(__a)) + { } + + __node_alloc_type& + _M_node_allocator() + { return __ebo_node_alloc::_M_get(); } + + const __node_alloc_type& + _M_node_allocator() const + { return __ebo_node_alloc::_M_cget(); } + + // Allocate a node and construct an element within it. + template + __node_ptr + _M_allocate_node(_Args&&... __args); + + // Destroy the element within a node and deallocate the node. + void + _M_deallocate_node(__node_ptr __n); + + // Deallocate a node. + void + _M_deallocate_node_ptr(__node_ptr __n); + + // Deallocate the linked list of nodes pointed to by __n. + // The elements within the nodes are destroyed. + void + _M_deallocate_nodes(__node_ptr __n); + + __buckets_ptr + _M_allocate_buckets(std::size_t __bkt_count); + + void + _M_deallocate_buckets(__buckets_ptr, std::size_t __bkt_count); + }; + + // Definitions of class template _Hashtable_alloc's out-of-line member + // functions. + template + template + auto + _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args) + -> __node_ptr + { + auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1); + __node_ptr __n = std::__to_address(__nptr); + __try + { + ::new ((void*)__n) __node_type; + __node_alloc_traits::construct(_M_node_allocator(), + __n->_M_valptr(), + std::forward<_Args>(__args)...); + return __n; + } + __catch(...) + { + __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1); + __throw_exception_again; + } + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_ptr __n) + { + __node_alloc_traits::destroy(_M_node_allocator(), __n->_M_valptr()); + _M_deallocate_node_ptr(__n); + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node_ptr(__node_ptr __n) + { + typedef typename __node_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__n); + __n->~__node_type(); + __node_alloc_traits::deallocate(_M_node_allocator(), __ptr, 1); + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_nodes(__node_ptr __n) + { + while (__n) + { + __node_ptr __tmp = __n; + __n = __n->_M_next(); + _M_deallocate_node(__tmp); + } + } + + template + auto + _Hashtable_alloc<_NodeAlloc>::_M_allocate_buckets(std::size_t __bkt_count) + -> __buckets_ptr + { + __buckets_alloc_type __alloc(_M_node_allocator()); + + auto __ptr = __buckets_alloc_traits::allocate(__alloc, __bkt_count); + __buckets_ptr __p = std::__to_address(__ptr); + __builtin_memset(__p, 0, __bkt_count * sizeof(__node_base_ptr)); + return __p; + } + + template + void + _Hashtable_alloc<_NodeAlloc>:: + _M_deallocate_buckets(__buckets_ptr __bkts, + std::size_t __bkt_count) + { + typedef typename __buckets_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__bkts); + __buckets_alloc_type __alloc(_M_node_allocator()); + __buckets_alloc_traits::deallocate(__alloc, __ptr, __bkt_count); + } + + ///@} hashtable-detail +} // namespace __detail +/// @endcond +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _HASHTABLE_POLICY_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..26db4694584bc185962c9cfbb9b9fab5567eb1c7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@hashtable_policy.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h new file mode 100644 index 0000000000000000000000000000000000000000..d9bf2cf61ff98fd11676570c912b09c48c636a55 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h @@ -0,0 +1,212 @@ +// The template and inlines for the -*- C++ -*- indirect_array class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/indirect_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _INDIRECT_ARRAY_H +#define _INDIRECT_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to arbitrary subset of an array. + * + * An indirect_array is a reference to the actual elements of an array + * specified by an ordered array of indices. The way to get an + * indirect_array is to call operator[](valarray) on a valarray. + * The returned indirect_array then permits carrying operations out on the + * referenced subset of elements in the original valarray. + * + * For example, if an indirect_array is obtained using the array (4,2,0) as + * an argument, and then assigned to an array containing (1,2,3), then the + * underlying array will have array[0]==3, array[2]==2, and array[4]==1. + * + * @param Tp Element type. + */ + template + class indirect_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + indirect_array(const indirect_array&); + + /// Assignment operator. Assigns elements to corresponding elements + /// of @a a. + indirect_array& operator=(const indirect_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator= (const _Tp&) const; + // ~indirect_array(); + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + /// Copy constructor. Both slices refer to the same underlying array. + indirect_array(_Array<_Tp>, size_t, _Array); + + friend class valarray<_Tp>; + friend class gslice_array<_Tp>; + + const size_t _M_sz; + const _Array _M_index; + const _Array<_Tp> _M_array; + + // not implemented + indirect_array(); + }; + + template + inline + indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {} + + template + inline + indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s, + _Array __i) + : _M_sz(__s), _M_index(__i), _M_array(__a) {} + + template + inline indirect_array<_Tp>& + indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, + _M_index); + return *this; + } + + template + inline void + indirect_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); } + + template + inline void + indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); } + + template + template + inline void + indirect_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const + { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \ + } \ + \ + template \ + template \ + inline void \ + indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _INDIRECT_ARRAY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9d6c04e98709b3ba49f3a7c182f8f475d0b35485 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@indirect_array.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h new file mode 100644 index 0000000000000000000000000000000000000000..cdecca0e2bfff219bef2d5d6f7325906d673a5be --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h @@ -0,0 +1,164 @@ +// Implementation of INVOKE -*- C++ -*- + +// Copyright (C) 2016-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/invoke.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_INVOKE_H +#define _GLIBCXX_INVOKE_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include // forward + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + // Used by __invoke_impl instead of std::forward<_Tp> so that a + // reference_wrapper is converted to an lvalue-reference. + template::type> + constexpr _Up&& + __invfwd(typename remove_reference<_Tp>::type& __t) noexcept + { return static_cast<_Up&&>(__t); } + + template + constexpr _Res + __invoke_impl(__invoke_other, _Fn&& __f, _Args&&... __args) + { return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); } + + template + constexpr _Res + __invoke_impl(__invoke_memfun_ref, _MemFun&& __f, _Tp&& __t, + _Args&&... __args) + { return (__invfwd<_Tp>(__t).*__f)(std::forward<_Args>(__args)...); } + + template + constexpr _Res + __invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t, + _Args&&... __args) + { + return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...); + } + + template + constexpr _Res + __invoke_impl(__invoke_memobj_ref, _MemPtr&& __f, _Tp&& __t) + { return __invfwd<_Tp>(__t).*__f; } + + template + constexpr _Res + __invoke_impl(__invoke_memobj_deref, _MemPtr&& __f, _Tp&& __t) + { return (*std::forward<_Tp>(__t)).*__f; } + + /// Invoke a callable object. + template + constexpr typename __invoke_result<_Callable, _Args...>::type + __invoke(_Callable&& __fn, _Args&&... __args) + noexcept(__is_nothrow_invocable<_Callable, _Args...>::value) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } + +#if __cplusplus >= 201703L + // INVOKE: Invoke a callable object and convert the result to R. + template + constexpr enable_if_t, _Res> + __invoke_r(_Callable&& __fn, _Args&&... __args) + noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + if constexpr (is_void_v<_Res>) + std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + else + return std::__invoke_impl<__type>(__tag{}, + std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } +#else // C++11 + template + using __can_invoke_as_void = __enable_if_t< + __and_, __is_invocable<_Callable, _Args...>>::value, + _Res + >; + + template + using __can_invoke_as_nonvoid = __enable_if_t< + __and_<__not_>, + is_convertible::type, + _Res> + >::value, + _Res + >; + + // INVOKE: Invoke a callable object and convert the result to R. + template + constexpr __can_invoke_as_nonvoid<_Res, _Callable, _Args...> + __invoke_r(_Callable&& __fn, _Args&&... __args) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } + + // INVOKE when R is cv void + template + _GLIBCXX14_CONSTEXPR __can_invoke_as_void<_Res, _Callable, _Args...> + __invoke_r(_Callable&& __fn, _Args&&... __args) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_INVOKE_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ec154d6295b2ff40f1c9200849ee59f26df6deb5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@invoke.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h new file mode 100644 index 0000000000000000000000000000000000000000..2c33003ed071ce32a39c05f0420c418a85a43924 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h @@ -0,0 +1,1118 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ios_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +// +// ISO C++ 14882: 27.4 Iostreams base classes +// + +#ifndef _IOS_BASE_H +#define _IOS_BASE_H 1 + +#pragma GCC system_header + +#include +#include +#include + +#if __cplusplus < 201103L +# include +#else +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The following definitions of bitmask types are enums, not ints, + // as permitted (but not required) in the standard, in order to provide + // better type safety in iostream calls. A side effect is that in C++98 + // expressions involving them are not compile-time constants. + enum _Ios_Fmtflags + { + _S_boolalpha = 1L << 0, + _S_dec = 1L << 1, + _S_fixed = 1L << 2, + _S_hex = 1L << 3, + _S_internal = 1L << 4, + _S_left = 1L << 5, + _S_oct = 1L << 6, + _S_right = 1L << 7, + _S_scientific = 1L << 8, + _S_showbase = 1L << 9, + _S_showpoint = 1L << 10, + _S_showpos = 1L << 11, + _S_skipws = 1L << 12, + _S_unitbuf = 1L << 13, + _S_uppercase = 1L << 14, + _S_adjustfield = _S_left | _S_right | _S_internal, + _S_basefield = _S_dec | _S_oct | _S_hex, + _S_floatfield = _S_scientific | _S_fixed, + _S_ios_fmtflags_end = 1L << 16, + _S_ios_fmtflags_max = __INT_MAX__, + _S_ios_fmtflags_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator~(_Ios_Fmtflags __a) + { return _Ios_Fmtflags(~static_cast(__a)); } + + inline const _Ios_Fmtflags& + operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a | __b; } + + inline const _Ios_Fmtflags& + operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a & __b; } + + inline const _Ios_Fmtflags& + operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a ^ __b; } + + + enum _Ios_Openmode + { + _S_app = 1L << 0, + _S_ate = 1L << 1, + _S_bin = 1L << 2, + _S_in = 1L << 3, + _S_out = 1L << 4, + _S_trunc = 1L << 5, + _S_noreplace = 1L << 6, + _S_ios_openmode_end = 1L << 16, + _S_ios_openmode_max = __INT_MAX__, + _S_ios_openmode_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator&(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator|(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator^(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator~(_Ios_Openmode __a) + { return _Ios_Openmode(~static_cast(__a)); } + + inline const _Ios_Openmode& + operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a | __b; } + + inline const _Ios_Openmode& + operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a & __b; } + + inline const _Ios_Openmode& + operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a ^ __b; } + + + enum _Ios_Iostate + { + _S_goodbit = 0, + _S_badbit = 1L << 0, + _S_eofbit = 1L << 1, + _S_failbit = 1L << 2, + _S_ios_iostate_end = 1L << 16, + _S_ios_iostate_max = __INT_MAX__, + _S_ios_iostate_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator&(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator|(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator^(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator~(_Ios_Iostate __a) + { return _Ios_Iostate(~static_cast(__a)); } + + inline const _Ios_Iostate& + operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a | __b; } + + inline const _Ios_Iostate& + operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a & __b; } + + inline const _Ios_Iostate& + operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a ^ __b; } + + + enum _Ios_Seekdir + { + _S_beg = 0, + _S_cur = _GLIBCXX_STDIO_SEEK_CUR, + _S_end = _GLIBCXX_STDIO_SEEK_END, + _S_ios_seekdir_end = 1L << 16 + }; + +#if __cplusplus >= 201103L + /// I/O error code + enum class io_errc { stream = 1 }; + + template <> struct is_error_code_enum : public true_type { }; + + const error_category& iostream_category() noexcept; + + inline error_code + make_error_code(io_errc __e) noexcept + { return error_code(static_cast(__e), iostream_category()); } + + inline error_condition + make_error_condition(io_errc __e) noexcept + { return error_condition(static_cast(__e), iostream_category()); } +#endif + + // 27.4.2 Class ios_base + /** + * @brief The base of the I/O class hierarchy. + * @ingroup io + * + * This class defines everything that can be defined about I/O that does + * not depend on the type of characters being input or output. Most + * people will only see @c ios_base when they need to specify the full + * name of the various I/O flags (e.g., the openmodes). + */ + class ios_base + { +#if _GLIBCXX_USE_CXX11_ABI +#if __cplusplus < 201103L + // Type that is layout-compatible with std::system_error + struct system_error : std::runtime_error + { + // Type that is layout-compatible with std::error_code + struct error_code + { + error_code() { } + private: + int _M_value; + const void* _M_cat; + } _M_code; + }; +#endif +#endif + public: + + /** + * @brief These are thrown to indicate problems with io. + * @ingroup exceptions + * + * 27.4.2.1.1 Class ios_base::failure + */ +#if _GLIBCXX_USE_CXX11_ABI + class _GLIBCXX_ABI_TAG_CXX11 failure : public system_error + { + public: + explicit + failure(const string& __str); + +#if __cplusplus >= 201103L + explicit + failure(const string&, const error_code&); + + explicit + failure(const char*, const error_code& = io_errc::stream); +#endif + + virtual + ~failure() throw(); + + virtual const char* + what() const throw(); + }; +#else + class failure : public exception + { + public: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 48. Use of non-existent exception constructor + explicit + failure(const string& __str) throw(); + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html + virtual + ~failure() throw(); + + virtual const char* + what() const throw(); + +#if __cplusplus >= 201103L + // Define the new members required by C++11, + // even though the error_code cannot be stored. + + explicit + failure(const string& __s, const error_code&) noexcept + : failure(__s) + { } + + explicit + failure(const char* __s, const error_code& = error_code{}) + : failure(string(__s)) + { } + + // Stand-in for system_error::code() but returning by value. + error_code code() const noexcept { return error_code{}; } +#endif + + private: + string _M_msg; + }; +#endif + + // 27.4.2.1.2 Type ios_base::fmtflags + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Fmtflags is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type fmtflags are: + * - boolalpha + * - dec + * - fixed + * - hex + * - internal + * - left + * - oct + * - right + * - scientific + * - showbase + * - showpoint + * - showpos + * - skipws + * - unitbuf + * - uppercase + * - adjustfield + * - basefield + * - floatfield + */ + typedef _Ios_Fmtflags fmtflags; + + /// Insert/extract @c bool in alphabetic rather than numeric format. + static const fmtflags boolalpha = _S_boolalpha; + + /// Converts integer input or generates integer output in decimal base. + static const fmtflags dec = _S_dec; + + /// Generate floating-point output in fixed-point notation. + static const fmtflags fixed = _S_fixed; + + /// Converts integer input or generates integer output in hexadecimal base. + static const fmtflags hex = _S_hex; + + /// Adds fill characters at a designated internal point in certain + /// generated output, or identical to @c right if no such point is + /// designated. + static const fmtflags internal = _S_internal; + + /// Adds fill characters on the right (final positions) of certain + /// generated output. (I.e., the thing you print is flush left.) + static const fmtflags left = _S_left; + + /// Converts integer input or generates integer output in octal base. + static const fmtflags oct = _S_oct; + + /// Adds fill characters on the left (initial positions) of certain + /// generated output. (I.e., the thing you print is flush right.) + static const fmtflags right = _S_right; + + /// Generates floating-point output in scientific notation. + static const fmtflags scientific = _S_scientific; + + /// Generates a prefix indicating the numeric base of generated integer + /// output. + static const fmtflags showbase = _S_showbase; + + /// Generates a decimal-point character unconditionally in generated + /// floating-point output. + static const fmtflags showpoint = _S_showpoint; + + /// Generates a + sign in non-negative generated numeric output. + static const fmtflags showpos = _S_showpos; + + /// Skips leading white space before certain input operations. + static const fmtflags skipws = _S_skipws; + + /// Flushes output after each output operation. + static const fmtflags unitbuf = _S_unitbuf; + + /// Replaces certain lowercase letters with their uppercase equivalents + /// in generated output. + static const fmtflags uppercase = _S_uppercase; + + /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. + static const fmtflags adjustfield = _S_adjustfield; + + /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. + static const fmtflags basefield = _S_basefield; + + /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. + static const fmtflags floatfield = _S_floatfield; + + // 27.4.2.1.3 Type ios_base::iostate + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Iostate is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type iostate are: + * - badbit + * - eofbit + * - failbit + * - goodbit + */ + typedef _Ios_Iostate iostate; + + /// Indicates a loss of integrity in an input or output sequence (such + /// as an irrecoverable read error from a file). + static const iostate badbit = _S_badbit; + + /// Indicates that an input operation reached the end of an input sequence. + static const iostate eofbit = _S_eofbit; + + /// Indicates that an input operation failed to read the expected + /// characters, or that an output operation failed to generate the + /// desired characters. + static const iostate failbit = _S_failbit; + + /// Indicates all is well. + static const iostate goodbit = _S_goodbit; + + // 27.4.2.1.4 Type ios_base::openmode + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Openmode is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type openmode are: + * - app + * - ate + * - binary + * - in + * - out + * - trunc + */ + typedef _Ios_Openmode openmode; + + /// Seek to end before each write. + static const openmode app = _S_app; + + /// Open and seek to end immediately after opening. + static const openmode ate = _S_ate; + + /// Perform input and output in binary mode (as opposed to text mode). + /// This is probably not what you think it is; see + /// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary + static const openmode binary = _S_bin; + + /// Open for input. Default for @c ifstream and fstream. + static const openmode in = _S_in; + + /// Open for output. Default for @c ofstream and fstream. + static const openmode out = _S_out; + + /// Truncate an existing stream when opening. Default for @c ofstream. + static const openmode trunc = _S_trunc; + + static const openmode __noreplace = _S_noreplace; + +#if __cplusplus >= 202100L +#define __cpp_lib_ios_noreplace 202207L + /// Open a file in exclusive mode. + static const openmode noreplace = _S_noreplace; +#endif + + // 27.4.2.1.5 Type ios_base::seekdir + /** + * @brief This is an enumerated type. + * + * @c @a _Ios_Seekdir is implementation-defined. Defined values + * of type seekdir are: + * - beg + * - cur, equivalent to @c SEEK_CUR in the C standard library. + * - end, equivalent to @c SEEK_END in the C standard library. + */ + typedef _Ios_Seekdir seekdir; + + /// Request a seek relative to the beginning of the stream. + static const seekdir beg = _S_beg; + + /// Request a seek relative to the current position within the sequence. + static const seekdir cur = _S_cur; + + /// Request a seek relative to the current end of the sequence. + static const seekdir end = _S_end; + +#if __cplusplus <= 201402L + // Annex D.6 (removed in C++17) + typedef int io_state + _GLIBCXX_DEPRECATED_SUGGEST("std::iostate"); + typedef int open_mode + _GLIBCXX_DEPRECATED_SUGGEST("std::openmode"); + typedef int seek_dir + _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir"); + + typedef std::streampos streampos + _GLIBCXX_DEPRECATED_SUGGEST("std::streampos"); + typedef std::streamoff streamoff + _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff"); +#endif + + // Callbacks; + /** + * @brief The set of events that may be passed to an event callback. + * + * erase_event is used during ~ios() and copyfmt(). imbue_event is used + * during imbue(). copyfmt_event is used during copyfmt(). + */ + enum event + { + erase_event, + imbue_event, + copyfmt_event + }; + + /** + * @brief The type of an event callback function. + * @param __e One of the members of the event enum. + * @param __b Reference to the ios_base object. + * @param __i The integer provided when the callback was registered. + * + * Event callbacks are user defined functions that get called during + * several ios_base and basic_ios functions, specifically imbue(), + * copyfmt(), and ~ios(). + */ + typedef void (*event_callback) (event __e, ios_base& __b, int __i); + + /** + * @brief Add the callback __fn with parameter __index. + * @param __fn The function to add. + * @param __index The integer to pass to the function when invoked. + * + * Registers a function as an event callback with an integer parameter to + * be passed to the function when invoked. Multiple copies of the + * function are allowed. If there are multiple callbacks, they are + * invoked in the order they were registered. + */ + void + register_callback(event_callback __fn, int __index); + + protected: + streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + + // 27.4.2.6 Members for callbacks + // 27.4.2.6 ios_base callbacks + struct _Callback_list + { + // Data Members + _Callback_list* _M_next; + ios_base::event_callback _M_fn; + int _M_index; + _Atomic_word _M_refcount; // 0 means one reference. + + _Callback_list(ios_base::event_callback __fn, int __index, + _Callback_list* __cb) + : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } + + void + _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + // 0 => OK to delete. + int + _M_remove_reference() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); + if (__res == 0) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + } + return __res; + } + }; + + _Callback_list* _M_callbacks; + + void + _M_call_callbacks(event __ev) throw(); + + void + _M_dispose_callbacks(void) throw(); + + // 27.4.2.5 Members for iword/pword storage + struct _Words + { + void* _M_pword; + long _M_iword; + _Words() : _M_pword(0), _M_iword(0) { } + }; + + // Only for failed iword/pword calls. + _Words _M_word_zero; + + // Guaranteed storage. + // The first 5 iword and pword slots are reserved for internal use. + enum { _S_local_word_size = 8 }; + _Words _M_local_word[_S_local_word_size]; + + // Allocated storage. + int _M_word_size; + _Words* _M_word; + + _Words& + _M_grow_words(int __index, bool __iword); + + // Members for locale and locale caching. + locale _M_ios_locale; + + void + _M_init() throw(); + + public: + + // 27.4.2.1.6 Class ios_base::Init + // Used to initialize standard streams. In theory, g++ could use + // -finit-priority to order this stuff correctly without going + // through these machinations. + class Init + { + friend class ios_base; + public: + Init(); + ~Init(); + +#if __cplusplus >= 201103L + Init(const Init&) = default; + Init& operator=(const Init&) = default; +#endif + + private: + static _Atomic_word _S_refcount; + static bool _S_synced_with_stdio; + }; + + // [27.4.2.2] fmtflags state functions + /** + * @brief Access to format flags. + * @return The format control flags for both input and output. + */ + fmtflags + flags() const + { return _M_flags; } + + /** + * @brief Setting new format flags all at once. + * @param __fmtfl The new flags to set. + * @return The previous format control flags. + * + * This function overwrites all the format flags with @a __fmtfl. + */ + fmtflags + flags(fmtflags __fmtfl) + { + fmtflags __old = _M_flags; + _M_flags = __fmtfl; + return __old; + } + + /** + * @brief Setting new format flags. + * @param __fmtfl Additional flags to set. + * @return The previous format control flags. + * + * This function sets additional flags in format control. Flags that + * were previously set remain set. + */ + fmtflags + setf(fmtflags __fmtfl) + { + fmtflags __old = _M_flags; + _M_flags |= __fmtfl; + return __old; + } + + /** + * @brief Setting new format flags. + * @param __fmtfl Additional flags to set. + * @param __mask The flags mask for @a fmtfl. + * @return The previous format control flags. + * + * This function clears @a mask in the format flags, then sets + * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. + */ + fmtflags + setf(fmtflags __fmtfl, fmtflags __mask) + { + fmtflags __old = _M_flags; + _M_flags &= ~__mask; + _M_flags |= (__fmtfl & __mask); + return __old; + } + + /** + * @brief Clearing format flags. + * @param __mask The flags to unset. + * + * This function clears @a __mask in the format flags. + */ + void + unsetf(fmtflags __mask) + { _M_flags &= ~__mask; } + + /** + * @brief Flags access. + * @return The precision to generate on certain output operations. + * + * Be careful if you try to give a definition of @a precision here; see + * DR 189. + */ + streamsize + precision() const + { return _M_precision; } + + /** + * @brief Changing flags. + * @param __prec The new precision value. + * @return The previous value of precision(). + */ + streamsize + precision(streamsize __prec) + { + streamsize __old = _M_precision; + _M_precision = __prec; + return __old; + } + + /** + * @brief Flags access. + * @return The minimum field width to generate on output operations. + * + * Minimum field width refers to the number of characters. + */ + streamsize + width() const + { return _M_width; } + + /** + * @brief Changing flags. + * @param __wide The new width value. + * @return The previous value of width(). + */ + streamsize + width(streamsize __wide) + { + streamsize __old = _M_width; + _M_width = __wide; + return __old; + } + + // [27.4.2.4] ios_base static members + /** + * @brief Interaction with the standard C I/O objects. + * @param __sync Whether to synchronize or not. + * @return True if the standard streams were previously synchronized. + * + * The synchronization referred to is @e only that between the standard + * C facilities (e.g., stdout) and the standard C++ objects (e.g., + * cout). User-declared streams are unaffected. See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary + */ + static bool + sync_with_stdio(bool __sync = true); + + // [27.4.2.3] ios_base locale functions + /** + * @brief Setting a new locale. + * @param __loc The new locale. + * @return The previous locale. + * + * Sets the new locale for this stream, and then invokes each callback + * with imbue_event. + */ + locale + imbue(const locale& __loc) throw(); + + /** + * @brief Locale access + * @return A copy of the current locale. + * + * If @c imbue(loc) has previously been called, then this function + * returns @c loc. Otherwise, it returns a copy of @c std::locale(), + * the global C++ locale. + */ + locale + getloc() const + { return _M_ios_locale; } + + /** + * @brief Locale access + * @return A reference to the current locale. + * + * Like getloc above, but returns a reference instead of + * generating a copy. + */ + const locale& + _M_getloc() const + { return _M_ios_locale; } + + // [27.4.2.5] ios_base storage functions + /** + * @brief Access to unique indices. + * @return An integer different from all previous calls. + * + * This function returns a unique integer every time it is called. It + * can be used for any purpose, but is primarily intended to be a unique + * index for the iword and pword functions. The expectation is that an + * application calls xalloc in order to obtain an index in the iword and + * pword arrays that can be used without fear of conflict. + * + * The implementation maintains a static variable that is incremented and + * returned on each invocation. xalloc is guaranteed to return an index + * that is safe to use in the iword and pword arrays. + */ + static int + xalloc() throw(); + + /** + * @brief Access to integer array. + * @param __ix Index into the array. + * @return A reference to an integer associated with the index. + * + * The iword function provides access to an array of integers that can be + * used for any purpose. The array grows as required to hold the + * supplied index. All integers in the array are initialized to 0. + * + * The implementation reserves several indices. You should use xalloc to + * obtain an index that is safe to use. Also note that since the array + * can grow dynamically, it is not safe to hold onto the reference. + */ + long& + iword(int __ix) + { + _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) + ? _M_word[__ix] : _M_grow_words(__ix, true); + return __word._M_iword; + } + + /** + * @brief Access to void pointer array. + * @param __ix Index into the array. + * @return A reference to a void* associated with the index. + * + * The pword function provides access to an array of pointers that can be + * used for any purpose. The array grows as required to hold the + * supplied index. All pointers in the array are initialized to 0. + * + * The implementation reserves several indices. You should use xalloc to + * obtain an index that is safe to use. Also note that since the array + * can grow dynamically, it is not safe to hold onto the reference. + */ + void*& + pword(int __ix) + { + _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) + ? _M_word[__ix] : _M_grow_words(__ix, false); + return __word._M_pword; + } + + // Destructor + /** + * Invokes each callback with erase_event. Destroys local storage. + * + * Note that the ios_base object for the standard streams never gets + * destroyed. As a result, any callbacks registered with the standard + * streams will not get invoked with erase_event (unless copyfmt is + * used). + */ + virtual ~ios_base(); + + protected: + ios_base() throw (); + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 50. Copy constructor and assignment operator of ios_base + private: + ios_base(const ios_base&); + + ios_base& + operator=(const ios_base&); +#else + public: + ios_base(const ios_base&) = delete; + + ios_base& + operator=(const ios_base&) = delete; + + protected: + void + _M_move(ios_base&) noexcept; + + void + _M_swap(ios_base& __rhs) noexcept; +#endif + }; + + // [27.4.5.1] fmtflags manipulators + /// Calls base.setf(ios_base::boolalpha). + inline ios_base& + boolalpha(ios_base& __base) + { + __base.setf(ios_base::boolalpha); + return __base; + } + + /// Calls base.unsetf(ios_base::boolalpha). + inline ios_base& + noboolalpha(ios_base& __base) + { + __base.unsetf(ios_base::boolalpha); + return __base; + } + + /// Calls base.setf(ios_base::showbase). + inline ios_base& + showbase(ios_base& __base) + { + __base.setf(ios_base::showbase); + return __base; + } + + /// Calls base.unsetf(ios_base::showbase). + inline ios_base& + noshowbase(ios_base& __base) + { + __base.unsetf(ios_base::showbase); + return __base; + } + + /// Calls base.setf(ios_base::showpoint). + inline ios_base& + showpoint(ios_base& __base) + { + __base.setf(ios_base::showpoint); + return __base; + } + + /// Calls base.unsetf(ios_base::showpoint). + inline ios_base& + noshowpoint(ios_base& __base) + { + __base.unsetf(ios_base::showpoint); + return __base; + } + + /// Calls base.setf(ios_base::showpos). + inline ios_base& + showpos(ios_base& __base) + { + __base.setf(ios_base::showpos); + return __base; + } + + /// Calls base.unsetf(ios_base::showpos). + inline ios_base& + noshowpos(ios_base& __base) + { + __base.unsetf(ios_base::showpos); + return __base; + } + + /// Calls base.setf(ios_base::skipws). + inline ios_base& + skipws(ios_base& __base) + { + __base.setf(ios_base::skipws); + return __base; + } + + /// Calls base.unsetf(ios_base::skipws). + inline ios_base& + noskipws(ios_base& __base) + { + __base.unsetf(ios_base::skipws); + return __base; + } + + /// Calls base.setf(ios_base::uppercase). + inline ios_base& + uppercase(ios_base& __base) + { + __base.setf(ios_base::uppercase); + return __base; + } + + /// Calls base.unsetf(ios_base::uppercase). + inline ios_base& + nouppercase(ios_base& __base) + { + __base.unsetf(ios_base::uppercase); + return __base; + } + + /// Calls base.setf(ios_base::unitbuf). + inline ios_base& + unitbuf(ios_base& __base) + { + __base.setf(ios_base::unitbuf); + return __base; + } + + /// Calls base.unsetf(ios_base::unitbuf). + inline ios_base& + nounitbuf(ios_base& __base) + { + __base.unsetf(ios_base::unitbuf); + return __base; + } + + // [27.4.5.2] adjustfield manipulators + /// Calls base.setf(ios_base::internal, ios_base::adjustfield). + inline ios_base& + internal(ios_base& __base) + { + __base.setf(ios_base::internal, ios_base::adjustfield); + return __base; + } + + /// Calls base.setf(ios_base::left, ios_base::adjustfield). + inline ios_base& + left(ios_base& __base) + { + __base.setf(ios_base::left, ios_base::adjustfield); + return __base; + } + + /// Calls base.setf(ios_base::right, ios_base::adjustfield). + inline ios_base& + right(ios_base& __base) + { + __base.setf(ios_base::right, ios_base::adjustfield); + return __base; + } + + // [27.4.5.3] basefield manipulators + /// Calls base.setf(ios_base::dec, ios_base::basefield). + inline ios_base& + dec(ios_base& __base) + { + __base.setf(ios_base::dec, ios_base::basefield); + return __base; + } + + /// Calls base.setf(ios_base::hex, ios_base::basefield). + inline ios_base& + hex(ios_base& __base) + { + __base.setf(ios_base::hex, ios_base::basefield); + return __base; + } + + /// Calls base.setf(ios_base::oct, ios_base::basefield). + inline ios_base& + oct(ios_base& __base) + { + __base.setf(ios_base::oct, ios_base::basefield); + return __base; + } + + // [27.4.5.4] floatfield manipulators + /// Calls base.setf(ios_base::fixed, ios_base::floatfield). + inline ios_base& + fixed(ios_base& __base) + { + __base.setf(ios_base::fixed, ios_base::floatfield); + return __base; + } + + /// Calls base.setf(ios_base::scientific, ios_base::floatfield). + inline ios_base& + scientific(ios_base& __base) + { + __base.setf(ios_base::scientific, ios_base::floatfield); + return __base; + } + +#if __cplusplus >= 201103L + // New C++11 floatfield manipulators + + /// Calls + /// base.setf(ios_base::fixed|ios_base::scientific, ios_base::floatfield) + inline ios_base& + hexfloat(ios_base& __base) + { + __base.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); + return __base; + } + + /// Calls @c base.unsetf(ios_base::floatfield) + inline ios_base& + defaultfloat(ios_base& __base) + { + __base.unsetf(ios_base::floatfield); + return __base; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _IOS_BASE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4a21543d2ff886b65a4f48232a4007e8975fbe71 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ios_base.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc new file mode 100644 index 0000000000000000000000000000000000000000..a1a7d89335e08985e178752496a67314ccd9b3db --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc @@ -0,0 +1,1154 @@ +// istream classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/istream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{istream} + */ + +// +// ISO C++ 14882: 27.6.1 Input streams +// + +#ifndef _ISTREAM_TCC +#define _ISTREAM_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + basic_istream<_CharT, _Traits>::sentry:: + sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false) + { + ios_base::iostate __err = ios_base::goodbit; + if (__in.good()) + { + __try + { + if (__in.tie()) + __in.tie()->flush(); + if (!__noskip && bool(__in.flags() & ios_base::skipws)) + { + const __int_type __eof = traits_type::eof(); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); + + const __ctype_type& __ct = __check_facet(__in._M_ctype); + while (!traits_type::eq_int_type(__c, __eof) + && __ct.is(ctype_base::space, + traits_type::to_char_type(__c))) + __c = __sb->snextc(); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 195. Should basic_istream::sentry's constructor ever + // set eofbit? + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + } + + if (__in.good() && __err == ios_base::goodbit) + _M_ok = true; + else + { + __err |= ios_base::failbit; + __in.setstate(__err); + } + } + + template + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + _M_extract(_ValueT& __v) + { + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __v); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(short& __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__min; + } + else if (__l > __gnu_cxx::__numeric_traits::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__max; + } + else + __n = short(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(int& __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__min; + } + else if (__l > __gnu_cxx::__numeric_traits::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__max; + } + else + __n = int(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(__streambuf_type* __sbout) + { + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, false); + if (__cerb && __sbout) + { + __try + { + bool __ineof; + if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof)) + __err |= ios_base::failbit; + if (__ineof) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::failbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::failbit); } + } + else if (!__sbout) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + typename basic_istream<_CharT, _Traits>::int_type + basic_istream<_CharT, _Traits>:: + get(void) + { + const int_type __eof = traits_type::eof(); + int_type __c = __eof; + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + __c = this->rdbuf()->sbumpc(); + // 27.6.1.1 paragraph 3 + if (!traits_type::eq_int_type(__c, __eof)) + _M_gcount = 1; + else + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return __c; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(char_type& __c) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __cb = this->rdbuf()->sbumpc(); + // 27.6.1.1 paragraph 3 + if (!traits_type::eq_int_type(__cb, traits_type::eof())) + { + _M_gcount = 1; + __c = traits_type::to_char_type(__cb); + } + else + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(char_type* __s, streamsize __n, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + while (_M_gcount + 1 < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim)) + { + *__s++ = traits_type::to_char_type(__c); + ++_M_gcount; + __c = __sb->snextc(); + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(__streambuf_type& __sb, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __this_sb = this->rdbuf(); + int_type __c = __this_sb->sgetc(); + char_type __c2 = traits_type::to_char_type(__c); + unsigned long long __gcount = 0; + + while (!traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim) + && !traits_type::eq_int_type(__sb.sputc(__c2), __eof)) + { + ++__gcount; + __c = __this_sb->snextc(); + __c2 = traits_type::to_char_type(__c); + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3464. istream::gcount() can overflow + if (__gcount <= __gnu_cxx::__numeric_traits::__max) + _M_gcount = __gcount; + else + _M_gcount = __gnu_cxx::__numeric_traits::__max; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + getline(char_type* __s, streamsize __n, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + while (_M_gcount + 1 < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim)) + { + *__s++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + ++_M_gcount; + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + if (traits_type::eq_int_type(__c, __idelim)) + { + __sb->sbumpc(); + ++_M_gcount; + } + else + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + // We provide three overloads, since the first two are much simpler + // than the general case. Also, the latter two can thus adopt the + // same "batchy" strategy used by getline above. + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(void) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + + if (traits_type::eq_int_type(__sb->sbumpc(), __eof)) + __err |= ios_base::eofbit; + else + _M_gcount = 1; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // N.B. On LFS-enabled platforms streamsize is still 32 bits + // wide: if we want to implement the standard mandated behavior + // for n == max() (see 27.6.1.3/24) we are at risk of signed + // integer overflow: thus these contortions. Also note that, + // by definition, when more than 2G chars are actually ignored, + // _M_gcount (the return value of gcount, that is) cannot be + // really correct, being unavoidably too small. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == __gnu_cxx::__numeric_traits::__max + && !traits_type::eq_int_type(__c, __eof)) + { + _M_gcount = + __gnu_cxx::__numeric_traits::__min; + __large_ignore = true; + } + else + break; + } + + if (__n == __gnu_cxx::__numeric_traits::__max) + { + if (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + else if (_M_gcount < __n) + { + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n, int_type __delim) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // See comment above. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == __gnu_cxx::__numeric_traits::__max + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + _M_gcount = + __gnu_cxx::__numeric_traits::__min; + __large_ignore = true; + } + else + break; + } + + if (__n == __gnu_cxx::__numeric_traits::__max) + { + if (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + if (_M_gcount != __n) + ++_M_gcount; + __sb->sbumpc(); + } + } + else if (_M_gcount < __n) // implies __c == __delim or EOF + { + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + ++_M_gcount; + __sb->sbumpc(); + } + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + typename basic_istream<_CharT, _Traits>::int_type + basic_istream<_CharT, _Traits>:: + peek(void) + { + int_type __c = traits_type::eof(); + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + __c = this->rdbuf()->sgetc(); + if (traits_type::eq_int_type(__c, traits_type::eof())) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return __c; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + read(char_type* __s, streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + _M_gcount = this->rdbuf()->sgetn(__s, __n); + if (_M_gcount != __n) + __err |= (ios_base::eofbit | ios_base::failbit); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + streamsize + basic_istream<_CharT, _Traits>:: + readsome(char_type* __s, streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + // Cannot compare int_type with streamsize generically. + const streamsize __num = this->rdbuf()->in_avail(); + if (__num > 0) + _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n)); + else if (__num == -1) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return _M_gcount; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + putback(char_type __c) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 60. What is a formatted input function? + _M_gcount = 0; + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + if (!__sb + || traits_type::eq_int_type(__sb->sputbackc(__c), __eof)) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + unget(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 60. What is a formatted input function? + _M_gcount = 0; + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + if (!__sb + || traits_type::eq_int_type(__sb->sungetc(), __eof)) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + int + basic_istream<_CharT, _Traits>:: + sync(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + int __ret = -1; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + __streambuf_type* __sb = this->rdbuf(); + if (__sb) + { + if (__sb->pubsync() == -1) + __err |= ios_base::badbit; + else + __ret = 0; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return __ret; + } + + template + typename basic_istream<_CharT, _Traits>::pos_type + basic_istream<_CharT, _Traits>:: + tellg(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + pos_type __ret = pos_type(-1); + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, + ios_base::in); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + return __ret; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + seekg(pos_type __pos) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekpos(__pos, + ios_base::in); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + seekg(off_type __off, ios_base::seekdir __dir) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, + ios_base::in); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + // 27.6.1.2.3 Character extraction templates + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::int_type __int_type; + + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __int_type __cb = __in.rdbuf()->sbumpc(); + if (!_Traits::eq_int_type(__cb, _Traits::eof())) + __c = _Traits::to_char_type(__cb); + else + __err |= (ios_base::eofbit | ios_base::failbit); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + if (__err) + __in.setstate(__err); + } + return __in; + } + + template + void + __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s, + streamsize __num) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef typename _Traits::int_type int_type; + typedef _CharT char_type; + typedef ctype<_CharT> __ctype_type; + + streamsize __extracted = 0; + ios_base::iostate __err = ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + __try + { + // Figure out how many characters to extract. + streamsize __width = __in.width(); + if (0 < __width && __width < __num) + __num = __width; + + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + + const int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + int_type __c = __sb->sgetc(); + + while (__extracted < __num - 1 + && !_Traits::eq_int_type(__c, __eof) + && !__ct.is(ctype_base::space, + _Traits::to_char_type(__c))) + { + *__s++ = _Traits::to_char_type(__c); + ++__extracted; + __c = __sb->snextc(); + } + + if (__extracted < __num - 1 + && _Traits::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 68. Extractors for char* should store null at end + *__s = char_type(); + __in.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + } + if (!__extracted) + __err |= ios_base::failbit; + if (__err) + __in.setstate(__err); + } + + // 27.6.1.4 Standard basic_istream manipulators + template + basic_istream<_CharT, _Traits>& + ws(basic_istream<_CharT, _Traits>& __in) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef typename __istream_type::int_type __int_type; + typedef ctype<_CharT> __ctype_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 451. behavior of std::ws + typename __istream_type::sentry __cerb(__in, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); + + while (true) + { + if (_Traits::eq_int_type(__c, __eof)) + { + __err = ios_base::eofbit; + break; + } + if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c))) + break; + __c = __sb->snextc(); + } + } + __catch (const __cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch (...) + { + __in._M_setstate(ios_base::badbit); + } + if (__err) + __in.setstate(__err); + } + return __in; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_istream; + extern template istream& ws(istream&); + extern template istream& operator>>(istream&, char&); + extern template istream& operator>>(istream&, unsigned char&); + extern template istream& operator>>(istream&, signed char&); + + extern template istream& istream::_M_extract(unsigned short&); + extern template istream& istream::_M_extract(unsigned int&); + extern template istream& istream::_M_extract(long&); + extern template istream& istream::_M_extract(unsigned long&); + extern template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template istream& istream::_M_extract(long long&); + extern template istream& istream::_M_extract(unsigned long long&); +#endif + extern template istream& istream::_M_extract(float&); + extern template istream& istream::_M_extract(double&); + extern template istream& istream::_M_extract(long double&); + extern template istream& istream::_M_extract(void*&); + + extern template class basic_iostream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_istream; + extern template wistream& ws(wistream&); + extern template wistream& operator>>(wistream&, wchar_t&); + extern template void __istream_extract(wistream&, wchar_t*, streamsize); + + extern template wistream& wistream::_M_extract(unsigned short&); + extern template wistream& wistream::_M_extract(unsigned int&); + extern template wistream& wistream::_M_extract(long&); + extern template wistream& wistream::_M_extract(unsigned long&); + extern template wistream& wistream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wistream& wistream::_M_extract(long long&); + extern template wistream& wistream::_M_extract(unsigned long long&); +#endif + extern template wistream& wistream::_M_extract(float&); + extern template wistream& wistream::_M_extract(double&); + extern template wistream& wistream::_M_extract(long double&); + extern template wistream& wistream::_M_extract(void*&); + + extern template class basic_iostream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..df4578959922161b271b5a1bff53d3e76b6a49e2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@istream.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc new file mode 100644 index 0000000000000000000000000000000000000000..d6b6e975ff5b3eb4a40fc0261060c7664a8a0adf --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc @@ -0,0 +1,669 @@ +// List implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/list.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{list} + */ + +#ifndef _LIST_TCC +#define _LIST_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + void + _List_base<_Tp, _Alloc>:: + _M_clear() _GLIBCXX_NOEXCEPT + { + typedef _List_node<_Tp> _Node; + __detail::_List_node_base* __cur = _M_impl._M_node._M_next; + while (__cur != &_M_impl._M_node) + { + _Node* __tmp = static_cast<_Node*>(__cur); + __cur = __tmp->_M_next; + _Tp* __val = __tmp->_M_valptr(); +#if __cplusplus >= 201103L + _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val); +#else + _Tp_alloc_type(_M_get_Node_allocator()).destroy(__val); +#endif + _M_put_node(__tmp); + } + } + +#if __cplusplus >= 201103L + template + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + emplace(const_iterator __position, _Args&&... __args) + { + _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); + __tmp->_M_hook(__position._M_const_cast()._M_node); + this->_M_inc_size(1); + return iterator(__tmp); + } +#endif + + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + _Node* __tmp = _M_create_node(__x); + __tmp->_M_hook(__position._M_const_cast()._M_node); + this->_M_inc_size(1); + return iterator(__tmp); + } + +#if __cplusplus >= 201103L + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + insert(const_iterator __position, size_type __n, const value_type& __x) + { + if (__n) + { + list __tmp(__n, __x, get_allocator()); + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } + + template + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + list __tmp(__first, __last, get_allocator()); + if (!__tmp.empty()) + { + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } +#endif + + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + erase(const_iterator __position) noexcept +#else + erase(iterator __position) +#endif + { + iterator __ret = iterator(__position._M_node->_M_next); + _M_erase(__position._M_const_cast()); + return __ret; + } + + // Return a const_iterator indicating the position to start inserting or + // erasing elements (depending whether the list is growing or shrinking), + // and set __new_size to the number of new elements that must be appended. + // Equivalent to the following, but performed optimally: + // if (__new_size < size()) { + // __new_size = 0; + // return std::next(begin(), __new_size); + // } else { + // __newsize -= size(); + // return end(); + // } + template + typename list<_Tp, _Alloc>::const_iterator + list<_Tp, _Alloc>:: + _M_resize_pos(size_type& __new_size) const + { + const_iterator __i; +#if _GLIBCXX_USE_CXX11_ABI + const size_type __len = size(); + if (__new_size < __len) + { + if (__new_size <= __len / 2) + { + __i = begin(); + std::advance(__i, __new_size); + } + else + { + __i = end(); + ptrdiff_t __num_erase = __len - __new_size; + std::advance(__i, -__num_erase); + } + __new_size = 0; + return __i; + } + else + __i = end(); +#else + size_type __len = 0; + for (__i = begin(); __i != end() && __len < __new_size; ++__i, ++__len) + ; +#endif + __new_size -= __len; + return __i; + } + +#if __cplusplus >= 201103L + template + void + list<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + size_type __i = 0; + __try + { + for (; __i < __n; ++__i) + emplace_back(); + } + __catch(...) + { + for (; __i; --__i) + pop_back(); + __throw_exception_again; + } + } + + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + _M_default_append(__new_size); + else + erase(__i, end()); + } + + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size, const value_type& __x) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + insert(end(), __new_size, __x); + else + erase(__i, end()); + } +#else + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size, value_type __x) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + insert(end(), __new_size, __x); + else + erase(__i._M_const_cast(), end()); + } +#endif + + template + list<_Tp, _Alloc>& + list<_Tp, _Alloc>:: + operator=(const list& __x) + { + if (this != std::__addressof(__x)) + { +#if __cplusplus >= 201103L + if (_Node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __x._M_get_Node_allocator(); + if (!_Node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // replacement allocator cannot free existing storage + clear(); + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } +#endif + _M_assign_dispatch(__x.begin(), __x.end(), __false_type()); + } + return *this; + } + + template + void + list<_Tp, _Alloc>:: + _M_fill_assign(size_type __n, const value_type& __val) + { + iterator __i = begin(); + for (; __i != end() && __n > 0; ++__i, --__n) + *__i = __val; + if (__n > 0) + insert(end(), __n, __val); + else + erase(__i, end()); + } + + template + template + void + list<_Tp, _Alloc>:: + _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, + __false_type) + { + iterator __first1 = begin(); + iterator __last1 = end(); + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + +#if __cplusplus > 201703L +# define _GLIBCXX20_ONLY(__expr) __expr +#else +# define _GLIBCXX20_ONLY(__expr) +#endif + + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + remove(const value_type& __value) + { +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) + { + iterator __next = __first; + ++__next; + if (*__first == __value) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + __to_destroy.splice(__to_destroy.begin(), *this, __first); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + + __first = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + unique() + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY( 0 ); +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __next = __first; + while (++__next != __last) + { + if (*__first == *__next) + { + __to_destroy.splice(__to_destroy.begin(), *this, __next); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + __next = __first; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + void + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + merge(list&& __x) +#else + merge(list& __x) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + _M_check_equal_allocators(__x); + + iterator __first1 = begin(); + iterator __last1 = end(); + iterator __first2 = __x.begin(); + iterator __last2 = __x.end(); + + const _Finalize_merge __fin(*this, __x, __first2); + + while (__first1 != __last1 && __first2 != __last2) + if (*__first2 < *__first1) + { + iterator __next = __first2; + _M_transfer(__first1, __first2, ++__next); + __first2 = __next; + } + else + ++__first1; + if (__first2 != __last2) + { + _M_transfer(__last1, __first2, __last2); + __first2 = __last2; + } + } + } + + template + template + void + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + merge(list&& __x, _StrictWeakOrdering __comp) +#else + merge(list& __x, _StrictWeakOrdering __comp) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + _M_check_equal_allocators(__x); + + iterator __first1 = begin(); + iterator __last1 = end(); + iterator __first2 = __x.begin(); + iterator __last2 = __x.end(); + + const _Finalize_merge __fin(*this, __x, __first2); + + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first2, *__first1)) + { + iterator __next = __first2; + _M_transfer(__first1, __first2, ++__next); + __first2 = __next; + } + else + ++__first1; + if (__first2 != __last2) + { + _M_transfer(__last1, __first2, __last2); + __first2 = __last2; + } + } + } + + template + void + list<_Tp, _Alloc>:: + sort() + { + // Do nothing if the list has length 0 or 1. + if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node + && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) + { + using __detail::_Scratch_list; + // The algorithm used here is largely unchanged from the SGI STL + // and is described in The C++ Standard Template Library by Plauger, + // Stepanov, Lee, Musser. + // Each element of *this is spliced out and merged into one of the + // sorted lists in __tmp, then all the lists in __tmp are merged + // together and then swapped back into *this. + // Because all nodes end up back in *this we do not need to update + // this->size() while nodes are temporarily moved out. + _Scratch_list __carry; + _Scratch_list __tmp[64]; + _Scratch_list* __fill = __tmp; + _Scratch_list* __counter; + + _Scratch_list::_Ptr_cmp __ptr_comp; + + __try + { + do + { + __carry._M_take_one(begin()._M_node); + + for(__counter = __tmp; + __counter != __fill && !__counter->empty(); + ++__counter) + { + + __counter->merge(__carry, __ptr_comp); + __carry.swap(*__counter); + } + __carry.swap(*__counter); + if (__counter == __fill) + ++__fill; + } + while ( !empty() ); + + for (__counter = __tmp + 1; __counter != __fill; ++__counter) + __counter->merge(__counter[-1], __ptr_comp); + __fill[-1].swap(this->_M_impl._M_node); + } + __catch(...) + { + // Move all nodes back into *this. + __carry._M_put_all(end()._M_node); + for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) + __tmp[__i]._M_put_all(end()._M_node); + __throw_exception_again; + } + } + } + + template + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + remove_if(_Predicate __pred) + { +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) + { + iterator __next = __first; + ++__next; + if (__pred(*__first)) + { + __to_destroy.splice(__to_destroy.begin(), *this, __first); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + __first = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + unique(_BinaryPredicate __binary_pred) + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY(0); +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(*__first, *__next)) + { + __to_destroy.splice(__to_destroy.begin(), *this, __next); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + __next = __first; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + +#undef _GLIBCXX20_ONLY + + template + template + void + list<_Tp, _Alloc>:: + sort(_StrictWeakOrdering __comp) + { + // Do nothing if the list has length 0 or 1. + if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node + && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) + { + using __detail::_Scratch_list; + _Scratch_list __carry; + _Scratch_list __tmp[64]; + _Scratch_list* __fill = __tmp; + _Scratch_list* __counter; + + _Scratch_list::_Ptr_cmp __ptr_comp + = { __comp }; + + __try + { + do + { + __carry._M_take_one(begin()._M_node); + + for(__counter = __tmp; + __counter != __fill && !__counter->empty(); + ++__counter) + { + + __counter->merge(__carry, __ptr_comp); + __carry.swap(*__counter); + } + __carry.swap(*__counter); + if (__counter == __fill) + ++__fill; + } + while ( !empty() ); + + for (__counter = __tmp + 1; __counter != __fill; ++__counter) + __counter->merge(__counter[-1], __ptr_comp); + __fill[-1].swap(this->_M_impl._M_node); + } + __catch(...) + { + // Move all nodes back into *this. + __carry._M_put_all(end()._M_node); + for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) + __tmp[__i]._M_put_all(end()._M_node); + __throw_exception_again; + } + } + } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _LIST_TCC */ + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..f7066529a136257776a247f5a109a6d7889b4f05 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@list.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h new file mode 100644 index 0000000000000000000000000000000000000000..6cad0ff565576fa4191cb43aca2e3e3f63b4985a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h @@ -0,0 +1,859 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_classes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_CLASSES_H +#define _LOCALE_CLASSES_H 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 22.1.1 Class locale + /** + * @brief Container class for localization functionality. + * @ingroup locales + * + * The locale class is first a class wrapper for C library locales. It is + * also an extensible container for user-defined localization. A locale is + * a collection of facets that implement various localization features such + * as money, time, and number printing. + * + * Constructing C++ locales does not change the C library locale. + * + * This library supports efficient construction and copying of locales + * through a reference counting implementation of the locale class. + */ + class locale + { + public: + // Types: + /// Definition of locale::category. + typedef int category; + + // Forward decls and friends: + class facet; + class id; + class _Impl; + + friend class facet; + friend class _Impl; + + template + friend bool + has_facet(const locale&) throw(); + + template + friend const _Facet& + use_facet(const locale&); + + template + friend struct __use_cache; + + ///@{ + /** + * @brief Category values. + * + * The standard category values are none, ctype, numeric, collate, time, + * monetary, and messages. They form a bitmask that supports union and + * intersection. The category all is the union of these values. + * + * NB: Order must match _S_facet_categories definition in locale.cc + */ + static const category none = 0; + static const category ctype = 1L << 0; + static const category numeric = 1L << 1; + static const category collate = 1L << 2; + static const category time = 1L << 3; + static const category monetary = 1L << 4; + static const category messages = 1L << 5; + static const category all = (ctype | numeric | collate | + time | monetary | messages); + ///@} + + // Construct/copy/destroy: + + /** + * @brief Default constructor. + * + * Constructs a copy of the global locale. If no locale has been + * explicitly set, this is the C locale. + */ + locale() throw(); + + /** + * @brief Copy constructor. + * + * Constructs a copy of @a other. + * + * @param __other The locale to copy. + */ + locale(const locale& __other) throw(); + + /** + * @brief Named locale constructor. + * + * Constructs a copy of the named C library locale. + * + * @param __s Name of the locale to construct. + * @throw std::runtime_error if __s is null or an undefined locale. + */ + explicit + locale(const char* __s); + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale named by @a s. If base is + * named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __s Name of the locale to use facets from. + * @param __cat Set of categories defining the facets to use from __s. + * @throw std::runtime_error if __s is null or an undefined locale. + */ + locale(const locale& __base, const char* __s, category __cat); + +#if __cplusplus >= 201103L + /** + * @brief Named locale constructor. + * + * Constructs a copy of the named C library locale. + * + * @param __s Name of the locale to construct. + * @throw std::runtime_error if __s is an undefined locale. + */ + explicit + locale(const std::string& __s) : locale(__s.c_str()) { } + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale named by @a s. If base is + * named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __s Name of the locale to use facets from. + * @param __cat Set of categories defining the facets to use from __s. + * @throw std::runtime_error if __s is an undefined locale. + */ + locale(const locale& __base, const std::string& __s, category __cat) + : locale(__base, __s.c_str(), __cat) { } +#endif + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale @a add. If @a base and @a + * add are named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __add The locale to use facets from. + * @param __cat Set of categories defining the facets to use from add. + */ + locale(const locale& __base, const locale& __add, category __cat); + + /** + * @brief Construct locale with another facet. + * + * Constructs a copy of the locale @a __other. The facet @a __f + * is added to @a __other, replacing an existing facet of type + * Facet if there is one. If @a __f is null, this locale is a + * copy of @a __other. + * + * @param __other The locale to copy. + * @param __f The facet to add in. + */ + template + locale(const locale& __other, _Facet* __f); + + /// Locale destructor. + ~locale() throw(); + + /** + * @brief Assignment operator. + * + * Set this locale to be a copy of @a other. + * + * @param __other The locale to copy. + * @return A reference to this locale. + */ + const locale& + operator=(const locale& __other) throw(); + + /** + * @brief Construct locale with another facet. + * + * Constructs and returns a new copy of this locale. Adds or replaces an + * existing facet of type Facet from the locale @a other into the new + * locale. + * + * @tparam _Facet The facet type to copy from other + * @param __other The locale to copy from. + * @return Newly constructed locale. + * @throw std::runtime_error if __other has no facet of type _Facet. + */ + template + locale + combine(const locale& __other) const; + + // Locale operations: + /** + * @brief Return locale name. + * @return Locale name or "*" if unnamed. + */ + _GLIBCXX_DEFAULT_ABI_TAG + string + name() const; + + /** + * @brief Locale equality. + * + * @param __other The locale to compare against. + * @return True if other and this refer to the same locale instance, are + * copies, or have the same name. False otherwise. + */ + bool + operator==(const locale& __other) const throw(); + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Locale inequality. + * + * @param __other The locale to compare against. + * @return ! (*this == __other) + */ + bool + operator!=(const locale& __other) const throw() + { return !(this->operator==(__other)); } +#endif + + /** + * @brief Compare two strings according to collate. + * + * Template operator to compare two strings using the compare function of + * the collate facet in this locale. One use is to provide the locale to + * the sort function. For example, a vector v of strings could be sorted + * according to locale loc by doing: + * @code + * std::sort(v.begin(), v.end(), loc); + * @endcode + * + * @param __s1 First string to compare. + * @param __s2 Second string to compare. + * @return True if collate<_Char> facet compares __s1 < __s2, else false. + */ + template + bool + operator()(const basic_string<_Char, _Traits, _Alloc>& __s1, + const basic_string<_Char, _Traits, _Alloc>& __s2) const; + + // Global locale objects: + /** + * @brief Set global locale + * + * This function sets the global locale to the argument and returns a + * copy of the previous global locale. If the argument has a name, it + * will also call std::setlocale(LC_ALL, loc.name()). + * + * @param __loc The new locale to make global. + * @return Copy of the old global locale. + */ + static locale + global(const locale& __loc); + + /** + * @brief Return reference to the C locale. + */ + static const locale& + classic(); + + private: + // The (shared) implementation + _Impl* _M_impl; + + // The "C" reference locale + static _Impl* _S_classic; + + // Current global locale + static _Impl* _S_global; + + // Names of underlying locale categories. + // NB: locale::global() has to know how to modify all the + // underlying categories, not just the ones required by the C++ + // standard. + static const char* const* const _S_categories; + + // Number of standard categories. For C++, these categories are + // collate, ctype, monetary, numeric, time, and messages. These + // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE, + // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE + // 1003.1-2001) specifies LC_MESSAGES. + // In addition to the standard categories, the underlying + // operating system is allowed to define extra LC_* + // macros. For GNU systems, the following are also valid: + // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, + // and LC_IDENTIFICATION. + enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES }; + +#ifdef __GTHREADS + static __gthread_once_t _S_once; +#endif + + explicit + locale(_Impl*) throw(); + + static void + _S_initialize(); + + static void + _S_initialize_once() throw(); + + static category + _S_normalize_category(category); + + void + _M_coalesce(const locale& __base, const locale& __add, category __cat); + +#if _GLIBCXX_USE_CXX11_ABI + static const id* const _S_twinned_facets[]; +#endif + }; + + + // 22.1.1.1.2 Class locale::facet + /** + * @brief Localization functionality base class. + * @ingroup locales + * + * The facet class is the base class for a localization feature, such as + * money, time, and number printing. It provides common support for facets + * and reference management. + * + * Facets may not be copied or assigned. + */ + class locale::facet + { + private: + friend class locale; + friend class locale::_Impl; + + mutable _Atomic_word _M_refcount; + + // Contains data from the underlying "C" library for the classic locale. + static __c_locale _S_c_locale; + + // String literal for the name of the classic locale. + static const char _S_c_name[2]; + +#ifdef __GTHREADS + static __gthread_once_t _S_once; +#endif + + static void + _S_initialize_once(); + + protected: + /** + * @brief Facet constructor. + * + * This is the constructor provided by the standard. If refs is 0, the + * facet is destroyed when the last referencing locale is destroyed. + * Otherwise the facet will never be destroyed. + * + * @param __refs The initial value for reference count. + */ + explicit + facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0) + { } + + /// Facet destructor. + virtual + ~facet(); + + static void + _S_create_c_locale(__c_locale& __cloc, const char* __s, + __c_locale __old = 0); + + static __c_locale + _S_clone_c_locale(__c_locale& __cloc) throw(); + + static void + _S_destroy_c_locale(__c_locale& __cloc); + + static __c_locale + _S_lc_ctype_c_locale(__c_locale __cloc, const char* __s); + + // Returns data from the underlying "C" library data for the + // classic locale. + static __c_locale + _S_get_c_locale(); + + _GLIBCXX_CONST static const char* + _S_get_c_name() throw(); + +#if __cplusplus < 201103L + private: + facet(const facet&); // Not defined. + + facet& + operator=(const facet&); // Not defined. +#else + facet(const facet&) = delete; + + facet& + operator=(const facet&) = delete; +#endif + + private: + void + _M_add_reference() const throw() + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + void + _M_remove_reference() const throw() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + __try + { delete this; } + __catch(...) + { } + } + } + + const facet* _M_sso_shim(const id*) const; + const facet* _M_cow_shim(const id*) const; + + protected: + class __shim; // For internal use only. + }; + + + // 22.1.1.1.3 Class locale::id + /** + * @brief Facet ID class. + * @ingroup locales + * + * The ID class provides facets with an index used to identify them. + * Every facet class must define a public static member locale::id, or be + * derived from a facet that provides this member, otherwise the facet + * cannot be used in a locale. The locale::id ensures that each class + * type gets a unique identifier. + */ + class locale::id + { + private: + friend class locale; + friend class locale::_Impl; + + template + friend const _Facet& + use_facet(const locale&); + + template + friend bool + has_facet(const locale&) throw(); + + // NB: There is no accessor for _M_index because it may be used + // before the constructor is run; the effect of calling a member + // function (even an inline) would be undefined. + mutable size_t _M_index; + + // Last id number assigned. + static _Atomic_word _S_refcount; + + void + operator=(const id&); // Not defined. + + id(const id&); // Not defined. + + public: + // NB: This class is always a static data member, and thus can be + // counted on to be zero-initialized. + /// Constructor. + id() { } + + size_t + _M_id() const throw(); + }; + + + // Implementation object for locale. + class locale::_Impl + { + public: + // Friends. + friend class locale; + friend class locale::facet; + + template + friend bool + has_facet(const locale&) throw(); + + template + friend const _Facet& + use_facet(const locale&); + + template + friend struct __use_cache; + + private: + // Data Members. + _Atomic_word _M_refcount; + const facet** _M_facets; + size_t _M_facets_size; + const facet** _M_caches; + char** _M_names; + static const locale::id* const _S_id_ctype[]; + static const locale::id* const _S_id_numeric[]; + static const locale::id* const _S_id_collate[]; + static const locale::id* const _S_id_time[]; + static const locale::id* const _S_id_monetary[]; + static const locale::id* const _S_id_messages[]; + static const locale::id* const* const _S_facet_categories[]; + + void + _M_add_reference() throw() + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + void + _M_remove_reference() throw() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + __try + { delete this; } + __catch(...) + { } + } + } + + _Impl(const _Impl&, size_t); + _Impl(const char*, size_t); + _Impl(size_t) throw(); + + ~_Impl() throw(); + + _Impl(const _Impl&); // Not defined. + + void + operator=(const _Impl&); // Not defined. + + bool + _M_check_same_name() + { + bool __ret = true; + if (_M_names[1]) + // We must actually compare all the _M_names: can be all equal! + for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) + __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0; + return __ret; + } + + void + _M_replace_categories(const _Impl*, category); + + void + _M_replace_category(const _Impl*, const locale::id* const*); + + void + _M_replace_facet(const _Impl*, const locale::id*); + + void + _M_install_facet(const locale::id*, const facet*); + + template + void + _M_init_facet(_Facet* __facet) + { _M_install_facet(&_Facet::id, __facet); } + + template + void + _M_init_facet_unchecked(_Facet* __facet) + { + __facet->_M_add_reference(); + _M_facets[_Facet::id._M_id()] = __facet; + } + + void + _M_install_cache(const facet*, size_t); + + void _M_init_extra(facet**); + void _M_init_extra(void*, void*, const char*, const char*); + +#ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT + void _M_init_extra_ldbl128(bool); +#endif + }; + + + /** + * @brief Facet for localized string comparison. + * + * This facet encapsulates the code to compare strings in a localized + * manner. + * + * The collate template uses protected virtual functions to provide + * the actual results. The public accessors forward the call to + * the virtual functions. These virtual functions are hooks for + * developers to implement the behavior they require from the + * collate facet. + */ + template + class _GLIBCXX_NAMESPACE_CXX11 collate : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + protected: + // Underlying "C" library locale information saved from + // initialization, needed by collate_byname as well. + __c_locale _M_c_locale_collate; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + collate(size_t __refs = 0) + : facet(__refs), _M_c_locale_collate(_S_get_c_locale()) + { } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __refs Passed to the base facet class. + */ + explicit + collate(__c_locale __cloc, size_t __refs = 0) + : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc)) + { } + + /** + * @brief Compare two strings. + * + * This function compares two strings and returns the result by calling + * collate::do_compare(). + * + * @param __lo1 Start of string 1. + * @param __hi1 End of string 1. + * @param __lo2 Start of string 2. + * @param __hi2 End of string 2. + * @return 1 if string1 > string2, -1 if string1 < string2, else 0. + */ + int + compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const + { return this->do_compare(__lo1, __hi1, __lo2, __hi2); } + + /** + * @brief Transform string to comparable form. + * + * This function is a wrapper for strxfrm functionality. It takes the + * input string and returns a modified string that can be directly + * compared to other transformed strings. In the C locale, this + * function just returns a copy of the input string. In some other + * locales, it may replace two chars with one, change a char for + * another, etc. It does so by returning collate::do_transform(). + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Transformed string_type. + */ + string_type + transform(const _CharT* __lo, const _CharT* __hi) const + { return this->do_transform(__lo, __hi); } + + /** + * @brief Return hash of a string. + * + * This function computes and returns a hash on the input string. It + * does so by returning collate::do_hash(). + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Hash value. + */ + long + hash(const _CharT* __lo, const _CharT* __hi) const + { return this->do_hash(__lo, __hi); } + + // Used to abstract out _CharT bits in virtual member functions, below. + int + _M_compare(const _CharT*, const _CharT*) const throw(); + + size_t + _M_transform(_CharT*, const _CharT*, size_t) const throw(); + + protected: + /// Destructor. + virtual + ~collate() + { _S_destroy_c_locale(_M_c_locale_collate); } + + /** + * @brief Compare two strings. + * + * This function is a hook for derived classes to change the value + * returned. @see compare(). + * + * @param __lo1 Start of string 1. + * @param __hi1 End of string 1. + * @param __lo2 Start of string 2. + * @param __hi2 End of string 2. + * @return 1 if string1 > string2, -1 if string1 < string2, else 0. + */ + virtual int + do_compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const; + + /** + * @brief Transform string to comparable form. + * + * This function is a hook for derived classes to change the value + * returned. + * + * @param __lo Start. + * @param __hi End. + * @return transformed string. + */ + virtual string_type + do_transform(const _CharT* __lo, const _CharT* __hi) const; + + /** + * @brief Return hash of a string. + * + * This function computes and returns a hash on the input string. This + * function is a hook for derived classes to change the value returned. + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Hash value. + */ + virtual long + do_hash(const _CharT* __lo, const _CharT* __hi) const; + }; + + template + locale::id collate<_CharT>::id; + + // Specializations. + template<> + int + collate::_M_compare(const char*, const char*) const throw(); + + template<> + size_t + collate::_M_transform(char*, const char*, size_t) const throw(); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + int + collate::_M_compare(const wchar_t*, const wchar_t*) const throw(); + + template<> + size_t + collate::_M_transform(wchar_t*, const wchar_t*, size_t) const throw(); +#endif + + /// class collate_byname [22.2.4.2]. + template + class _GLIBCXX_NAMESPACE_CXX11 collate_byname : public collate<_CharT> + { + public: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + explicit + collate_byname(const char* __s, size_t __refs = 0) + : collate<_CharT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_collate); + this->_S_create_c_locale(this->_M_c_locale_collate, __s); + } + } + +#if __cplusplus >= 201103L + explicit + collate_byname(const string& __s, size_t __refs = 0) + : collate_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~collate_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +# include + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a1b849364301b42fc697589ba64dd80be91e7a13 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc new file mode 100644 index 0000000000000000000000000000000000000000..64cd7534dc652f2684d7d3cc1aef87208438dd17 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc @@ -0,0 +1,298 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_classes.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_CLASSES_TCC +#define _LOCALE_CLASSES_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + locale:: + locale(const locale& __other, _Facet* __f) + { + _M_impl = new _Impl(*__other._M_impl, 1); + + __try + { _M_impl->_M_install_facet(&_Facet::id, __f); } + __catch(...) + { + _M_impl->_M_remove_reference(); + __throw_exception_again; + } + delete [] _M_impl->_M_names[0]; + _M_impl->_M_names[0] = 0; // Unnamed. + } + + template + locale + locale:: + combine(const locale& __other) const + { + _Impl* __tmp = new _Impl(*_M_impl, 1); + __try + { + __tmp->_M_replace_facet(__other._M_impl, &_Facet::id); + } + __catch(...) + { + __tmp->_M_remove_reference(); + __throw_exception_again; + } + return locale(__tmp); + } + + template + bool + locale:: + operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1, + const basic_string<_CharT, _Traits, _Alloc>& __s2) const + { + typedef std::collate<_CharT> __collate_type; + const __collate_type& __collate = use_facet<__collate_type>(*this); + return (__collate.compare(__s1.data(), __s1.data() + __s1.length(), + __s2.data(), __s2.data() + __s2.length()) < 0); + } + + /** + * @brief Test for the presence of a facet. + * @ingroup locales + * + * has_facet tests the locale argument for the presence of the facet type + * provided as the template parameter. Facets derived from the facet + * parameter will also return true. + * + * @tparam _Facet The facet type to test the presence of. + * @param __loc The locale to test. + * @return true if @p __loc contains a facet of type _Facet, else false. + */ + template + bool + has_facet(const locale& __loc) throw() + { + const size_t __i = _Facet::id._M_id(); + const locale::facet** __facets = __loc._M_impl->_M_facets; + return (__i < __loc._M_impl->_M_facets_size +#if __cpp_rtti + && dynamic_cast(__facets[__i])); +#else + && static_cast(__facets[__i])); +#endif + } + + /** + * @brief Return a facet. + * @ingroup locales + * + * use_facet looks for and returns a reference to a facet of type Facet + * where Facet is the template parameter. If has_facet(locale) is true, + * there is a suitable facet to return. It throws std::bad_cast if the + * locale doesn't contain a facet of type Facet. + * + * @tparam _Facet The facet type to access. + * @param __loc The locale to use. + * @return Reference to facet of type Facet. + * @throw std::bad_cast if @p __loc doesn't contain a facet of type _Facet. + */ + template + const _Facet& + use_facet(const locale& __loc) + { + const size_t __i = _Facet::id._M_id(); + const locale::facet** __facets = __loc._M_impl->_M_facets; + if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i]) + __throw_bad_cast(); +#if __cpp_rtti + return dynamic_cast(*__facets[__i]); +#else + return static_cast(*__facets[__i]); +#endif + } + + + // Generic version does nothing. + template + int + collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const throw () + { return 0; } + + // Generic version does nothing. + template + size_t + collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const throw () + { return 0; } + + template + int + collate<_CharT>:: + do_compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const + { + // strcoll assumes zero-terminated strings so we make a copy + // and then put a zero at the end. + const string_type __one(__lo1, __hi1); + const string_type __two(__lo2, __hi2); + + const _CharT* __p = __one.c_str(); + const _CharT* __pend = __one.data() + __one.length(); + const _CharT* __q = __two.c_str(); + const _CharT* __qend = __two.data() + __two.length(); + + // strcoll stops when it sees a nul character so we break + // the strings into zero-terminated substrings and pass those + // to strcoll. + for (;;) + { + const int __res = _M_compare(__p, __q); + if (__res) + return __res; + + __p += char_traits<_CharT>::length(__p); + __q += char_traits<_CharT>::length(__q); + if (__p == __pend && __q == __qend) + return 0; + else if (__p == __pend) + return -1; + else if (__q == __qend) + return 1; + + __p++; + __q++; + } + } + + template + typename collate<_CharT>::string_type + collate<_CharT>:: + do_transform(const _CharT* __lo, const _CharT* __hi) const + { + string_type __ret; + + // strxfrm assumes zero-terminated strings so we make a copy + const string_type __str(__lo, __hi); + + const _CharT* __p = __str.c_str(); + const _CharT* __pend = __str.data() + __str.length(); + + size_t __len = (__hi - __lo) * 2; + + _CharT* __c = new _CharT[__len]; + + __try + { + // strxfrm stops when it sees a nul character so we break + // the string into zero-terminated substrings and pass those + // to strxfrm. + for (;;) + { + // First try a buffer perhaps big enough. + size_t __res = _M_transform(__c, __p, __len); + // If the buffer was not large enough, try again with the + // correct size. + if (__res >= __len) + { + __len = __res + 1; + delete [] __c, __c = 0; + __c = new _CharT[__len]; + __res = _M_transform(__c, __p, __len); + } + + __ret.append(__c, __res); + __p += char_traits<_CharT>::length(__p); + if (__p == __pend) + break; + + __p++; + __ret.push_back(_CharT()); + } + } + __catch(...) + { + delete [] __c; + __throw_exception_again; + } + + delete [] __c; + + return __ret; + } + + template + long + collate<_CharT>:: + do_hash(const _CharT* __lo, const _CharT* __hi) const + { + unsigned long __val = 0; + for (; __lo < __hi; ++__lo) + __val = + *__lo + ((__val << 7) + | (__val >> (__gnu_cxx::__numeric_traits:: + __digits - 7))); + return static_cast(__val); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class collate; + extern template class collate_byname; + + extern template + const collate& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class collate; + extern template class collate_byname; + + extern template + const collate& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..e6cd64fcedc9b2a4b53101886b4456e07a8bdafc Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_classes.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h new file mode 100644 index 0000000000000000000000000000000000000000..ae006b8152230c3e8f50f38ba2d30d601b7d0858 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h @@ -0,0 +1,634 @@ +// wstring_convert implementation -*- C++ -*- + +// Copyright (C) 2015-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_conv.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_CONV_H +#define _LOCALE_CONV_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup locales + * @{ + */ + + template + bool + __do_str_codecvt(const _InChar* __first, const _InChar* __last, + _OutStr& __outstr, const _Codecvt& __cvt, _State& __state, + size_t& __count, _Fn __fn) + { + if (__first == __last) + { + __outstr.clear(); + __count = 0; + return true; + } + + size_t __outchars = 0; + auto __next = __first; + const auto __maxlen = __cvt.max_length() + 1; + + codecvt_base::result __result; + do + { + __outstr.resize(__outstr.size() + (__last - __next) * __maxlen); + auto __outnext = &__outstr.front() + __outchars; + auto const __outlast = &__outstr.back() + 1; + __result = (__cvt.*__fn)(__state, __next, __last, __next, + __outnext, __outlast, __outnext); + __outchars = __outnext - &__outstr.front(); + } + while (__result == codecvt_base::partial && __next != __last + && ptrdiff_t(__outstr.size() - __outchars) < __maxlen); + + if (__result == codecvt_base::error) + { + __count = __next - __first; + return false; + } + + // The codecvt facet will only return noconv when the types are + // the same, so avoid instantiating basic_string::assign otherwise + if _GLIBCXX17_CONSTEXPR (is_same()) + if (__result == codecvt_base::noconv) + { + __outstr.assign(__first, __last); + __count = __last - __first; + return true; + } + + __outstr.resize(__outchars); + __count = __next - __first; + return true; + } + + // Convert narrow character string to wide. + template + inline bool + __str_codecvt_in(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const char*, const char*, const char*&, + _CharT*, _CharT*, _CharT*&) const; + _ConvFn __fn = &codecvt<_CharT, char, _State>::in; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + // As above, but with no __count parameter + template + inline bool + __str_codecvt_in(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n); + } + + // As above, but returns false for partial conversion + template + inline bool + __str_codecvt_in_all(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n) + && (__n == size_t(__last - __first)); + } + + // Convert wide character string to narrow. + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&, + char*, char*, char*&) const; + _ConvFn __fn = &codecvt<_CharT, char, _State>::out; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + // As above, but with no __count parameter + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); + } + + // As above, but returns false for partial conversions + template + inline bool + __str_codecvt_out_all(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n) + && (__n == size_t(__last - __first)); + } + +#ifdef _GLIBCXX_USE_CHAR8_T + + // Convert wide character string to narrow. + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char8_t, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char8_t, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&, + char8_t*, char8_t*, char8_t*&) const; + _ConvFn __fn = &codecvt<_CharT, char8_t, _State>::out; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char8_t, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); + } + +#endif // _GLIBCXX_USE_CHAR8_T + + namespace __detail + { + template + struct _Scoped_ptr + { + __attribute__((__nonnull__(2))) + explicit + _Scoped_ptr(_Tp* __ptr) noexcept + : _M_ptr(__ptr) + { } + + _Scoped_ptr(_Tp* __ptr, const char* __msg) + : _M_ptr(__ptr) + { + if (!__ptr) + __throw_logic_error(__msg); + } + + ~_Scoped_ptr() { delete _M_ptr; } + + _Scoped_ptr(const _Scoped_ptr&) = delete; + _Scoped_ptr& operator=(const _Scoped_ptr&) = delete; + + __attribute__((__returns_nonnull__)) + _Tp* operator->() const noexcept { return _M_ptr; } + + _Tp& operator*() const noexcept { return *_M_ptr; } + + private: + _Tp* _M_ptr; + }; + } + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /// String conversions + template, + typename _Byte_alloc = allocator> + class wstring_convert + { + public: + typedef basic_string, _Byte_alloc> byte_string; + typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string; + typedef typename _Codecvt::state_type state_type; + typedef typename wide_string::traits_type::int_type int_type; + + /// Default constructor. + wstring_convert() : _M_cvt(new _Codecvt()) { } + + /** Constructor. + * + * @param __pcvt The facet to use for conversions. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + */ + explicit + wstring_convert(_Codecvt* __pcvt) : _M_cvt(__pcvt, "wstring_convert") + { } + + /** Construct with an initial converstion state. + * + * @param __pcvt The facet to use for conversions. + * @param __state Initial conversion state. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + * The object's conversion state will persist between conversions. + */ + wstring_convert(_Codecvt* __pcvt, state_type __state) + : _M_cvt(__pcvt, "wstring_convert"), + _M_state(__state), _M_with_cvtstate(true) + { } + + /** Construct with error strings. + * + * @param __byte_err A string to return on failed conversions. + * @param __wide_err A wide string to return on failed conversions. + */ + explicit + wstring_convert(const byte_string& __byte_err, + const wide_string& __wide_err = wide_string()) + : _M_cvt(new _Codecvt), + _M_byte_err_string(__byte_err), _M_wide_err_string(__wide_err), + _M_with_strings(true) + { } + + ~wstring_convert() = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2176. Special members for wstring_convert and wbuffer_convert + wstring_convert(const wstring_convert&) = delete; + wstring_convert& operator=(const wstring_convert&) = delete; + + /// @{ Convert from bytes. + wide_string + from_bytes(char __byte) + { + char __bytes[2] = { __byte }; + return from_bytes(__bytes, __bytes+1); + } + + wide_string + from_bytes(const char* __ptr) + { return from_bytes(__ptr, __ptr+char_traits::length(__ptr)); } + + wide_string + from_bytes(const byte_string& __str) + { + auto __ptr = __str.data(); + return from_bytes(__ptr, __ptr + __str.size()); + } + + wide_string + from_bytes(const char* __first, const char* __last) + { + if (!_M_with_cvtstate) + _M_state = state_type(); + wide_string __out{ _M_wide_err_string.get_allocator() }; + if (__str_codecvt_in(__first, __last, __out, *_M_cvt, _M_state, + _M_count)) + return __out; + if (_M_with_strings) + return _M_wide_err_string; + __throw_range_error("wstring_convert::from_bytes"); + } + /// @} + + /// @{ Convert to bytes. + byte_string + to_bytes(_Elem __wchar) + { + _Elem __wchars[2] = { __wchar }; + return to_bytes(__wchars, __wchars+1); + } + + byte_string + to_bytes(const _Elem* __ptr) + { + return to_bytes(__ptr, __ptr+wide_string::traits_type::length(__ptr)); + } + + byte_string + to_bytes(const wide_string& __wstr) + { + auto __ptr = __wstr.data(); + return to_bytes(__ptr, __ptr + __wstr.size()); + } + + byte_string + to_bytes(const _Elem* __first, const _Elem* __last) + { + if (!_M_with_cvtstate) + _M_state = state_type(); + byte_string __out{ _M_byte_err_string.get_allocator() }; + if (__str_codecvt_out(__first, __last, __out, *_M_cvt, _M_state, + _M_count)) + return __out; + if (_M_with_strings) + return _M_byte_err_string; + __throw_range_error("wstring_convert::to_bytes"); + } + /// @} + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2174. wstring_convert::converted() should be noexcept + /// The number of elements successfully converted in the last conversion. + size_t converted() const noexcept { return _M_count; } + + /// The final conversion state of the last conversion. + state_type state() const { return _M_state; } + + private: + __detail::_Scoped_ptr<_Codecvt> _M_cvt; + byte_string _M_byte_err_string; + wide_string _M_wide_err_string; + state_type _M_state = state_type(); + size_t _M_count = 0; + bool _M_with_cvtstate = false; + bool _M_with_strings = false; + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// Buffer conversions + template> + class wbuffer_convert : public basic_streambuf<_Elem, _Tr> + { + typedef basic_streambuf<_Elem, _Tr> _Wide_streambuf; + + public: + typedef typename _Codecvt::state_type state_type; + + /// Default constructor. + wbuffer_convert() : wbuffer_convert(nullptr) { } + + /** Constructor. + * + * @param __bytebuf The underlying byte stream buffer. + * @param __pcvt The facet to use for conversions. + * @param __state Initial conversion state. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + */ + explicit + wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, + state_type __state = state_type()) + : _M_buf(__bytebuf), _M_cvt(__pcvt, "wbuffer_convert"), + _M_state(__state), _M_always_noconv(_M_cvt->always_noconv()) + { + if (_M_buf) + { + this->setp(_M_put_area, _M_put_area + _S_buffer_length); + this->setg(_M_get_area + _S_putback_length, + _M_get_area + _S_putback_length, + _M_get_area + _S_putback_length); + } + } + + ~wbuffer_convert() = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2176. Special members for wstring_convert and wbuffer_convert + wbuffer_convert(const wbuffer_convert&) = delete; + wbuffer_convert& operator=(const wbuffer_convert&) = delete; + + streambuf* rdbuf() const noexcept { return _M_buf; } + + streambuf* + rdbuf(streambuf *__bytebuf) noexcept + { + auto __prev = _M_buf; + _M_buf = __bytebuf; + return __prev; + } + + /// The conversion state following the last conversion. + state_type state() const noexcept { return _M_state; } + + protected: + int + sync() + { return _M_buf && _M_conv_put() && !_M_buf->pubsync() ? 0 : -1; } + + typename _Wide_streambuf::int_type + overflow(typename _Wide_streambuf::int_type __out) + { + if (!_M_buf || !_M_conv_put()) + return _Tr::eof(); + else if (!_Tr::eq_int_type(__out, _Tr::eof())) + return this->sputc(__out); + return _Tr::not_eof(__out); + } + + typename _Wide_streambuf::int_type + underflow() + { + if (!_M_buf) + return _Tr::eof(); + + if (this->gptr() < this->egptr() || (_M_buf && _M_conv_get())) + return _Tr::to_int_type(*this->gptr()); + else + return _Tr::eof(); + } + + streamsize + xsputn(const typename _Wide_streambuf::char_type* __s, streamsize __n) + { + if (!_M_buf || __n == 0) + return 0; + streamsize __done = 0; + do + { + auto __nn = std::min(this->epptr() - this->pptr(), + __n - __done); + _Tr::copy(this->pptr(), __s + __done, __nn); + this->pbump(__nn); + __done += __nn; + } while (__done < __n && _M_conv_put()); + return __done; + } + + private: + // fill the get area from converted contents of the byte stream buffer + bool + _M_conv_get() + { + const streamsize __pb1 = this->gptr() - this->eback(); + const streamsize __pb2 = _S_putback_length; + const streamsize __npb = std::min(__pb1, __pb2); + + _Tr::move(_M_get_area + _S_putback_length - __npb, + this->gptr() - __npb, __npb); + + streamsize __nbytes = sizeof(_M_get_buf) - _M_unconv; + __nbytes = std::min(__nbytes, _M_buf->in_avail()); + if (__nbytes < 1) + __nbytes = 1; + __nbytes = _M_buf->sgetn(_M_get_buf + _M_unconv, __nbytes); + if (__nbytes < 1) + return false; + __nbytes += _M_unconv; + + // convert _M_get_buf into _M_get_area + + _Elem* __outbuf = _M_get_area + _S_putback_length; + _Elem* __outnext = __outbuf; + const char* __bnext = _M_get_buf; + + codecvt_base::result __result; + if (_M_always_noconv) + __result = codecvt_base::noconv; + else + { + _Elem* __outend = _M_get_area + _S_buffer_length; + + __result = _M_cvt->in(_M_state, + __bnext, __bnext + __nbytes, __bnext, + __outbuf, __outend, __outnext); + } + + if (__result == codecvt_base::noconv) + { + // cast is safe because noconv means _Elem is same type as char + auto __get_buf = reinterpret_cast(_M_get_buf); + _Tr::copy(__outbuf, __get_buf, __nbytes); + _M_unconv = 0; + return true; + } + + if ((_M_unconv = _M_get_buf + __nbytes - __bnext)) + char_traits::move(_M_get_buf, __bnext, _M_unconv); + + this->setg(__outbuf, __outbuf, __outnext); + + return __result != codecvt_base::error; + } + + // unused + bool + _M_put(...) + { return false; } + + bool + _M_put(const char* __p, streamsize __n) + { + if (_M_buf->sputn(__p, __n) < __n) + return false; + return true; + } + + // convert the put area and write to the byte stream buffer + bool + _M_conv_put() + { + _Elem* const __first = this->pbase(); + const _Elem* const __last = this->pptr(); + const streamsize __pending = __last - __first; + + if (_M_always_noconv) + return _M_put(__first, __pending); + + char __outbuf[2 * _S_buffer_length]; + + const _Elem* __next = __first; + const _Elem* __start; + do + { + __start = __next; + char* __outnext = __outbuf; + char* const __outlast = __outbuf + sizeof(__outbuf); + auto __result = _M_cvt->out(_M_state, __next, __last, __next, + __outnext, __outlast, __outnext); + if (__result == codecvt_base::error) + return false; + else if (__result == codecvt_base::noconv) + return _M_put(__next, __pending); + + if (!_M_put(__outbuf, __outnext - __outbuf)) + return false; + } + while (__next != __last && __next != __start); + + if (__next != __last) + _Tr::move(__first, __next, __last - __next); + + this->pbump(__first - __next); + return __next != __first; + } + + streambuf* _M_buf; + __detail::_Scoped_ptr<_Codecvt> _M_cvt; + state_type _M_state; + + static const streamsize _S_buffer_length = 32; + static const streamsize _S_putback_length = 3; + _Elem _M_put_area[_S_buffer_length]; + _Elem _M_get_area[_S_buffer_length]; + streamsize _M_unconv = 0; + char _M_get_buf[_S_buffer_length-_S_putback_length]; + bool _M_always_noconv; + }; + + /// @} group locales + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __cplusplus + +#endif /* _LOCALE_CONV_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9a6306715a479c7c17729b1bc88d089c11ab0cc1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_conv.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h new file mode 100644 index 0000000000000000000000000000000000000000..24374d7a8c413e263b237169ea9a83d90de0ed7d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h @@ -0,0 +1,2689 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FACETS_H +#define _LOCALE_FACETS_H 1 + +#pragma GCC system_header + +#include // For wctype_t +#include +#include +#include +#include // For ios_base, ios_base::iostate +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +// Number of standard facets (for narrow characters only) +#define _GLIBCXX_NUM_FACETS 14 + +// Number of duplicated facets for cxx11 ABI +#define _GLIBCXX_NUM_CXX11_FACETS (_GLIBCXX_USE_DUAL_ABI ? 8 : 0) + +// codecvt and codecvt +#ifdef _GLIBCXX_USE_CHAR8_T +# define _GLIBCXX_NUM_UNICODE_FACETS 4 +#else +# define _GLIBCXX_NUM_UNICODE_FACETS 2 +#endif + +// Facets duplicated for alt128 long double format +// num_get, num_put, money_get, money_put (+ cxx11 money_get, money_put) +#define _GLIBCXX_NUM_LBDL_ALT128_FACETS (4 + (_GLIBCXX_USE_DUAL_ABI ? 2 : 0)) + + // Convert string to numeric value of type _Tp and store results. + // NB: This is specialized for all required types, there is no + // generic definition. + template + void + __convert_to_v(const char*, _Tp&, ios_base::iostate&, + const __c_locale&) throw(); + + // Explicit specializations for required types. + template<> + void + __convert_to_v(const char*, float&, ios_base::iostate&, + const __c_locale&) throw(); + + template<> + void + __convert_to_v(const char*, double&, ios_base::iostate&, + const __c_locale&) throw(); + + template<> + void + __convert_to_v(const char*, long double&, ios_base::iostate&, + const __c_locale&) throw(); + + // NB: __pad is a struct, rather than a function, so it can be + // partially-specialized. + template + struct __pad + { + static void + _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, + const _CharT* __olds, streamsize __newlen, streamsize __oldlen); + }; + + // Used by both numeric and monetary facets. + // Inserts "group separator" characters into an array of characters. + // It's recursive, one iteration per group. It moves the characters + // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this + // only with __gsize != 0. + template + _CharT* + __add_grouping(_CharT* __s, _CharT __sep, + const char* __gbeg, size_t __gsize, + const _CharT* __first, const _CharT* __last); + + // This template permits specializing facet output code for + // ostreambuf_iterator. For ostreambuf_iterator, sputn is + // significantly more efficient than incrementing iterators. + template + inline + ostreambuf_iterator<_CharT> + __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len) + { + __s._M_put(__ws, __len); + return __s; + } + + // This is the unspecialized form of the template. + template + inline + _OutIter + __write(_OutIter __s, const _CharT* __ws, int __len) + { + for (int __j = 0; __j < __len; __j++, ++__s) + *__s = __ws[__j]; + return __s; + } + + + // 22.2.1.1 Template class ctype + // Include host and configuration specific ctype enums for ctype_base. + + /** + * @brief Common base for ctype facet + * + * This template class provides implementations of the public functions + * that forward to the protected virtual functions. + * + * This template also provides abstract stubs for the protected virtual + * functions. + */ + template + class __ctype_abstract_base : public locale::facet, public ctype_base + { + public: + // Types: + /// Typedef for the template parameter + typedef _CharT char_type; + + /** + * @brief Test char_type classification. + * + * This function finds a mask M for @a __c and compares it to + * mask @a __m. It does so by returning the value of + * ctype::do_is(). + * + * @param __c The char_type to compare the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + bool + is(mask __m, char_type __c) const + { return this->do_is(__m, __c); } + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char_type in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the char array. It does so by returning the value of + * ctype::do_is(). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + const char_type* + is(const char_type *__lo, const char_type *__hi, mask *__vec) const + { return this->do_is(__lo, __hi, __vec); } + + /** + * @brief Find char_type matching a mask + * + * This function searches for and returns the first char_type c in + * [lo,hi) for which is(m,c) is true. It does so by returning + * ctype::do_scan_is(). + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to matching char_type if found, else @a __hi. + */ + const char_type* + scan_is(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_is(__m, __lo, __hi); } + + /** + * @brief Find char_type not matching a mask + * + * This function searches for and returns the first char_type c in + * [lo,hi) for which is(m,c) is false. It does so by returning + * ctype::do_scan_not(). + * + * @param __m The mask to compare against. + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return Pointer to non-matching char if found, else @a __hi. + */ + const char_type* + scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_not(__m, __lo, __hi); } + + /** + * @brief Convert to uppercase. + * + * This function converts the argument to uppercase if possible. + * If not possible (for example, '2'), returns the argument. It does + * so by returning ctype::do_toupper(). + * + * @param __c The char_type to convert. + * @return The uppercase char_type if convertible, else @a __c. + */ + char_type + toupper(char_type __c) const + { return this->do_toupper(__c); } + + /** + * @brief Convert array to uppercase. + * + * This function converts each char_type in the range [lo,hi) to + * uppercase if possible. Other elements remain untouched. It does so + * by returning ctype:: do_toupper(lo, hi). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + toupper(char_type *__lo, const char_type* __hi) const + { return this->do_toupper(__lo, __hi); } + + /** + * @brief Convert to lowercase. + * + * This function converts the argument to lowercase if possible. If + * not possible (for example, '2'), returns the argument. It does so + * by returning ctype::do_tolower(c). + * + * @param __c The char_type to convert. + * @return The lowercase char_type if convertible, else @a __c. + */ + char_type + tolower(char_type __c) const + { return this->do_tolower(__c); } + + /** + * @brief Convert array to lowercase. + * + * This function converts each char_type in the range [__lo,__hi) to + * lowercase if possible. Other elements remain untouched. It does so + * by returning ctype:: do_tolower(__lo, __hi). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + tolower(char_type* __lo, const char_type* __hi) const + { return this->do_tolower(__lo, __hi); } + + /** + * @brief Widen char to char_type + * + * This function converts the char argument to char_type using the + * simplest reasonable transformation. It does so by returning + * ctype::do_widen(c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted char_type. + */ + char_type + widen(char __c) const + { return this->do_widen(__c); } + + /** + * @brief Widen array to char_type + * + * This function converts each char in the input to char_type using the + * simplest reasonable transformation. It does so by returning + * ctype::do_widen(c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char* + widen(const char* __lo, const char* __hi, char_type* __to) const + { return this->do_widen(__lo, __hi, __to); } + + /** + * @brief Narrow char_type to char + * + * This function converts the char_type to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. It does so by returning + * ctype::do_narrow(__c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char_type to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + char + narrow(char_type __c, char __dfault) const + { return this->do_narrow(__c, __dfault); } + + /** + * @brief Narrow array to char array + * + * This function converts each char_type in the input to char using the + * simplest reasonable transformation and writes the results to the + * destination array. For any char_type in the input that cannot be + * converted, @a dfault is used instead. It does so by returning + * ctype::do_narrow(__lo, __hi, __dfault, __to). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char_type* + narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const + { return this->do_narrow(__lo, __hi, __dfault, __to); } + + protected: + explicit + __ctype_abstract_base(size_t __refs = 0): facet(__refs) { } + + virtual + ~__ctype_abstract_base() { } + + /** + * @brief Test char_type classification. + * + * This function finds a mask M for @a c and compares it to mask @a m. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __c The char_type to find the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + virtual bool + do_is(mask __m, char_type __c) const = 0; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char_type in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the input. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, + mask* __vec) const = 0; + + /** + * @brief Find char_type matching mask + * + * This function searches for and returns the first char_type c in + * [__lo,__hi) for which is(__m,c) is true. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching char_type if found, else @a __hi. + */ + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + + /** + * @brief Find char_type not matching mask + * + * This function searches for and returns a pointer to the first + * char_type c of [lo,hi) for which is(m,c) is false. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching char_type if found, else @a __hi. + */ + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the char_type argument to uppercase + * if possible. If not possible (for example, '2'), returns the + * argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The char_type to convert. + * @return The uppercase char_type if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const = 0; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each char_type in the range [__lo,__hi) + * to uppercase if possible. Other elements remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const = 0; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The char_type to convert. + * @return The lowercase char_type if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const = 0; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each char_type in the range [__lo,__hi) + * to lowercase if possible. Other elements remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const = 0; + + /** + * @brief Widen char + * + * This virtual function converts the char to char_type using the + * simplest reasonable transformation. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted char_type + */ + virtual char_type + do_widen(char __c) const = 0; + + /** + * @brief Widen char array + * + * This function converts each char in the input to char_type using the + * simplest reasonable transformation. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const = 0; + + /** + * @brief Narrow char_type to char + * + * This virtual function converts the argument to char using the + * simplest reasonable transformation. If the conversion fails, dfault + * is returned instead. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char_type to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault) const = 0; + + /** + * @brief Narrow char_type array to char + * + * This virtual function converts each char_type in the range + * [__lo,__hi) to char using the simplest reasonable + * transformation and writes the results to the destination + * array. For any element in the input that cannot be + * converted, @a __dfault is used instead. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const = 0; + }; + + /** + * @brief Primary class template ctype facet. + * @ingroup locales + * + * This template class defines classification and conversion functions for + * character sets. It wraps cctype functionality. Ctype gets used by + * streams for many I/O operations. + * + * This template provides the protected virtual functions the developer + * will have to replace in a derived class or specialization to make a + * working facet. The public functions that access them are defined in + * __ctype_abstract_base, to allow for implementation flexibility. See + * ctype for an example. The functions are documented in + * __ctype_abstract_base. + * + * Note: implementations are provided for all the protected virtual + * functions, but will likely not be useful. + */ + template + class ctype : public __ctype_abstract_base<_CharT> + { + public: + // Types: + typedef _CharT char_type; + typedef typename __ctype_abstract_base<_CharT>::mask mask; + + /// The facet id for ctype + static locale::id id; + + explicit + ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { } + + protected: + virtual + ~ctype(); + + virtual bool + do_is(mask __m, char_type __c) const; + + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const; + + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const; + + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const; + + virtual char_type + do_toupper(char_type __c) const; + + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + virtual char_type + do_tolower(char_type __c) const; + + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + virtual char_type + do_widen(char __c) const; + + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __dest) const; + + virtual char + do_narrow(char_type, char __dfault) const; + + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const; + }; + + template + locale::id ctype<_CharT>::id; + + // Incomplete to provide a compile time diagnostics for common misuse + // of [locale.convenience] functions with basic_string as a character type. + template + class ctype >; + + /** + * @brief The ctype specialization. + * @ingroup locales + * + * This class defines classification and conversion functions for + * the char type. It gets used by char streams for many I/O + * operations. The char specialization provides a number of + * optimizations as well. + */ + template<> + class ctype : public locale::facet, public ctype_base + { + public: + // Types: + /// Typedef for the template parameter char. + typedef char char_type; + + protected: + // Data Members: + __c_locale _M_c_locale_ctype; + bool _M_del; + __to_type _M_toupper; + __to_type _M_tolower; + const mask* _M_table; + mutable char _M_widen_ok; + mutable char _M_widen[1 + static_cast(-1)]; + mutable char _M_narrow[1 + static_cast(-1)]; + mutable char _M_narrow_ok; // 0 uninitialized, 1 init, + // 2 memcpy can't be used + + public: + /// The facet id for ctype + static locale::id id; + /// The size of the mask table. It is SCHAR_MAX + 1. + static const size_t table_size = 1 + static_cast(-1); + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __table If non-zero, table is used as the per-char mask. + * Else classic_table() is used. + * @param __del If true, passes ownership of table to this facet. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0); + + /** + * @brief Constructor performs static initialization. + * + * This constructor is used to construct the initial C locale facet. + * + * @param __cloc Handle to C locale data. + * @param __table If non-zero, table is used as the per-char mask. + * @param __del If true, passes ownership of table to this facet. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false, + size_t __refs = 0); + + /** + * @brief Test char classification. + * + * This function compares the mask table[c] to @a __m. + * + * @param __c The char to compare the mask of. + * @param __m The mask to compare against. + * @return True if __m & table[__c] is true, false otherwise. + */ + inline bool + is(mask __m, char __c) const; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char in the range [lo, hi) and + * successively writes it to vec. vec must have as many elements as + * the char array. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + inline const char* + is(const char* __lo, const char* __hi, mask* __vec) const; + + /** + * @brief Find char matching a mask + * + * This function searches for and returns the first char in [lo,hi) for + * which is(m,char) is true. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching char if found, else @a __hi. + */ + inline const char* + scan_is(mask __m, const char* __lo, const char* __hi) const; + + /** + * @brief Find char not matching a mask + * + * This function searches for and returns a pointer to the first char + * in [__lo,__hi) for which is(m,char) is false. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching char if found, else @a __hi. + */ + inline const char* + scan_not(mask __m, const char* __lo, const char* __hi) const; + + /** + * @brief Convert to uppercase. + * + * This function converts the char argument to uppercase if possible. + * If not possible (for example, '2'), returns the argument. + * + * toupper() acts as if it returns ctype::do_toupper(c). + * do_toupper() must always return the same result for the same input. + * + * @param __c The char to convert. + * @return The uppercase char if convertible, else @a __c. + */ + char_type + toupper(char_type __c) const + { return this->do_toupper(__c); } + + /** + * @brief Convert array to uppercase. + * + * This function converts each char in the range [__lo,__hi) to uppercase + * if possible. Other chars remain untouched. + * + * toupper() acts as if it returns ctype:: do_toupper(__lo, __hi). + * do_toupper() must always return the same result for the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + toupper(char_type *__lo, const char_type* __hi) const + { return this->do_toupper(__lo, __hi); } + + /** + * @brief Convert to lowercase. + * + * This function converts the char argument to lowercase if possible. + * If not possible (for example, '2'), returns the argument. + * + * tolower() acts as if it returns ctype::do_tolower(__c). + * do_tolower() must always return the same result for the same input. + * + * @param __c The char to convert. + * @return The lowercase char if convertible, else @a __c. + */ + char_type + tolower(char_type __c) const + { return this->do_tolower(__c); } + + /** + * @brief Convert array to lowercase. + * + * This function converts each char in the range [lo,hi) to lowercase + * if possible. Other chars remain untouched. + * + * tolower() acts as if it returns ctype:: do_tolower(__lo, __hi). + * do_tolower() must always return the same result for the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + tolower(char_type* __lo, const char_type* __hi) const + { return this->do_tolower(__lo, __hi); } + + /** + * @brief Widen char + * + * This function converts the char to char_type using the simplest + * reasonable transformation. For an underived ctype facet, the + * argument will be returned unchanged. + * + * This function works as if it returns ctype::do_widen(c). + * do_widen() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted character. + */ + char_type + widen(char __c) const + { + if (_M_widen_ok) + return _M_widen[static_cast(__c)]; + this->_M_widen_init(); + return this->do_widen(__c); + } + + /** + * @brief Widen char array + * + * This function converts each char in the input to char using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be copied unchanged. + * + * This function works as if it returns ctype::do_widen(c). + * do_widen() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char* + widen(const char* __lo, const char* __hi, char_type* __to) const + { + if (_M_widen_ok == 1) + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + if (!_M_widen_ok) + _M_widen_init(); + return this->do_widen(__lo, __hi, __to); + } + + /** + * @brief Narrow char + * + * This function converts the char to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. For an underived ctype facet, @a c + * will be returned unchanged. + * + * This function works as if it returns ctype::do_narrow(c). + * do_narrow() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted character. + */ + char + narrow(char_type __c, char __dfault) const + { + if (_M_narrow[static_cast(__c)]) + return _M_narrow[static_cast(__c)]; + const char __t = do_narrow(__c, __dfault); + if (__t != __dfault) + _M_narrow[static_cast(__c)] = __t; + return __t; + } + + /** + * @brief Narrow char array + * + * This function converts each char in the input to char using the + * simplest reasonable transformation and writes the results to the + * destination array. For any char in the input that cannot be + * converted, @a dfault is used instead. For an underived ctype + * facet, the argument will be copied unchanged. + * + * This function works as if it returns ctype::do_narrow(lo, hi, + * dfault, to). do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char_type* + narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const + { + if (__builtin_expect(_M_narrow_ok == 1, true)) + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + if (!_M_narrow_ok) + _M_narrow_init(); + return this->do_narrow(__lo, __hi, __dfault, __to); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 695. ctype::classic_table() not accessible. + /// Returns a pointer to the mask table provided to the constructor, or + /// the default from classic_table() if none was provided. + const mask* + table() const throw() + { return _M_table; } + + /// Returns a pointer to the C locale mask table. + static const mask* + classic_table() throw(); + protected: + + /** + * @brief Destructor. + * + * This function deletes table() if @a del was true in the + * constructor. + */ + virtual + ~ctype(); + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the char argument to uppercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The char to convert. + * @return The uppercase char if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each char in the range [lo,hi) to + * uppercase if possible. Other chars remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the char argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The char to convert. + * @return The lowercase char if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each char in the range [lo,hi) to + * lowercase if possible. Other chars remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Widen char + * + * This virtual function converts the char to char using the simplest + * reasonable transformation. For an underived ctype facet, the + * argument will be returned unchanged. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted character. + */ + virtual char_type + do_widen(char __c) const + { return __c; } + + /** + * @brief Widen char array + * + * This function converts each char in the range [lo,hi) to char using + * the simplest reasonable transformation. For an underived + * ctype facet, the argument will be copied unchanged. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + + /** + * @brief Narrow char + * + * This virtual function converts the char to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. For an underived ctype facet, @a c will be + * returned unchanged. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault __attribute__((__unused__))) const + { return __c; } + + /** + * @brief Narrow char array to char array + * + * This virtual function converts each char in the range [lo,hi) to + * char using the simplest reasonable transformation and writes the + * results to the destination array. For any char in the input that + * cannot be converted, @a dfault is used instead. For an underived + * ctype facet, the argument will be copied unchanged. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault __attribute__((__unused__)), char* __to) const + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + + private: + void _M_narrow_init() const; + void _M_widen_init() const; + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** + * @brief The ctype specialization. + * @ingroup locales + * + * This class defines classification and conversion functions for the + * wchar_t type. It gets used by wchar_t streams for many I/O operations. + * The wchar_t specialization provides a number of optimizations as well. + * + * ctype inherits its public methods from + * __ctype_abstract_base. + */ + template<> + class ctype : public __ctype_abstract_base + { + public: + // Types: + /// Typedef for the template parameter wchar_t. + typedef wchar_t char_type; + typedef wctype_t __wmask_type; + + protected: + __c_locale _M_c_locale_ctype; + + // Pre-computed narrowed and widened chars. + bool _M_narrow_ok; + char _M_narrow[128]; + wint_t _M_widen[1 + static_cast(-1)]; + + // Pre-computed elements for do_is. + mask _M_bit[16]; + __wmask_type _M_wmask[16]; + + public: + // Data Members: + /// The facet id for ctype + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + ctype(size_t __refs = 0); + + /** + * @brief Constructor performs static initialization. + * + * This constructor is used to construct the initial C locale facet. + * + * @param __cloc Handle to C locale data. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(__c_locale __cloc, size_t __refs = 0); + + protected: + __wmask_type + _M_convert_to_wmask(const mask __m) const throw(); + + /// Destructor + virtual + ~ctype(); + + /** + * @brief Test wchar_t classification. + * + * This function finds a mask M for @a c and compares it to mask @a m. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __c The wchar_t to find the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + virtual bool + do_is(mask __m, char_type __c) const; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each wchar_t in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the input. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const; + + /** + * @brief Find wchar_t matching mask + * + * This function searches for and returns the first wchar_t c in + * [__lo,__hi) for which is(__m,c) is true. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching wchar_t if found, else @a __hi. + */ + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const; + + /** + * @brief Find wchar_t not matching mask + * + * This function searches for and returns a pointer to the first + * wchar_t c of [__lo,__hi) for which is(__m,c) is false. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching wchar_t if found, else @a __hi. + */ + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const; + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the wchar_t argument to uppercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The wchar_t to convert. + * @return The uppercase wchar_t if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * uppercase if possible. Other elements remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The wchar_t to convert. + * @return The lowercase wchar_t if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * lowercase if possible. Other elements remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Widen char to wchar_t + * + * This virtual function converts the char to wchar_t using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be cast to wchar_t. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted wchar_t. + */ + virtual char_type + do_widen(char __c) const; + + /** + * @brief Widen char array to wchar_t array + * + * This function converts each char in the input to wchar_t using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be copied, casting each element to wchar_t. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const; + + /** + * @brief Narrow wchar_t to char + * + * This virtual function converts the argument to char using + * the simplest reasonable transformation. If the conversion + * fails, dfault is returned instead. For an underived + * ctype facet, @a c will be cast to char and + * returned. + * + * do_narrow() is a hook for a derived facet to change the + * behavior of narrowing. do_narrow() must always return the + * same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The wchar_t to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault) const; + + /** + * @brief Narrow wchar_t array to char array + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * char using the simplest reasonable transformation and writes the + * results to the destination array. For any wchar_t in the input that + * cannot be converted, @a dfault is used instead. For an underived + * ctype facet, the argument will be copied, casting each + * element to char. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const; + + // For use at construction time only. + void + _M_initialize_ctype() throw(); + }; +#endif //_GLIBCXX_USE_WCHAR_T + + /// class ctype_byname [22.2.1.2]. + template + class ctype_byname : public ctype<_CharT> + { + public: + typedef typename ctype<_CharT>::mask mask; + + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0) + : ctype_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~ctype_byname() { } + }; + + /// 22.2.1.4 Class ctype_byname specializations. + template<> + class ctype_byname : public ctype + { + public: + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + + protected: + virtual + ~ctype_byname(); + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + class ctype_byname : public ctype + { + public: + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + + protected: + virtual + ~ctype_byname(); + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// Include host and configuration specific ctype inlines. +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 22.2.2 The numeric category. + class __num_base + { + public: + // NB: Code depends on the order of _S_atoms_out elements. + // Below are the indices into _S_atoms_out. + enum + { + _S_ominus, + _S_oplus, + _S_ox, + _S_oX, + _S_odigits, + _S_odigits_end = _S_odigits + 16, + _S_oudigits = _S_odigits_end, + _S_oudigits_end = _S_oudigits + 16, + _S_oe = _S_odigits + 14, // For scientific notation, 'e' + _S_oE = _S_oudigits + 14, // For scientific notation, 'E' + _S_oend = _S_oudigits_end + }; + + // A list of valid numeric literals for output. This array + // contains chars that will be passed through the current locale's + // ctype<_CharT>.widen() and then used to render numbers. + // For the standard "C" locale, this is + // "-+xX0123456789abcdef0123456789ABCDEF". + static const char* _S_atoms_out; + + // String literal of acceptable (narrow) input, for num_get. + // "-+xX0123456789abcdefABCDEF" + static const char* _S_atoms_in; + + enum + { + _S_iminus, + _S_iplus, + _S_ix, + _S_iX, + _S_izero, + _S_ie = _S_izero + 14, + _S_iE = _S_izero + 20, + _S_iend = 26 + }; + + // num_put + // Construct and return valid scanf format for floating point types. + static void + _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw(); + }; + + template + struct __numpunct_cache : public locale::facet + { + const char* _M_grouping; + size_t _M_grouping_size; + bool _M_use_grouping; + const _CharT* _M_truename; + size_t _M_truename_size; + const _CharT* _M_falsename; + size_t _M_falsename_size; + _CharT _M_decimal_point; + _CharT _M_thousands_sep; + + // A list of valid numeric literals for output: in the standard + // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF". + // This array contains the chars after having been passed + // through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms_out[__num_base::_S_oend]; + + // A list of valid numeric literals for input: in the standard + // "C" locale, this is "-+xX0123456789abcdefABCDEF" + // This array contains the chars after having been passed + // through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms_in[__num_base::_S_iend]; + + bool _M_allocated; + + __numpunct_cache(size_t __refs = 0) + : facet(__refs), _M_grouping(0), _M_grouping_size(0), + _M_use_grouping(false), + _M_truename(0), _M_truename_size(0), _M_falsename(0), + _M_falsename_size(0), _M_decimal_point(_CharT()), + _M_thousands_sep(_CharT()), _M_allocated(false) + { } + + ~__numpunct_cache(); + + void + _M_cache(const locale& __loc); + + private: + __numpunct_cache& + operator=(const __numpunct_cache&); + + explicit + __numpunct_cache(const __numpunct_cache&); + }; + + template + __numpunct_cache<_CharT>::~__numpunct_cache() + { + if (_M_allocated) + { + delete [] _M_grouping; + delete [] _M_truename; + delete [] _M_falsename; + } + } + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template numpunct. + * @ingroup locales + * + * This facet stores several pieces of information related to printing and + * scanning numbers, such as the decimal point character. It takes a + * template parameter specifying the char type. The numpunct facet is + * used by streams for many I/O operations involving numbers. + * + * The numpunct template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from a numpunct facet. + */ + template + class numpunct : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + typedef __numpunct_cache<_CharT> __cache_type; + + protected: + __cache_type* _M_data; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Numpunct constructor. + * + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_numpunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up the + * predefined locale facets. + * + * @param __cache __numpunct_cache object. + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(__cache_type* __cache, size_t __refs = 0) + : facet(__refs), _M_data(__cache) + { _M_initialize_numpunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(__c_locale __cloc, size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_numpunct(__cloc); } + + /** + * @brief Return decimal point character. + * + * This function returns a char_type to use as a decimal point. It + * does so by returning returning + * numpunct::do_decimal_point(). + * + * @return @a char_type representing a decimal point. + */ + char_type + decimal_point() const + { return this->do_decimal_point(); } + + /** + * @brief Return thousands separator character. + * + * This function returns a char_type to use as a thousands + * separator. It does so by returning returning + * numpunct::do_thousands_sep(). + * + * @return char_type representing a thousands separator. + */ + char_type + thousands_sep() const + { return this->do_thousands_sep(); } + + /** + * @brief Return grouping specification. + * + * This function returns a string representing groupings for the + * integer part of a number. Groupings indicate where thousands + * separators should be inserted in the integer part of a number. + * + * Each char in the return string is interpret as an integer + * rather than a character. These numbers represent the number + * of digits in a group. The first char in the string + * represents the number of digits in the least significant + * group. If a char is negative, it indicates an unlimited + * number of digits for the group. If more chars from the + * string are required to group a number, the last char is used + * repeatedly. + * + * For example, if the grouping() returns "\003\002" and is + * applied to the number 123456789, this corresponds to + * 12,34,56,789. Note that if the string was "32", this would + * put more than 50 digits into the least significant group if + * the character set is ASCII. + * + * The string is returned by calling + * numpunct::do_grouping(). + * + * @return string representing grouping specification. + */ + string + grouping() const + { return this->do_grouping(); } + + /** + * @brief Return string representation of bool true. + * + * This function returns a string_type containing the text + * representation for true bool variables. It does so by calling + * numpunct::do_truename(). + * + * @return string_type representing printed form of true. + */ + string_type + truename() const + { return this->do_truename(); } + + /** + * @brief Return string representation of bool false. + * + * This function returns a string_type containing the text + * representation for false bool variables. It does so by calling + * numpunct::do_falsename(). + * + * @return string_type representing printed form of false. + */ + string_type + falsename() const + { return this->do_falsename(); } + + protected: + /// Destructor. + virtual + ~numpunct(); + + /** + * @brief Return decimal point character. + * + * Returns a char_type to use as a decimal point. This function is a + * hook for derived classes to change the value returned. + * + * @return @a char_type representing a decimal point. + */ + virtual char_type + do_decimal_point() const + { return _M_data->_M_decimal_point; } + + /** + * @brief Return thousands separator character. + * + * Returns a char_type to use as a thousands separator. This function + * is a hook for derived classes to change the value returned. + * + * @return @a char_type representing a thousands separator. + */ + virtual char_type + do_thousands_sep() const + { return _M_data->_M_thousands_sep; } + + /** + * @brief Return grouping specification. + * + * Returns a string representing groupings for the integer part of a + * number. This function is a hook for derived classes to change the + * value returned. @see grouping() for details. + * + * @return String representing grouping specification. + */ + virtual string + do_grouping() const + { return _M_data->_M_grouping; } + + /** + * @brief Return string representation of bool true. + * + * Returns a string_type containing the text representation for true + * bool variables. This function is a hook for derived classes to + * change the value returned. + * + * @return string_type representing printed form of true. + */ + virtual string_type + do_truename() const + { return _M_data->_M_truename; } + + /** + * @brief Return string representation of bool false. + * + * Returns a string_type containing the text representation for false + * bool variables. This function is a hook for derived classes to + * change the value returned. + * + * @return string_type representing printed form of false. + */ + virtual string_type + do_falsename() const + { return _M_data->_M_falsename; } + + // For use at construction time only. + void + _M_initialize_numpunct(__c_locale __cloc = 0); + }; + + template + locale::id numpunct<_CharT>::id; + + template<> + numpunct::~numpunct(); + + template<> + void + numpunct::_M_initialize_numpunct(__c_locale __cloc); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + numpunct::~numpunct(); + + template<> + void + numpunct::_M_initialize_numpunct(__c_locale __cloc); +#endif + + /// class numpunct_byname [22.2.3.2]. + template + class numpunct_byname : public numpunct<_CharT> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + explicit + numpunct_byname(const char* __s, size_t __refs = 0) + : numpunct<_CharT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_numpunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } + } + +#if __cplusplus >= 201103L + explicit + numpunct_byname(const string& __s, size_t __refs = 0) + : numpunct_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~numpunct_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + /** + * @brief Primary class template num_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a number + * from a string. It is used by the istream numeric extraction + * operators. + * + * The num_get template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the num_get facet. + */ + template + class num_get : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + num_get(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Numeric parsing. + * + * Parses the input stream into the bool @a v. It does so by calling + * num_get::do_get(). + * + * If ios_base::boolalpha is set, attempts to read + * ctype::truename() or ctype::falsename(). Sets + * @a v to true or false if successful. Sets err to + * ios_base::failbit if reading the string fails. Sets err to + * ios_base::eofbit if the stream is emptied. + * + * If ios_base::boolalpha is not set, proceeds as with reading a long, + * except if the value is 1, sets @a v to true, if the value is 0, sets + * @a v to false, and otherwise set err to ios_base::failbit. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, bool& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the integral variable @a v. It does so + * by calling num_get::do_get(). + * + * Parsing is affected by the flag settings in @a io. + * + * The basic parse is affected by the value of io.flags() & + * ios_base::basefield. If equal to ios_base::oct, parses like the + * scanf %o specifier. Else if equal to ios_base::hex, parses like %X + * specifier. Else if basefield equal to 0, parses like the %i + * specifier. Otherwise, parses like %d for signed and %u for unsigned + * types. The matching type length modifier is also used. + * + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned short& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned int& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } +#endif + ///@} + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the integral variable @a v. It does so + * by calling num_get::do_get(). + * + * The input characters are parsed like the scanf %g specifier. The + * matching type length modifier is also used. + * + * The decimal point character used is numpunct::decimal_point(). + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, float& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long double& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + ///@} + + /** + * @brief Numeric parsing. + * + * Parses the input stream into the pointer variable @a v. It does so + * by calling num_get::do_get(). + * + * The input characters are parsed like the scanf %p specifier. + * + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * Note that the digit grouping effect for pointers is a bit ambiguous + * in the standard and shouldn't be relied on. See DR 344. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, void*& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + protected: + /// Destructor. + virtual ~num_get() { } + + _GLIBCXX_DEFAULT_ABI_TAG + iter_type + _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, + string&) const; + + template + _GLIBCXX_DEFAULT_ABI_TAG + iter_type + _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, + _ValueT&) const; + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type + _M_find(const _CharT2*, size_t __len, _CharT2 __c) const + { + int __ret = -1; + if (__len <= 10) + { + if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len)) + __ret = __c - _CharT2('0'); + } + else + { + if (__c >= _CharT2('0') && __c <= _CharT2('9')) + __ret = __c - _CharT2('0'); + else if (__c >= _CharT2('a') && __c <= _CharT2('f')) + __ret = 10 + (__c - _CharT2('a')); + else if (__c >= _CharT2('A') && __c <= _CharT2('F')) + __ret = 10 + (__c - _CharT2('A')); + } + return __ret; + } + + template + typename __gnu_cxx::__enable_if::__value, + int>::__type + _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const + { + int __ret = -1; + const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c); + if (__q) + { + __ret = __q - __zero; + if (__ret > 15) + __ret -= 6; + } + return __ret; + } + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the variable @a v. This function is a + * hook for derived classes to change the value returned. @see get() + * for more details. + * + * @param __beg Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned short& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned int& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } +#endif + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, float&) const; + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + double&) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get + // this entry in the vtable is for a 64-bit "long double" with the + // same format as double. This keeps the vtable layout consistent + // with std::num_get (visible when -mlong-double-64 is used). + virtual iter_type + __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + double&) const; +#else + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + long double&) const; +#endif + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, void*&) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + // For __gnu_cxx_ieee128::num_get this entry in the vtable is for + // the non-IEEE 128-bit "long double" (aka "double double"). This + // is consistent with __gnu_cxx_ldbl128::num_get (-mabi=ibmlongdouble) + virtual iter_type + __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + __ibm128&) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get + // this entry in the vtable is for the 128-bit "long double" type. + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + long double&) const; +#endif + ///@} + }; + + template + locale::id num_get<_CharT, _InIter>::id; + + + /** + * @brief Primary class template num_put. + * @ingroup locales + * + * This facet encapsulates the code to convert a number to a string. It is + * used by the ostream numeric insertion operators. + * + * The num_put template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the num_put facet. + */ + template + class num_put : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + num_put(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Numeric formatting. + * + * Formats the boolean @a v and inserts it into a stream. It does so + * by calling num_put::do_put(). + * + * If ios_base::boolalpha is set, writes ctype::truename() or + * ctype::falsename(). Otherwise formats @a v as an int. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const + { return this->do_put(__s, __io, __fill, __v); } + + ///@{ + /** + * @brief Numeric formatting. + * + * Formats the integral value @a v and inserts it into a + * stream. It does so by calling num_put::do_put(). + * + * Formatting is affected by the flag settings in @a io. + * + * The basic format is affected by the value of io.flags() & + * ios_base::basefield. If equal to ios_base::oct, formats like the + * printf %o specifier. Else if equal to ios_base::hex, formats like + * %x or %X with ios_base::uppercase unset or set respectively. + * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu + * for unsigned values. Note that if both oct and hex are set, neither + * will take effect. + * + * If ios_base::showpos is set, '+' is output before positive values. + * If ios_base::showbase is set, '0' precedes octal values (except 0) + * and '0[xX]' precedes hex values. + * + * The decimal point character used is numpunct::decimal_point(). + * Thousands separators are inserted according to + * numpunct::grouping() and numpunct::thousands_sep(). + * + * If io.width() is non-zero, enough @a fill characters are inserted to + * make the result at least that wide. If + * (io.flags() & ios_base::adjustfield) == ios_base::left, result is + * padded at the end. If ios_base::internal, then padding occurs + * immediately after either a '+' or '-' or after '0x' or '0X'. + * Otherwise, padding occurs at the beginning. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, long __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long __v) const + { return this->do_put(__s, __io, __fill, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long long __v) const + { return this->do_put(__s, __io, __fill, __v); } +#endif + ///@} + + ///@{ + /** + * @brief Numeric formatting. + * + * Formats the floating point value @a v and inserts it into a stream. + * It does so by calling num_put::do_put(). + * + * Formatting is affected by the flag settings in @a io. + * + * The basic format is affected by the value of io.flags() & + * ios_base::floatfield. If equal to ios_base::fixed, formats like the + * printf %f specifier. Else if equal to ios_base::scientific, formats + * like %e or %E with ios_base::uppercase unset or set respectively. + * Otherwise, formats like %g or %G depending on uppercase. Note that + * if both fixed and scientific are set, the effect will also be like + * %g or %G. + * + * The output precision is given by io.precision(). This precision is + * capped at numeric_limits::digits10 + 2 (different for double and + * long double). The default precision is 6. + * + * If ios_base::showpos is set, '+' is output before positive values. + * If ios_base::showpoint is set, a decimal point will always be + * output. + * + * The decimal point character used is numpunct::decimal_point(). + * Thousands separators are inserted according to + * numpunct::grouping() and numpunct::thousands_sep(). + * + * If io.width() is non-zero, enough @a fill characters are inserted to + * make the result at least that wide. If + * (io.flags() & ios_base::adjustfield) == ios_base::left, result is + * padded at the end. If ios_base::internal, then padding occurs + * immediately after either a '+' or '-' or after '0x' or '0X'. + * Otherwise, padding occurs at the beginning. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + long double __v) const + { return this->do_put(__s, __io, __fill, __v); } + ///@} + + /** + * @brief Numeric formatting. + * + * Formats the pointer value @a v and inserts it into a stream. It + * does so by calling num_put::do_put(). + * + * This function formats @a v as an unsigned long with ios_base::hex + * and ios_base::showbase set. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + const void* __v) const + { return this->do_put(__s, __io, __fill, __v); } + + protected: + template + iter_type + _M_insert_float(iter_type, ios_base& __io, char_type __fill, + char __mod, _ValueT __v) const; + + void + _M_group_float(const char* __grouping, size_t __grouping_size, + char_type __sep, const char_type* __p, char_type* __new, + char_type* __cs, int& __len) const; + + template + iter_type + _M_insert_int(iter_type, ios_base& __io, char_type __fill, + _ValueT __v) const; + + void + _M_group_int(const char* __grouping, size_t __grouping_size, + char_type __sep, ios_base& __io, char_type* __new, + char_type* __cs, int& __len) const; + + void + _M_pad(char_type __fill, streamsize __w, ios_base& __io, + char_type* __new, const char_type* __cs, int& __len) const; + + /// Destructor. + virtual + ~num_put() { } + + ///@{ + /** + * @brief Numeric formatting. + * + * These functions do the work of formatting numeric values and + * inserting them into a stream. This function is a hook for derived + * classes to change the value returned. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const; + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + long long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } +#endif + + virtual iter_type + do_put(iter_type, ios_base&, char_type, double) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_put(iter_type, ios_base&, char_type, double) const; +#else + virtual iter_type + do_put(iter_type, ios_base&, char_type, long double) const; +#endif + + virtual iter_type + do_put(iter_type, ios_base&, char_type, const void*) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_put(iter_type, ios_base&, char_type, __ibm128) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_put(iter_type, ios_base&, char_type, long double) const; +#endif + ///@} + }; + + template + locale::id num_put<_CharT, _OutIter>::id; + +_GLIBCXX_END_NAMESPACE_LDBL + + // Subclause convenience interfaces, inlines. + // NB: These are inline because, when used in a loop, some compilers + // can hoist the body out of the loop; then it's just as fast as the + // C is*() function. + + /// Convenience interface to ctype.is(ctype_base::space, __c). + template + inline bool + isspace(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::space, __c); } + + /// Convenience interface to ctype.is(ctype_base::print, __c). + template + inline bool + isprint(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::print, __c); } + + /// Convenience interface to ctype.is(ctype_base::cntrl, __c). + template + inline bool + iscntrl(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::cntrl, __c); } + + /// Convenience interface to ctype.is(ctype_base::upper, __c). + template + inline bool + isupper(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::upper, __c); } + + /// Convenience interface to ctype.is(ctype_base::lower, __c). + template + inline bool + islower(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::lower, __c); } + + /// Convenience interface to ctype.is(ctype_base::alpha, __c). + template + inline bool + isalpha(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::alpha, __c); } + + /// Convenience interface to ctype.is(ctype_base::digit, __c). + template + inline bool + isdigit(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::digit, __c); } + + /// Convenience interface to ctype.is(ctype_base::punct, __c). + template + inline bool + ispunct(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::punct, __c); } + + /// Convenience interface to ctype.is(ctype_base::xdigit, __c). + template + inline bool + isxdigit(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::xdigit, __c); } + + /// Convenience interface to ctype.is(ctype_base::alnum, __c). + template + inline bool + isalnum(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::alnum, __c); } + + /// Convenience interface to ctype.is(ctype_base::graph, __c). + template + inline bool + isgraph(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::graph, __c); } + +#if __cplusplus >= 201103L + /// Convenience interface to ctype.is(ctype_base::blank, __c). + template + inline bool + isblank(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::blank, __c); } +#endif + + /// Convenience interface to ctype.toupper(__c). + template + inline _CharT + toupper(_CharT __c, const locale& __loc) + { return use_facet >(__loc).toupper(__c); } + + /// Convenience interface to ctype.tolower(__c). + template + inline _CharT + tolower(_CharT __c, const locale& __loc) + { return use_facet >(__loc).tolower(__c); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +# include + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..374a75414669f2deaae74965d74ee0f119c53c4e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc new file mode 100644 index 0000000000000000000000000000000000000000..ec7cce4a64043f71c1b849415af375af72b021d1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc @@ -0,0 +1,1404 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_FACETS_TCC +#define _LOCALE_FACETS_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Routine to access a cache for the facet. If the cache didn't + // exist before, it gets constructed on the fly. + template + struct __use_cache + { + const _Facet* + operator() (const locale& __loc) const; + }; + + // Specializations. + template + struct __use_cache<__numpunct_cache<_CharT> > + { + const __numpunct_cache<_CharT>* + operator() (const locale& __loc) const + { + const size_t __i = numpunct<_CharT>::id._M_id(); + const locale::facet** __caches = __loc._M_impl->_M_caches; + if (!__caches[__i]) + { + __numpunct_cache<_CharT>* __tmp = 0; + __try + { + __tmp = new __numpunct_cache<_CharT>; + __tmp->_M_cache(__loc); + } + __catch(...) + { + delete __tmp; + __throw_exception_again; + } + __loc._M_impl->_M_install_cache(__tmp, __i); + } + return static_cast*>(__caches[__i]); + } + }; + + template + void + __numpunct_cache<_CharT>::_M_cache(const locale& __loc) + { + const numpunct<_CharT>& __np = use_facet >(__loc); + + char* __grouping = 0; + _CharT* __truename = 0; + _CharT* __falsename = 0; + __try + { + const string& __g = __np.grouping(); + _M_grouping_size = __g.size(); + __grouping = new char[_M_grouping_size]; + __g.copy(__grouping, _M_grouping_size); + _M_use_grouping = (_M_grouping_size + && static_cast(__grouping[0]) > 0 + && (__grouping[0] + != __gnu_cxx::__numeric_traits::__max)); + + const basic_string<_CharT>& __tn = __np.truename(); + _M_truename_size = __tn.size(); + __truename = new _CharT[_M_truename_size]; + __tn.copy(__truename, _M_truename_size); + + const basic_string<_CharT>& __fn = __np.falsename(); + _M_falsename_size = __fn.size(); + __falsename = new _CharT[_M_falsename_size]; + __fn.copy(__falsename, _M_falsename_size); + + _M_decimal_point = __np.decimal_point(); + _M_thousands_sep = __np.thousands_sep(); + + const ctype<_CharT>& __ct = use_facet >(__loc); + __ct.widen(__num_base::_S_atoms_out, + __num_base::_S_atoms_out + + __num_base::_S_oend, _M_atoms_out); + __ct.widen(__num_base::_S_atoms_in, + __num_base::_S_atoms_in + + __num_base::_S_iend, _M_atoms_in); + + _M_grouping = __grouping; + _M_truename = __truename; + _M_falsename = __falsename; + _M_allocated = true; + } + __catch(...) + { + delete [] __grouping; + delete [] __truename; + delete [] __falsename; + __throw_exception_again; + } + } + + // Used by both numeric and monetary facets. + // Check to make sure that the __grouping_tmp string constructed in + // money_get or num_get matches the canonical grouping for a given + // locale. + // __grouping_tmp is parsed L to R + // 1,222,444 == __grouping_tmp of "\1\3\3" + // __grouping is parsed R to L + // 1,222,444 == __grouping of "\3" == "\3\3\3" + _GLIBCXX_PURE bool + __verify_grouping(const char* __grouping, size_t __grouping_size, + const string& __grouping_tmp) throw (); + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + template + _GLIBCXX_DEFAULT_ABI_TAG + _InIter + num_get<_CharT, _InIter>:: + _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io, + ios_base::iostate& __err, string& __xtrc) const + { + typedef char_traits<_CharT> __traits_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); + + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; + + // First check for sign. + if (!__testeof) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) + && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + { + __xtrc += __plus ? '+' : '-'; + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + } + + // Next, look for leading zeros. + bool __found_mantissa = false; + int __sep_pos = 0; + while (!__testeof) + { + if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + || __c == __lc->_M_decimal_point) + break; + else if (__c == __lit[__num_base::_S_izero]) + { + if (!__found_mantissa) + { + __xtrc += '0'; + __found_mantissa = true; + } + ++__sep_pos; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + break; + } + + // Only need acceptable digits for floating point numbers. + bool __found_dec = false; + bool __found_sci = false; + string __found_grouping; + if (__lc->_M_use_grouping) + __found_grouping.reserve(32); + const char_type* __lit_zero = __lit + __num_base::_S_izero; + + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + const int __digit = _M_find(__lit_zero, 10, __c); + if (__digit != -1) + { + __xtrc += '0' + __digit; + __found_mantissa = true; + } + else if (__c == __lc->_M_decimal_point + && !__found_dec && !__found_sci) + { + __xtrc += '.'; + __found_dec = true; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if (__plus || __c == __lit[__num_base::_S_iminus]) + __xtrc += __plus ? '+' : '-'; + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + if (!__found_dec && !__found_sci) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + // NB: __convert_to_v will not assign __v and will + // set the failbit. + __xtrc.clear(); + break; + } + } + else + break; + } + else if (__c == __lc->_M_decimal_point) + { + if (!__found_dec && !__found_sci) + { + // If no grouping chars are seen, no grouping check + // is applied. Therefore __found_grouping is adjusted + // only if decimal_point comes after some thousands_sep. + if (__found_grouping.size()) + __found_grouping += static_cast(__sep_pos); + __xtrc += '.'; + __found_dec = true; + } + else + break; + } + else + { + const char_type* __q = + __traits_type::find(__lit_zero, 10, __c); + if (__q) + { + __xtrc += '0' + (__q - __lit_zero); + __found_mantissa = true; + ++__sep_pos; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + if (__found_grouping.size() && !__found_dec) + __found_grouping += static_cast(__sep_pos); + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) + && !(__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + __xtrc += __plus ? '+' : '-'; + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + + // Digit grouping is checked. If grouping and found_grouping don't + // match, then get very very upset, and set failbit. + if (__found_grouping.size()) + { + // Add the ending grouping if a decimal or 'e'/'E' wasn't found. + if (!__found_dec && !__found_sci) + __found_grouping += static_cast(__sep_pos); + + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __found_grouping)) + __err = ios_base::failbit; + } + + return __beg; + } + + template + template + _GLIBCXX_DEFAULT_ABI_TAG + _InIter + num_get<_CharT, _InIter>:: + _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io, + ios_base::iostate& __err, _ValueT& __v) const + { + typedef char_traits<_CharT> __traits_type; + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); + + // NB: Iff __basefield == 0, __base can change based on contents. + const ios_base::fmtflags __basefield = __io.flags() + & ios_base::basefield; + const bool __oct = __basefield == ios_base::oct; + int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10); + + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; + + // First check for sign. + bool __negative = false; + if (!__testeof) + { + __c = *__beg; + __negative = __c == __lit[__num_base::_S_iminus]; + if ((__negative || __c == __lit[__num_base::_S_iplus]) + && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + { + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + } + + // Next, look for leading zeros and check required digits + // for base formats. + bool __found_zero = false; + int __sep_pos = 0; + while (!__testeof) + { + if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + || __c == __lc->_M_decimal_point) + break; + else if (__c == __lit[__num_base::_S_izero] + && (!__found_zero || __base == 10)) + { + __found_zero = true; + ++__sep_pos; + if (__basefield == 0) + __base = 8; + if (__base == 8) + __sep_pos = 0; + } + else if (__found_zero + && (__c == __lit[__num_base::_S_ix] + || __c == __lit[__num_base::_S_iX])) + { + if (__basefield == 0) + __base = 16; + if (__base == 16) + { + __found_zero = false; + __sep_pos = 0; + } + else + break; + } + else + break; + + if (++__beg != __end) + { + __c = *__beg; + if (!__found_zero) + break; + } + else + __testeof = true; + } + + // At this point, base is determined. If not hex, only allow + // base digits as valid input. + const size_t __len = (__base == 16 ? __num_base::_S_iend + - __num_base::_S_izero : __base); + + // Extract. + typedef __gnu_cxx::__numeric_traits<_ValueT> __num_traits; + string __found_grouping; + if (__lc->_M_use_grouping) + __found_grouping.reserve(32); + bool __testfail = false; + bool __testoverflow = false; + const __unsigned_type __max = + (__negative && __num_traits::__is_signed) + ? -static_cast<__unsigned_type>(__num_traits::__min) + : __num_traits::__max; + const __unsigned_type __smax = __max / __base; + __unsigned_type __result = 0; + int __digit = 0; + const char_type* __lit_zero = __lit + __num_base::_S_izero; + + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + __digit = _M_find(__lit_zero, __len, __c); + if (__digit == -1) + break; + + if (__result > __smax) + __testoverflow = true; + else + { + __result *= __base; + __testoverflow |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + __testfail = true; + break; + } + } + else if (__c == __lc->_M_decimal_point) + break; + else + { + const char_type* __q = + __traits_type::find(__lit_zero, __len, __c); + if (!__q) + break; + + __digit = __q - __lit_zero; + if (__digit > 15) + __digit -= 6; + if (__result > __smax) + __testoverflow = true; + else + { + __result *= __base; + __testoverflow |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + + // Digit grouping is checked. If grouping and found_grouping don't + // match, then get very very upset, and set failbit. + if (__found_grouping.size()) + { + // Add the ending grouping. + __found_grouping += static_cast(__sep_pos); + + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __found_grouping)) + __err = ios_base::failbit; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + if ((!__sep_pos && !__found_zero && !__found_grouping.size()) + || __testfail) + { + __v = 0; + __err = ios_base::failbit; + } + else if (__testoverflow) + { + if (__negative && __num_traits::__is_signed) + __v = __num_traits::__min; + else + __v = __num_traits::__max; + __err = ios_base::failbit; + } + else + __v = __negative ? -__result : __result; + + if (__testeof) + __err |= ios_base::eofbit; + return __beg; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 17. Bad bool parsing + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, bool& __v) const + { + if (!(__io.flags() & ios_base::boolalpha)) + { + // Parse bool values as long. + // NB: We can't just call do_get(long) here, as it might + // refer to a derived class. + long __l = -1; + __beg = _M_extract_int(__beg, __end, __io, __err, __l); + if (__l == 0 || __l == 1) + __v = bool(__l); + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = true; + __err = ios_base::failbit; + if (__beg == __end) + __err |= ios_base::eofbit; + } + } + else + { + // Parse bool values as alphanumeric. + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + bool __testf = true; + bool __testt = true; + bool __donef = __lc->_M_falsename_size == 0; + bool __donet = __lc->_M_truename_size == 0; + bool __testeof = false; + size_t __n = 0; + while (!__donef || !__donet) + { + if (__beg == __end) + { + __testeof = true; + break; + } + + const char_type __c = *__beg; + + if (!__donef) + __testf = __c == __lc->_M_falsename[__n]; + + if (!__testf && __donet) + break; + + if (!__donet) + __testt = __c == __lc->_M_truename[__n]; + + if (!__testt && __donef) + break; + + if (!__testt && !__testf) + break; + + ++__n; + ++__beg; + + __donef = !__testf || __n >= __lc->_M_falsename_size; + __donet = !__testt || __n >= __lc->_M_truename_size; + } + if (__testf && __n == __lc->_M_falsename_size && __n) + { + __v = false; + if (__testt && __n == __lc->_M_truename_size) + __err = ios_base::failbit; + else + __err = __testeof ? ios_base::eofbit : ios_base::goodbit; + } + else if (__testt && __n == __lc->_M_truename_size && __n) + { + __v = true; + __err = __testeof ? ios_base::eofbit : ios_base::goodbit; + } + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = false; + __err = ios_base::failbit; + if (__testeof) + __err |= ios_base::eofbit; + } + } + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, float& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _InIter + num_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } +#endif + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, void*& __v) const + { + // Prepare for hex formatted input. + typedef ios_base::fmtflags fmtflags; + const fmtflags __fmt = __io.flags(); + __io.flags((__fmt & ~ios_base::basefield) | ios_base::hex); + + typedef __gnu_cxx::__conditional_type<(sizeof(void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + + _UIntPtrType __ul; + __beg = _M_extract_int(__beg, __end, __io, __err, __ul); + + // Reset from hex formatted input. + __io.flags(__fmt); + + __v = reinterpret_cast(__ul); + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _InIter + num_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, __ibm128& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } +#endif + + // For use by integer and floating-point types after they have been + // converted into a char_type string. + template + void + num_put<_CharT, _OutIter>:: + _M_pad(_CharT __fill, streamsize __w, ios_base& __io, + _CharT* __new, const _CharT* __cs, int& __len) const + { + // [22.2.2.2.2] Stage 3. + // If necessary, pad. + __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, + __cs, __w, __len); + __len = static_cast(__w); + } + +_GLIBCXX_END_NAMESPACE_LDBL + + template + int + __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit, + ios_base::fmtflags __flags, bool __dec) + { + _CharT* __buf = __bufend; + if (__builtin_expect(__dec, true)) + { + // Decimal. + do + { + *--__buf = __lit[(__v % 10) + __num_base::_S_odigits]; + __v /= 10; + } + while (__v != 0); + } + else if ((__flags & ios_base::basefield) == ios_base::oct) + { + // Octal. + do + { + *--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits]; + __v >>= 3; + } + while (__v != 0); + } + else + { + // Hex. + const bool __uppercase = __flags & ios_base::uppercase; + const int __case_offset = __uppercase ? __num_base::_S_oudigits + : __num_base::_S_odigits; + do + { + *--__buf = __lit[(__v & 0xf) + __case_offset]; + __v >>= 4; + } + while (__v != 0); + } + return __bufend - __buf; + } + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + template + void + num_put<_CharT, _OutIter>:: + _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep, + ios_base&, _CharT* __new, _CharT* __cs, int& __len) const + { + _CharT* __p = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, __cs, __cs + __len); + __len = __p - __new; + } + + template + template + _OutIter + num_put<_CharT, _OutIter>:: + _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill, + _ValueT __v) const + { + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_out; + const ios_base::fmtflags __flags = __io.flags(); + + // Long enough to hold hex, dec, and octal representations. + const int __ilen = 5 * sizeof(_ValueT); + _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __ilen)); + + // [22.2.2.2.2] Stage 1, numeric conversion to character. + // Result is returned right-justified in the buffer. + const ios_base::fmtflags __basefield = __flags & ios_base::basefield; + const bool __dec = (__basefield != ios_base::oct + && __basefield != ios_base::hex); + const __unsigned_type __u = ((__v > 0 || !__dec) + ? __unsigned_type(__v) + : -__unsigned_type(__v)); + int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec); + __cs += __ilen - __len; + + // Add grouping, if necessary. + if (__lc->_M_use_grouping) + { + // Grouping can add (almost) as many separators as the number + // of digits + space is reserved for numeric base or sign. + _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * (__len + 1) + * 2)); + _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size, + __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len); + __cs = __cs2 + 2; + } + + // Complete Stage 1, prepend numeric base or sign. + if (__builtin_expect(__dec, true)) + { + // Decimal. + if (__v >= 0) + { + if (bool(__flags & ios_base::showpos) + && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) + *--__cs = __lit[__num_base::_S_oplus], ++__len; + } + else + *--__cs = __lit[__num_base::_S_ominus], ++__len; + } + else if (bool(__flags & ios_base::showbase) && __v) + { + if (__basefield == ios_base::oct) + *--__cs = __lit[__num_base::_S_odigits], ++__len; + else + { + // 'x' or 'X' + const bool __uppercase = __flags & ios_base::uppercase; + *--__cs = __lit[__num_base::_S_ox + __uppercase]; + // '0' + *--__cs = __lit[__num_base::_S_odigits]; + __len += 2; + } + } + + // Pad. + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __w)); + _M_pad(__fill, __w, __io, __cs3, __cs, __len); + __cs = __cs3; + } + __io.width(0); + + // [22.2.2.2.2] Stage 4. + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __cs, __len); + } + + template + void + num_put<_CharT, _OutIter>:: + _M_group_float(const char* __grouping, size_t __grouping_size, + _CharT __sep, const _CharT* __p, _CharT* __new, + _CharT* __cs, int& __len) const + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 282. What types does numpunct grouping refer to? + // Add grouping, if necessary. + const int __declen = __p ? __p - __cs : __len; + _CharT* __p2 = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, + __cs, __cs + __declen); + + // Tack on decimal part. + int __newlen = __p2 - __new; + if (__p) + { + char_traits<_CharT>::copy(__p2, __p, __len - __declen); + __newlen += __len - __declen; + } + __len = __newlen; + } + + // The following code uses vsnprintf (or vsprintf(), when + // _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point + // values for insertion into a stream. An optimization would be to + // replace them with code that works directly on a wide buffer and + // then use __pad to do the padding. It would be good to replace + // them anyway to gain back the efficiency that C++ provides by + // knowing up front the type of the values to insert. Also, sprintf + // is dangerous since may lead to accidental buffer overruns. This + // implementation follows the C++ standard fairly directly as + // outlined in 22.2.2.2 [lib.locale.num.put] + template + template + _OutIter + num_put<_CharT, _OutIter>:: + _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod, + _ValueT __v) const + { + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + // Use default precision if out of range. + const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision(); + + const int __max_digits = + __gnu_cxx::__numeric_traits<_ValueT>::__digits10; + + // [22.2.2.2.2] Stage 1, numeric conversion to character. + int __len; + // Long enough for the max format spec. + char __fbuf[16]; + __num_base::_S_format_float(__io, __fbuf, __mod); + +#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF + // Precision is always used except for hexfloat format. + const bool __use_prec = + (__io.flags() & ios_base::floatfield) != ios_base::floatfield; + + // First try a buffer perhaps big enough (most probably sufficient + // for non-ios_base::fixed outputs) + int __cs_size = __max_digits * 3; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); + + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); + } +#else + // Consider the possibility of long ios_base::fixed outputs + const bool __fixed = __io.flags() & ios_base::fixed; + const int __max_exp = + __gnu_cxx::__numeric_traits<_ValueT>::__max_exponent10; + + // The size of the output string is computed as follows. + // ios_base::fixed outputs may need up to __max_exp + 1 chars + // for the integer part + __prec chars for the fractional part + // + 3 chars for sign, decimal point, '\0'. On the other hand, + // for non-fixed outputs __max_digits * 2 + __prec chars are + // largely sufficient. + const int __cs_size = __fixed ? __max_exp + __prec + 4 + : __max_digits * 2 + __prec; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf, + __prec, __v); +#endif + + // [22.2.2.2.2] Stage 2, convert to char_type, using correct + // numpunct.decimal_point() values for '.' and adding grouping. + const ctype<_CharT>& __ctype = use_facet >(__loc); + + _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len)); + __ctype.widen(__cs, __cs + __len, __ws); + + // Replace decimal point. + _CharT* __wp = 0; + const char* __p = char_traits::find(__cs, __len, '.'); + if (__p) + { + __wp = __ws + (__p - __cs); + *__wp = __lc->_M_decimal_point; + } + + // Add grouping, if necessary. + // N.B. Make sure to not group things like 2e20, i.e., no decimal + // point, scientific notation. + if (__lc->_M_use_grouping + && (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9' + && __cs[1] >= '0' && __cs[2] >= '0'))) + { + // Grouping can add (almost) as many separators as the + // number of digits, but no more. + _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len * 2)); + + streamsize __off = 0; + if (__cs[0] == '-' || __cs[0] == '+') + { + __off = 1; + __ws2[0] = __ws[0]; + __len -= 1; + } + + _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size, + __lc->_M_thousands_sep, __wp, __ws2 + __off, + __ws + __off, __len); + __len += __off; + + __ws = __ws2; + } + + // Pad. + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __w)); + _M_pad(__fill, __w, __io, __ws3, __ws, __len); + __ws = __ws3; + } + __io.width(0); + + // [22.2.2.2.2] Stage 4. + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __ws, __len); + } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const + { + const ios_base::fmtflags __flags = __io.flags(); + if ((__flags & ios_base::boolalpha) == 0) + { + const long __l = __v; + __s = _M_insert_int(__s, __io, __fill, __l); + } + else + { + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + const _CharT* __name = __v ? __lc->_M_truename + : __lc->_M_falsename; + int __len = __v ? __lc->_M_truename_size + : __lc->_M_falsename_size; + + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + const streamsize __plen = __w - __len; + _CharT* __ps + = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __plen)); + + char_traits<_CharT>::assign(__ps, __plen, __fill); + __io.width(0); + + if ((__flags & ios_base::adjustfield) == ios_base::left) + { + __s = std::__write(__s, __name, __len); + __s = std::__write(__s, __ps, __plen); + } + else + { + __s = std::__write(__s, __ps, __plen); + __s = std::__write(__s, __name, __len); + } + return __s; + } + __io.width(0); + __s = std::__write(__s, __name, __len); + } + return __s; + } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return _M_insert_float(__s, __io, __fill, char(), __v); } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _OutIter + num_put<_CharT, _OutIter>:: + __do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return _M_insert_float(__s, __io, __fill, char(), __v); } +#endif + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, + long double __v) const + { return _M_insert_float(__s, __io, __fill, 'L', __v); } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, + const void* __v) const + { + const ios_base::fmtflags __flags = __io.flags(); + const ios_base::fmtflags __fmt = ~(ios_base::basefield + | ios_base::uppercase); + __io.flags((__flags & __fmt) | (ios_base::hex | ios_base::showbase)); + + typedef __gnu_cxx::__conditional_type<(sizeof(const void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + + __s = _M_insert_int(__s, __io, __fill, + reinterpret_cast<_UIntPtrType>(__v)); + __io.flags(__flags); + return __s; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _OutIter + num_put<_CharT, _OutIter>:: + __do_put(iter_type __s, ios_base& __io, char_type __fill, + __ibm128 __v) const + { return _M_insert_float(__s, __io, __fill, 'L', __v); } +#endif +_GLIBCXX_END_NAMESPACE_LDBL + + // Construct correctly padded string, as per 22.2.2.2.2 + // Assumes + // __newlen > __oldlen + // __news is allocated for __newlen size + + // NB: Of the two parameters, _CharT can be deduced from the + // function arguments. The other (_Traits) has to be explicitly specified. + template + void + __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, + _CharT* __news, const _CharT* __olds, + streamsize __newlen, streamsize __oldlen) + { + const size_t __plen = static_cast(__newlen - __oldlen); + const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield; + + // Padding last. + if (__adjust == ios_base::left) + { + _Traits::copy(__news, __olds, __oldlen); + _Traits::assign(__news + __oldlen, __plen, __fill); + return; + } + + size_t __mod = 0; + if (__adjust == ios_base::internal) + { + // Pad after the sign, if there is one. + // Pad after 0[xX], if there is one. + // Who came up with these rules, anyway? Jeeze. + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + if (__ctype.widen('-') == __olds[0] + || __ctype.widen('+') == __olds[0]) + { + __news[0] = __olds[0]; + __mod = 1; + ++__news; + } + else if (__ctype.widen('0') == __olds[0] + && __oldlen > 1 + && (__ctype.widen('x') == __olds[1] + || __ctype.widen('X') == __olds[1])) + { + __news[0] = __olds[0]; + __news[1] = __olds[1]; + __mod = 2; + __news += 2; + } + // else Padding first. + } + _Traits::assign(__news, __plen, __fill); + _Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod); + } + + template + _CharT* + __add_grouping(_CharT* __s, _CharT __sep, + const char* __gbeg, size_t __gsize, + const _CharT* __first, const _CharT* __last) + { + size_t __idx = 0; + size_t __ctr = 0; + + while (__last - __first > __gbeg[__idx] + && static_cast(__gbeg[__idx]) > 0 + && __gbeg[__idx] != __gnu_cxx::__numeric_traits::__max) + { + __last -= __gbeg[__idx]; + __idx < __gsize - 1 ? ++__idx : ++__ctr; + } + + while (__first != __last) + *__s++ = *__first++; + + while (__ctr--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + + while (__idx--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + + return __s; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct; + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL num_get; + extern template class _GLIBCXX_NAMESPACE_LDBL num_put; + extern template class ctype_byname; + + extern template + const ctype& + use_facet >(const locale&); + + extern template + const numpunct& + use_facet >(const locale&); + + extern template + const num_put& + use_facet >(const locale&); + + extern template + const num_get& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct; + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL num_get; + extern template class _GLIBCXX_NAMESPACE_LDBL num_put; + extern template class ctype_byname; + + extern template + const ctype& + use_facet >(const locale&); + + extern template + const numpunct& + use_facet >(const locale&); + + extern template + const num_put& + use_facet >(const locale&); + + extern template + const num_get& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..dfd2510517403c5e4d6c58d992cb43332a5e8760 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h new file mode 100644 index 0000000000000000000000000000000000000000..71a82af5ee32d760782855fc8380273dbd2723e6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h @@ -0,0 +1,2071 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets_nonio.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FACETS_NONIO_H +#define _LOCALE_FACETS_NONIO_H 1 + +#pragma GCC system_header + +#include // For struct tm + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Time format ordering data. + * @ingroup locales + * + * This class provides an enum representing different orderings of + * time: day, month, and year. + */ + class time_base + { + public: + enum dateorder { no_order, dmy, mdy, ymd, ydm }; + }; + + template + struct __timepunct_cache : public locale::facet + { + // List of all known timezones, with GMT first. + static const _CharT* _S_timezones[14]; + + const _CharT* _M_date_format; + const _CharT* _M_date_era_format; + const _CharT* _M_time_format; + const _CharT* _M_time_era_format; + const _CharT* _M_date_time_format; + const _CharT* _M_date_time_era_format; + const _CharT* _M_am; + const _CharT* _M_pm; + const _CharT* _M_am_pm_format; + + // Day names, starting with "C"'s Sunday. + const _CharT* _M_day1; + const _CharT* _M_day2; + const _CharT* _M_day3; + const _CharT* _M_day4; + const _CharT* _M_day5; + const _CharT* _M_day6; + const _CharT* _M_day7; + + // Abbreviated day names, starting with "C"'s Sun. + const _CharT* _M_aday1; + const _CharT* _M_aday2; + const _CharT* _M_aday3; + const _CharT* _M_aday4; + const _CharT* _M_aday5; + const _CharT* _M_aday6; + const _CharT* _M_aday7; + + // Month names, starting with "C"'s January. + const _CharT* _M_month01; + const _CharT* _M_month02; + const _CharT* _M_month03; + const _CharT* _M_month04; + const _CharT* _M_month05; + const _CharT* _M_month06; + const _CharT* _M_month07; + const _CharT* _M_month08; + const _CharT* _M_month09; + const _CharT* _M_month10; + const _CharT* _M_month11; + const _CharT* _M_month12; + + // Abbreviated month names, starting with "C"'s Jan. + const _CharT* _M_amonth01; + const _CharT* _M_amonth02; + const _CharT* _M_amonth03; + const _CharT* _M_amonth04; + const _CharT* _M_amonth05; + const _CharT* _M_amonth06; + const _CharT* _M_amonth07; + const _CharT* _M_amonth08; + const _CharT* _M_amonth09; + const _CharT* _M_amonth10; + const _CharT* _M_amonth11; + const _CharT* _M_amonth12; + + bool _M_allocated; + + __timepunct_cache(size_t __refs = 0) : facet(__refs), + _M_date_format(0), _M_date_era_format(0), _M_time_format(0), + _M_time_era_format(0), _M_date_time_format(0), + _M_date_time_era_format(0), _M_am(0), _M_pm(0), + _M_am_pm_format(0), _M_day1(0), _M_day2(0), _M_day3(0), + _M_day4(0), _M_day5(0), _M_day6(0), _M_day7(0), + _M_aday1(0), _M_aday2(0), _M_aday3(0), _M_aday4(0), + _M_aday5(0), _M_aday6(0), _M_aday7(0), _M_month01(0), + _M_month02(0), _M_month03(0), _M_month04(0), _M_month05(0), + _M_month06(0), _M_month07(0), _M_month08(0), _M_month09(0), + _M_month10(0), _M_month11(0), _M_month12(0), _M_amonth01(0), + _M_amonth02(0), _M_amonth03(0), _M_amonth04(0), + _M_amonth05(0), _M_amonth06(0), _M_amonth07(0), + _M_amonth08(0), _M_amonth09(0), _M_amonth10(0), + _M_amonth11(0), _M_amonth12(0), _M_allocated(false) + { } + + ~__timepunct_cache(); + + private: + __timepunct_cache& + operator=(const __timepunct_cache&); + + explicit + __timepunct_cache(const __timepunct_cache&); + }; + + template + __timepunct_cache<_CharT>::~__timepunct_cache() + { + if (_M_allocated) + { + // Unused. + } + } + + // Specializations. + template<> + const char* + __timepunct_cache::_S_timezones[14]; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + const wchar_t* + __timepunct_cache::_S_timezones[14]; +#endif + + // Generic. + template + const _CharT* __timepunct_cache<_CharT>::_S_timezones[14]; + + template + class __timepunct : public locale::facet + { + public: + // Types: + typedef _CharT __char_type; + typedef __timepunct_cache<_CharT> __cache_type; + + protected: + __cache_type* _M_data; + __c_locale _M_c_locale_timepunct; + const char* _M_name_timepunct; + + public: + /// Numpunct facet id. + static locale::id id; + + explicit + __timepunct(size_t __refs = 0); + + explicit + __timepunct(__cache_type* __cache, size_t __refs = 0); + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param refs Passed to the base facet class. + */ + explicit + __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0); + + // FIXME: for error checking purposes _M_put should return the return + // value of strftime/wcsftime. + void + _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format, + const tm* __tm) const throw (); + + void + _M_date_formats(const _CharT** __date) const + { + // Always have default first. + __date[0] = _M_data->_M_date_format; + __date[1] = _M_data->_M_date_era_format; + } + + void + _M_time_formats(const _CharT** __time) const + { + // Always have default first. + __time[0] = _M_data->_M_time_format; + __time[1] = _M_data->_M_time_era_format; + } + + void + _M_date_time_formats(const _CharT** __dt) const + { + // Always have default first. + __dt[0] = _M_data->_M_date_time_format; + __dt[1] = _M_data->_M_date_time_era_format; + } + +#if !_GLIBCXX_INLINE_VERSION + void + _M_am_pm_format(const _CharT*) const + { /* Kept for ABI compatibility, see PR65927 */ } +#endif + + void + _M_am_pm_format(const _CharT** __ampm_format) const + { + __ampm_format[0] = _M_data->_M_am_pm_format; + } + + void + _M_am_pm(const _CharT** __ampm) const + { + __ampm[0] = _M_data->_M_am; + __ampm[1] = _M_data->_M_pm; + } + + void + _M_days(const _CharT** __days) const + { + __days[0] = _M_data->_M_day1; + __days[1] = _M_data->_M_day2; + __days[2] = _M_data->_M_day3; + __days[3] = _M_data->_M_day4; + __days[4] = _M_data->_M_day5; + __days[5] = _M_data->_M_day6; + __days[6] = _M_data->_M_day7; + } + + void + _M_days_abbreviated(const _CharT** __days) const + { + __days[0] = _M_data->_M_aday1; + __days[1] = _M_data->_M_aday2; + __days[2] = _M_data->_M_aday3; + __days[3] = _M_data->_M_aday4; + __days[4] = _M_data->_M_aday5; + __days[5] = _M_data->_M_aday6; + __days[6] = _M_data->_M_aday7; + } + + void + _M_months(const _CharT** __months) const + { + __months[0] = _M_data->_M_month01; + __months[1] = _M_data->_M_month02; + __months[2] = _M_data->_M_month03; + __months[3] = _M_data->_M_month04; + __months[4] = _M_data->_M_month05; + __months[5] = _M_data->_M_month06; + __months[6] = _M_data->_M_month07; + __months[7] = _M_data->_M_month08; + __months[8] = _M_data->_M_month09; + __months[9] = _M_data->_M_month10; + __months[10] = _M_data->_M_month11; + __months[11] = _M_data->_M_month12; + } + + void + _M_months_abbreviated(const _CharT** __months) const + { + __months[0] = _M_data->_M_amonth01; + __months[1] = _M_data->_M_amonth02; + __months[2] = _M_data->_M_amonth03; + __months[3] = _M_data->_M_amonth04; + __months[4] = _M_data->_M_amonth05; + __months[5] = _M_data->_M_amonth06; + __months[6] = _M_data->_M_amonth07; + __months[7] = _M_data->_M_amonth08; + __months[8] = _M_data->_M_amonth09; + __months[9] = _M_data->_M_amonth10; + __months[10] = _M_data->_M_amonth11; + __months[11] = _M_data->_M_amonth12; + } + + protected: + virtual + ~__timepunct(); + + // For use at construction time only. + void + _M_initialize_timepunct(__c_locale __cloc = 0); + }; + + template + locale::id __timepunct<_CharT>::id; + + // Specializations. + template<> + void + __timepunct::_M_initialize_timepunct(__c_locale __cloc); + + template<> + void + __timepunct::_M_put(char*, size_t, const char*, const tm*) const throw (); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + void + __timepunct::_M_initialize_timepunct(__c_locale __cloc); + + template<> + void + __timepunct::_M_put(wchar_t*, size_t, const wchar_t*, + const tm*) const throw (); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + + // Include host and configuration specific timepunct functions. + #include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __time_get_state + { + // Finalize state. + void + _M_finalize_state(tm* __tm); + + unsigned int _M_have_I : 1; + unsigned int _M_have_wday : 1; + unsigned int _M_have_yday : 1; + unsigned int _M_have_mon : 1; + unsigned int _M_have_mday : 1; + unsigned int _M_have_uweek : 1; + unsigned int _M_have_wweek : 1; + unsigned int _M_have_century : 1; + unsigned int _M_is_pm : 1; + unsigned int _M_want_century : 1; + unsigned int _M_want_xday : 1; + unsigned int _M_pad1 : 5; + unsigned int _M_week_no : 6; + unsigned int _M_pad2 : 10; + int _M_century; + int _M_pad3; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template time_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a date or + * time from a string. It is used by the istream numeric + * extraction operators. + * + * The time_get template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the time_get facet. + */ + template + class time_get : public locale::facet, public time_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + time_get(size_t __refs = 0) + : facet (__refs) { } + + /** + * @brief Return preferred order of month, day, and year. + * + * This function returns an enum from time_base::dateorder giving the + * preferred ordering if the format @a x given to time_put::put() only + * uses month, day, and year. If the format @a x for the associated + * locale uses other fields, this function returns + * time_base::dateorder::noorder. + * + * NOTE: The library always returns noorder at the moment. + * + * @return A member of time_base::dateorder. + */ + dateorder + date_order() const + { return this->do_date_order(); } + + /** + * @brief Parse input time string. + * + * This function parses a time according to the format @a X and puts the + * results into a user-supplied struct tm. The result is returned by + * calling time_get::do_get_time(). + * + * If there is a valid time string according to format @a X, @a tm will + * be filled in accordingly and the returned iterator will point to the + * first character beyond the time string. If an error occurs before + * the end, err |= ios_base::failbit. If parsing reads all the + * characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond time string. + */ + iter_type + get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_time(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input date string. + * + * This function parses a date according to the format @a x and puts the + * results into a user-supplied struct tm. The result is returned by + * calling time_get::do_get_date(). + * + * If there is a valid date string according to format @a x, @a tm will + * be filled in accordingly and the returned iterator will point to the + * first character beyond the date string. If an error occurs before + * the end, err |= ios_base::failbit. If parsing reads all the + * characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond date string. + */ + iter_type + get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_date(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input weekday string. + * + * This function parses a weekday name and puts the results into a + * user-supplied struct tm. The result is returned by calling + * time_get::do_get_weekday(). + * + * Parsing starts by parsing an abbreviated weekday name. If a valid + * abbreviation is followed by a character that would lead to the full + * weekday name, parsing continues until the full name is found or an + * error occurs. Otherwise parsing finishes at the end of the + * abbreviated name. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond weekday name. + */ + iter_type + get_weekday(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_weekday(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input month string. + * + * This function parses a month name and puts the results into a + * user-supplied struct tm. The result is returned by calling + * time_get::do_get_monthname(). + * + * Parsing starts by parsing an abbreviated month name. If a valid + * abbreviation is followed by a character that would lead to the full + * month name, parsing continues until the full name is found or an + * error occurs. Otherwise parsing finishes at the end of the + * abbreviated name. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= + * ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond month name. + */ + iter_type + get_monthname(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_monthname(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input year string. + * + * This function reads up to 4 characters to parse a year string and + * puts the results into a user-supplied struct tm. The result is + * returned by calling time_get::do_get_year(). + * + * 4 consecutive digits are interpreted as a full year. If there are + * exactly 2 consecutive digits, the library interprets this as the + * number of years since 1900. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond year. + */ + iter_type + get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_year(__beg, __end, __io, __err, __tm); } + +#if __cplusplus >= 201103L + /** + * @brief Parse input string according to format. + * + * This function calls time_get::do_get with the provided + * parameters. @see do_get() and get(). + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __format Format specifier. + * @param __modifier Format modifier. + * @return Iterator to first char not parsed. + */ + inline + iter_type get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, char __format, + char __modifier = 0) const + { + return this->do_get(__s, __end, __io, __err, __tm, __format, + __modifier); + } + + /** + * @brief Parse input string according to format. + * + * This function parses the input string according to a + * provided format string. It does the inverse of + * time_put::put. The format string follows the format + * specified for strftime(3)/strptime(3). The actual parsing + * is done by time_get::do_get. + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __fmt Start of the format string. + * @param __fmtend End of the format string. + * @return Iterator to first char not parsed. + */ + iter_type get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, const char_type* __fmt, + const char_type* __fmtend) const; +#endif // __cplusplus >= 201103L + + protected: + /// Destructor. + virtual + ~time_get() { } + + /** + * @brief Return preferred order of month, day, and year. + * + * This function returns an enum from time_base::dateorder giving the + * preferred ordering if the format @a x given to time_put::put() only + * uses month, day, and year. This function is a hook for derived + * classes to change the value returned. + * + * @return A member of time_base::dateorder. + */ + virtual dateorder + do_date_order() const; + + /** + * @brief Parse input time string. + * + * This function parses a time according to the format @a x and puts the + * results into a user-supplied struct tm. This function is a hook for + * derived classes to change the value returned. @see get_time() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond time string. + */ + virtual iter_type + do_get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input date string. + * + * This function parses a date according to the format @a X and puts the + * results into a user-supplied struct tm. This function is a hook for + * derived classes to change the value returned. @see get_date() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond date string. + */ + virtual iter_type + do_get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input weekday string. + * + * This function parses a weekday name and puts the results into a + * user-supplied struct tm. This function is a hook for derived + * classes to change the value returned. @see get_weekday() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond weekday name. + */ + virtual iter_type + do_get_weekday(iter_type __beg, iter_type __end, ios_base&, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input month string. + * + * This function parses a month name and puts the results into a + * user-supplied struct tm. This function is a hook for derived + * classes to change the value returned. @see get_monthname() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond month name. + */ + virtual iter_type + do_get_monthname(iter_type __beg, iter_type __end, ios_base&, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input year string. + * + * This function reads up to 4 characters to parse a year string and + * puts the results into a user-supplied struct tm. This function is a + * hook for derived classes to change the value returned. @see + * get_year() for details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond year. + */ + virtual iter_type + do_get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + +#if __cplusplus >= 201103L + /** + * @brief Parse input string according to format. + * + * This function parses the string according to the provided + * format and optional modifier. This function is a hook for + * derived classes to change the value returned. @see get() + * for more details. + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __f Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __format Format specifier. + * @param __modifier Format modifier. + * @return Iterator to first char not parsed. + */ +#if _GLIBCXX_USE_CXX11_ABI + virtual +#endif + iter_type + do_get(iter_type __s, iter_type __end, ios_base& __f, + ios_base::iostate& __err, tm* __tm, + char __format, char __modifier) const; +#endif // __cplusplus >= 201103L + + // Extract numeric component of length __len. + iter_type + _M_extract_num(iter_type __beg, iter_type __end, int& __member, + int __min, int __max, size_t __len, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract any unique array of string literals in a const _CharT* array. + iter_type + _M_extract_name(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract day or month name in a const _CharT* array. + iter_type + _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract on a component-by-component basis, via __format argument. + iter_type + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format) const; + + // Extract on a component-by-component basis, via __format argument, with + // state. + iter_type + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format, + __time_get_state &__state) const; + }; + + template + locale::id time_get<_CharT, _InIter>::id; + + /// class time_get_byname [22.2.5.2]. + template + class time_get_byname : public time_get<_CharT, _InIter> + { + public: + // Types: + typedef _CharT char_type; + typedef _InIter iter_type; + + explicit + time_get_byname(const char*, size_t __refs = 0) + : time_get<_CharT, _InIter>(__refs) { } + +#if __cplusplus >= 201103L + explicit + time_get_byname(const string& __s, size_t __refs = 0) + : time_get_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~time_get_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /** + * @brief Primary class template time_put. + * @ingroup locales + * + * This facet encapsulates the code to format and output dates and times + * according to formats used by strftime(). + * + * The time_put template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the time_put facet. + */ + template + class time_put : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + time_put(size_t __refs = 0) + : facet(__refs) { } + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format string. The format string is interpreted as by + * strftime(). + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __beg Start of format string. + * @param __end End of format string. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + const _CharT* __beg, const _CharT* __end) const; + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format char and optional modifier. The format and modifier + * are interpreted as by strftime(). It does so by returning + * time_put::do_put(). + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __format Format char. + * @param __mod Optional modifier char. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + const tm* __tm, char __format, char __mod = 0) const + { return this->do_put(__s, __io, __fill, __tm, __format, __mod); } + + protected: + /// Destructor. + virtual + ~time_put() + { } + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format char and optional modifier. This function is a hook + * for derived classes to change the value returned. @see put() for + * more details. + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __format Format char. + * @param __mod Optional modifier char. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + char __format, char __mod) const; + }; + + template + locale::id time_put<_CharT, _OutIter>::id; + + /// class time_put_byname [22.2.5.4]. + template + class time_put_byname : public time_put<_CharT, _OutIter> + { + public: + // Types: + typedef _CharT char_type; + typedef _OutIter iter_type; + + explicit + time_put_byname(const char*, size_t __refs = 0) + : time_put<_CharT, _OutIter>(__refs) + { } + +#if __cplusplus >= 201103L + explicit + time_put_byname(const string& __s, size_t __refs = 0) + : time_put_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~time_put_byname() { } + }; + + + /** + * @brief Money format ordering data. + * @ingroup locales + * + * This class contains an ordered array of 4 fields to represent the + * pattern for formatting a money amount. Each field may contain one entry + * from the part enum. symbol, sign, and value must be present and the + * remaining field must contain either none or space. @see + * moneypunct::pos_format() and moneypunct::neg_format() for details of how + * these fields are interpreted. + */ + class money_base + { + public: + enum part { none, space, symbol, sign, value }; + struct pattern { char field[4]; }; + + static const pattern _S_default_pattern; + + enum + { + _S_minus, + _S_zero, + _S_end = 11 + }; + + // String literal of acceptable (narrow) input/output, for + // money_get/money_put. "-0123456789" + static const char* _S_atoms; + + // Construct and return valid pattern consisting of some combination of: + // space none symbol sign value + _GLIBCXX_CONST static pattern + _S_construct_pattern(char __precedes, char __space, char __posn) throw (); + }; + + template + struct __moneypunct_cache : public locale::facet + { + const char* _M_grouping; + size_t _M_grouping_size; + bool _M_use_grouping; + _CharT _M_decimal_point; + _CharT _M_thousands_sep; + const _CharT* _M_curr_symbol; + size_t _M_curr_symbol_size; + const _CharT* _M_positive_sign; + size_t _M_positive_sign_size; + const _CharT* _M_negative_sign; + size_t _M_negative_sign_size; + int _M_frac_digits; + money_base::pattern _M_pos_format; + money_base::pattern _M_neg_format; + + // A list of valid numeric literals for input and output: in the standard + // "C" locale, this is "-0123456789". This array contains the chars after + // having been passed through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms[money_base::_S_end]; + + bool _M_allocated; + + __moneypunct_cache(size_t __refs = 0) : facet(__refs), + _M_grouping(0), _M_grouping_size(0), _M_use_grouping(false), + _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()), + _M_curr_symbol(0), _M_curr_symbol_size(0), + _M_positive_sign(0), _M_positive_sign_size(0), + _M_negative_sign(0), _M_negative_sign_size(0), + _M_frac_digits(0), + _M_pos_format(money_base::pattern()), + _M_neg_format(money_base::pattern()), _M_allocated(false) + { } + + ~__moneypunct_cache(); + + void + _M_cache(const locale& __loc); + + private: + __moneypunct_cache& + operator=(const __moneypunct_cache&); + + explicit + __moneypunct_cache(const __moneypunct_cache&); + }; + + template + __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache() + { + if (_M_allocated) + { + delete [] _M_grouping; + delete [] _M_curr_symbol; + delete [] _M_positive_sign; + delete [] _M_negative_sign; + } + } + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template moneypunct. + * @ingroup locales + * + * This facet encapsulates the punctuation, grouping and other formatting + * features of money amount string representations. + */ + template + class moneypunct : public locale::facet, public money_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + private: + __cache_type* _M_data; + + public: + /// This value is provided by the standard, but no reason for its + /// existence. + static const bool intl = _Intl; + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_moneypunct(); } + + /** + * @brief Constructor performs initialization. + * + * This is an internal constructor. + * + * @param __cache Cache for optimization. + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(__cache_type* __cache, size_t __refs = 0) + : facet(__refs), _M_data(__cache) + { _M_initialize_moneypunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_moneypunct(__cloc, __s); } + + /** + * @brief Return decimal point character. + * + * This function returns a char_type to use as a decimal point. It + * does so by returning returning + * moneypunct::do_decimal_point(). + * + * @return @a char_type representing a decimal point. + */ + char_type + decimal_point() const + { return this->do_decimal_point(); } + + /** + * @brief Return thousands separator character. + * + * This function returns a char_type to use as a thousands + * separator. It does so by returning returning + * moneypunct::do_thousands_sep(). + * + * @return char_type representing a thousands separator. + */ + char_type + thousands_sep() const + { return this->do_thousands_sep(); } + + /** + * @brief Return grouping specification. + * + * This function returns a string representing groupings for the + * integer part of an amount. Groupings indicate where thousands + * separators should be inserted. + * + * Each char in the return string is interpret as an integer rather + * than a character. These numbers represent the number of digits in a + * group. The first char in the string represents the number of digits + * in the least significant group. If a char is negative, it indicates + * an unlimited number of digits for the group. If more chars from the + * string are required to group a number, the last char is used + * repeatedly. + * + * For example, if the grouping() returns \003\002 + * and is applied to the number 123456789, this corresponds to + * 12,34,56,789. Note that if the string was 32, this would + * put more than 50 digits into the least significant group if + * the character set is ASCII. + * + * The string is returned by calling + * moneypunct::do_grouping(). + * + * @return string representing grouping specification. + */ + string + grouping() const + { return this->do_grouping(); } + + /** + * @brief Return currency symbol string. + * + * This function returns a string_type to use as a currency symbol. It + * does so by returning returning + * moneypunct::do_curr_symbol(). + * + * @return @a string_type representing a currency symbol. + */ + string_type + curr_symbol() const + { return this->do_curr_symbol(); } + + /** + * @brief Return positive sign string. + * + * This function returns a string_type to use as a sign for positive + * amounts. It does so by returning returning + * moneypunct::do_positive_sign(). + * + * If the return value contains more than one character, the first + * character appears in the position indicated by pos_format() and the + * remainder appear at the end of the formatted string. + * + * @return @a string_type representing a positive sign. + */ + string_type + positive_sign() const + { return this->do_positive_sign(); } + + /** + * @brief Return negative sign string. + * + * This function returns a string_type to use as a sign for negative + * amounts. It does so by returning returning + * moneypunct::do_negative_sign(). + * + * If the return value contains more than one character, the first + * character appears in the position indicated by neg_format() and the + * remainder appear at the end of the formatted string. + * + * @return @a string_type representing a negative sign. + */ + string_type + negative_sign() const + { return this->do_negative_sign(); } + + /** + * @brief Return number of digits in fraction. + * + * This function returns the exact number of digits that make up the + * fractional part of a money amount. It does so by returning + * returning moneypunct::do_frac_digits(). + * + * The fractional part of a money amount is optional. But if it is + * present, there must be frac_digits() digits. + * + * @return Number of digits in amount fraction. + */ + int + frac_digits() const + { return this->do_frac_digits(); } + + ///@{ + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * positive or negative valued money amount. It does so by returning + * returning moneypunct::do_pos_format() or + * moneypunct::do_neg_format(). + * + * The pattern has 4 fields describing the ordering of symbol, sign, + * value, and none or space. There must be one of each in the pattern. + * The none and space enums may not appear in the first field and space + * may not appear in the final field. + * + * The parts of a money string must appear in the order indicated by + * the fields of the pattern. The symbol field indicates that the + * value of curr_symbol() may be present. The sign field indicates + * that the value of positive_sign() or negative_sign() must be + * present. The value field indicates that the absolute value of the + * money amount is present. none indicates 0 or more whitespace + * characters, except at the end, where it permits no whitespace. + * space indicates that 1 or more whitespace characters must be + * present. + * + * For example, for the US locale and pos_format() pattern + * {symbol,sign,value,none}, curr_symbol() == '$' + * positive_sign() == '+', and value 10.01, and + * options set to force the symbol, the corresponding string is + * $+10.01. + * + * @return Pattern for money values. + */ + pattern + pos_format() const + { return this->do_pos_format(); } + + pattern + neg_format() const + { return this->do_neg_format(); } + ///@} + + protected: + /// Destructor. + virtual + ~moneypunct(); + + /** + * @brief Return decimal point character. + * + * Returns a char_type to use as a decimal point. This function is a + * hook for derived classes to change the value returned. + * + * @return @a char_type representing a decimal point. + */ + virtual char_type + do_decimal_point() const + { return _M_data->_M_decimal_point; } + + /** + * @brief Return thousands separator character. + * + * Returns a char_type to use as a thousands separator. This function + * is a hook for derived classes to change the value returned. + * + * @return @a char_type representing a thousands separator. + */ + virtual char_type + do_thousands_sep() const + { return _M_data->_M_thousands_sep; } + + /** + * @brief Return grouping specification. + * + * Returns a string representing groupings for the integer part of a + * number. This function is a hook for derived classes to change the + * value returned. @see grouping() for details. + * + * @return String representing grouping specification. + */ + virtual string + do_grouping() const + { return _M_data->_M_grouping; } + + /** + * @brief Return currency symbol string. + * + * This function returns a string_type to use as a currency symbol. + * This function is a hook for derived classes to change the value + * returned. @see curr_symbol() for details. + * + * @return @a string_type representing a currency symbol. + */ + virtual string_type + do_curr_symbol() const + { return _M_data->_M_curr_symbol; } + + /** + * @brief Return positive sign string. + * + * This function returns a string_type to use as a sign for positive + * amounts. This function is a hook for derived classes to change the + * value returned. @see positive_sign() for details. + * + * @return @a string_type representing a positive sign. + */ + virtual string_type + do_positive_sign() const + { return _M_data->_M_positive_sign; } + + /** + * @brief Return negative sign string. + * + * This function returns a string_type to use as a sign for negative + * amounts. This function is a hook for derived classes to change the + * value returned. @see negative_sign() for details. + * + * @return @a string_type representing a negative sign. + */ + virtual string_type + do_negative_sign() const + { return _M_data->_M_negative_sign; } + + /** + * @brief Return number of digits in fraction. + * + * This function returns the exact number of digits that make up the + * fractional part of a money amount. This function is a hook for + * derived classes to change the value returned. @see frac_digits() + * for details. + * + * @return Number of digits in amount fraction. + */ + virtual int + do_frac_digits() const + { return _M_data->_M_frac_digits; } + + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * positive valued money amount. This function is a hook for derived + * classes to change the value returned. @see pos_format() for + * details. + * + * @return Pattern for money values. + */ + virtual pattern + do_pos_format() const + { return _M_data->_M_pos_format; } + + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * negative valued money amount. This function is a hook for derived + * classes to change the value returned. @see neg_format() for + * details. + * + * @return Pattern for money values. + */ + virtual pattern + do_neg_format() const + { return _M_data->_M_neg_format; } + + // For use at construction time only. + void + _M_initialize_moneypunct(__c_locale __cloc = 0, + const char* __name = 0); + }; + + template + locale::id moneypunct<_CharT, _Intl>::id; + + template + const bool moneypunct<_CharT, _Intl>::intl; + + template<> + moneypunct::~moneypunct(); + + template<> + moneypunct::~moneypunct(); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, const char*); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, const char*); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + moneypunct::~moneypunct(); + + template<> + moneypunct::~moneypunct(); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, + const char*); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, + const char*); +#endif + + /// class moneypunct_byname [22.2.6.4]. + template + class moneypunct_byname : public moneypunct<_CharT, _Intl> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + static const bool intl = _Intl; + + explicit + moneypunct_byname(const char* __s, size_t __refs = 0) + : moneypunct<_CharT, _Intl>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_moneypunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } + } + +#if __cplusplus >= 201103L + explicit + moneypunct_byname(const string& __s, size_t __refs = 0) + : moneypunct_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~moneypunct_byname() { } + }; + + template + const bool moneypunct_byname<_CharT, _Intl>::intl; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + + /** + * @brief Primary class template money_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a monetary + * amount from a string. + * + * The money_get template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the money_get facet. + */ + template + class money_get : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + typedef basic_string<_CharT> string_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + money_get(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Read and parse a monetary value. + * + * This function reads characters from @a __s, interprets them as a + * monetary value according to moneypunct and ctype facets retrieved + * from io.getloc(), and returns the result in @a units as an integral + * value moneypunct::frac_digits() * the actual amount. For example, + * the string $10.01 in a US locale would store 1001 in @a units. + * + * Any characters not part of a valid money amount are not consumed. + * + * If a money value cannot be parsed from the input stream, sets + * err=(err|io.failbit). If the stream is consumed before finishing + * parsing, sets err=(err|io.failbit|io.eofbit). @a units is + * unchanged if parsing fails. + * + * This function works by returning the result of do_get(). + * + * @param __s Start of characters to parse. + * @param __end End of characters to parse. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __err Error field to set if parsing fails. + * @param __units Place to store result of parsing. + * @return Iterator referencing first character beyond valid money + * amount. + */ + iter_type + get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const + { return this->do_get(__s, __end, __intl, __io, __err, __units); } + + /** + * @brief Read and parse a monetary value. + * + * This function reads characters from @a __s, interprets them as + * a monetary value according to moneypunct and ctype facets + * retrieved from io.getloc(), and returns the result in @a + * digits. For example, the string $10.01 in a US locale would + * store 1001 in @a digits. + * + * Any characters not part of a valid money amount are not consumed. + * + * If a money value cannot be parsed from the input stream, sets + * err=(err|io.failbit). If the stream is consumed before finishing + * parsing, sets err=(err|io.failbit|io.eofbit). + * + * This function works by returning the result of do_get(). + * + * @param __s Start of characters to parse. + * @param __end End of characters to parse. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __err Error field to set if parsing fails. + * @param __digits Place to store result of parsing. + * @return Iterator referencing first character beyond valid money + * amount. + */ + iter_type + get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const + { return this->do_get(__s, __end, __intl, __io, __err, __digits); } + + protected: + /// Destructor. + virtual + ~money_get() { } + + /** + * @brief Read and parse a monetary value. + * + * This function reads and parses characters representing a monetary + * value. This function is a hook for derived classes to change the + * value returned. @see get() for details. + */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const; +#else + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const; +#endif + + /** + * @brief Read and parse a monetary value. + * + * This function reads and parses characters representing a monetary + * value. This function is a hook for derived classes to change the + * value returned. @see get() for details. + */ + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, __ibm128& __units) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const; +#endif + + template + iter_type + _M_extract(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, string& __digits) const; + }; + + template + locale::id money_get<_CharT, _InIter>::id; + + /** + * @brief Primary class template money_put. + * @ingroup locales + * + * This facet encapsulates the code to format and output a monetary + * amount. + * + * The money_put template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the money_put facet. + */ + template + class money_put : public locale::facet + { + public: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + typedef basic_string<_CharT> string_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + money_put(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a units as a monetary value according to + * moneypunct and ctype facets retrieved from io.getloc(), and writes + * the resulting characters to @a __s. For example, the value 1001 in a + * US locale would write $10.01 to @a __s. + * + * This function works by returning the result of do_put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __units Place to store result of parsing. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, bool __intl, ios_base& __io, + char_type __fill, long double __units) const + { return this->do_put(__s, __intl, __io, __fill, __units); } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a digits as a monetary value + * according to moneypunct and ctype facets retrieved from + * io.getloc(), and writes the resulting characters to @a __s. + * For example, the string 1001 in a US locale + * would write $10.01 to @a __s. + * + * This function works by returning the result of do_put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __digits Place to store result of parsing. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, bool __intl, ios_base& __io, + char_type __fill, const string_type& __digits) const + { return this->do_put(__s, __intl, __io, __fill, __digits); } + + protected: + /// Destructor. + virtual + ~money_put() { } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a units as a monetary value according to + * moneypunct and ctype facets retrieved from io.getloc(), and writes + * the resulting characters to @a __s. For example, the value 1001 in a + * US locale would write $10.01 to @a __s. + * + * This function is a hook for derived classes to change the value + * returned. @see put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __units Place to store result of parsing. + * @return Iterator after writing. + */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const; +#else + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const; +#endif + + /** + * @brief Format and output a monetary value. + * + * This function formats @a digits as a monetary value + * according to moneypunct and ctype facets retrieved from + * io.getloc(), and writes the resulting characters to @a __s. + * For example, the string 1001 in a US locale + * would write $10.01 to @a __s. + * + * This function is a hook for derived classes to change the value + * returned. @see put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __digits Place to store result of parsing. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + const string_type& __digits) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + __ibm128 __units) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const; +#endif + + template + iter_type + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const; + }; + + template + locale::id money_put<_CharT, _OutIter>::id; + +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 + + /** + * @brief Messages facet base class providing catalog typedef. + * @ingroup locales + */ + struct messages_base + { + typedef int catalog; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template messages. + * @ingroup locales + * + * This facet encapsulates the code to retrieve messages from + * message catalogs. The only thing defined by the standard for this facet + * is the interface. All underlying functionality is + * implementation-defined. + * + * This library currently implements 3 versions of the message facet. The + * first version (gnu) is a wrapper around gettext, provided by libintl. + * The second version (ieee) is a wrapper around catgets. The final + * version (default) does no actual translation. These implementations are + * only provided for char and wchar_t instantiations. + * + * The messages template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the messages facet. + */ + template + class messages : public locale::facet, public messages_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + protected: + // Underlying "C" library locale information saved from + // initialization, needed by messages_byname as well. + __c_locale _M_c_locale_messages; + const char* _M_name_messages; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + messages(size_t __refs = 0); + + // Non-standard. + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param __refs Refcount to pass to the base class. + */ + explicit + messages(__c_locale __cloc, const char* __s, size_t __refs = 0); + + /* + * @brief Open a message catalog. + * + * This function opens and returns a handle to a message catalog by + * returning do_open(__s, __loc). + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @return Handle to the catalog or value < 0 if open fails. + */ + catalog + open(const basic_string& __s, const locale& __loc) const + { return this->do_open(__s, __loc); } + + // Non-standard and unorthodox, yet effective. + /* + * @brief Open a message catalog. + * + * This non-standard function opens and returns a handle to a message + * catalog by returning do_open(s, loc). The third argument provides a + * message catalog root directory for gnu gettext and is ignored + * otherwise. + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @param __dir Message catalog root directory. + * @return Handle to the catalog or value < 0 if open fails. + */ + catalog + open(const basic_string&, const locale&, const char*) const; + + /* + * @brief Look up a string in a message catalog. + * + * This function retrieves and returns a message from a catalog by + * returning do_get(c, set, msgid, s). + * + * For gnu, @a __set and @a msgid are ignored. Returns gettext(s). + * For default, returns s. For ieee, returns catgets(c,set,msgid,s). + * + * @param __c The catalog to access. + * @param __set Implementation-defined. + * @param __msgid Implementation-defined. + * @param __s Default return value if retrieval fails. + * @return Retrieved message or @a __s if get fails. + */ + string_type + get(catalog __c, int __set, int __msgid, const string_type& __s) const + { return this->do_get(__c, __set, __msgid, __s); } + + /* + * @brief Close a message catalog. + * + * Closes catalog @a c by calling do_close(c). + * + * @param __c The catalog to close. + */ + void + close(catalog __c) const + { return this->do_close(__c); } + + protected: + /// Destructor. + virtual + ~messages(); + + /* + * @brief Open a message catalog. + * + * This function opens and returns a handle to a message catalog in an + * implementation-defined manner. This function is a hook for derived + * classes to change the value returned. + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @return Handle to the opened catalog, value < 0 if open failed. + */ + virtual catalog + do_open(const basic_string&, const locale&) const; + + /* + * @brief Look up a string in a message catalog. + * + * This function retrieves and returns a message from a catalog in an + * implementation-defined manner. This function is a hook for derived + * classes to change the value returned. + * + * For gnu, @a __set and @a __msgid are ignored. Returns gettext(s). + * For default, returns s. For ieee, returns catgets(c,set,msgid,s). + * + * @param __c The catalog to access. + * @param __set Implementation-defined. + * @param __msgid Implementation-defined. + * @param __s Default return value if retrieval fails. + * @return Retrieved message or @a __s if get fails. + */ + virtual string_type + do_get(catalog, int, int, const string_type& __dfault) const; + + /* + * @brief Close a message catalog. + * + * @param __c The catalog to close. + */ + virtual void + do_close(catalog) const; + + // Returns a locale and codeset-converted string, given a char* message. + char* + _M_convert_to_char(const string_type& __msg) const + { + // XXX + return reinterpret_cast(const_cast<_CharT*>(__msg.c_str())); + } + + // Returns a locale and codeset-converted string, given a char* message. + string_type + _M_convert_from_char(char*) const + { + // XXX + return string_type(); + } + }; + + template + locale::id messages<_CharT>::id; + + /// Specializations for required instantiations. + template<> + string + messages::do_get(catalog, int, int, const string&) const; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + wstring + messages::do_get(catalog, int, int, const wstring&) const; +#endif + + /// class messages_byname [22.2.7.2]. + template + class messages_byname : public messages<_CharT> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + explicit + messages_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + messages_byname(const string& __s, size_t __refs = 0) + : messages_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~messages_byname() + { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// Include host and configuration specific messages functions. +#include + +// 22.2.1.5 Template class codecvt +#include + +#include + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1454d330a9bede855b4764c5112eb29eb2ac7bad Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc new file mode 100644 index 0000000000000000000000000000000000000000..17a2c8d4486e8fe295d72d613dd3979d471afca5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc @@ -0,0 +1,1834 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets_nonio.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_FACETS_NONIO_TCC +#define _LOCALE_FACETS_NONIO_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct __use_cache<__moneypunct_cache<_CharT, _Intl> > + { + const __moneypunct_cache<_CharT, _Intl>* + operator() (const locale& __loc) const + { + const size_t __i = moneypunct<_CharT, _Intl>::id._M_id(); + const locale::facet** __caches = __loc._M_impl->_M_caches; + if (!__caches[__i]) + { + __moneypunct_cache<_CharT, _Intl>* __tmp = 0; + __try + { + __tmp = new __moneypunct_cache<_CharT, _Intl>; + __tmp->_M_cache(__loc); + } + __catch(...) + { + delete __tmp; + __throw_exception_again; + } + __loc._M_impl->_M_install_cache(__tmp, __i); + } + return static_cast< + const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]); + } + }; + + template + void + __moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc) + { + const moneypunct<_CharT, _Intl>& __mp = + use_facet >(__loc); + + struct _Scoped_str + { + size_t _M_len; + _CharT* _M_str; + + explicit + _Scoped_str(const basic_string<_CharT>& __str) + : _M_len(__str.size()), _M_str(new _CharT[_M_len]) + { __str.copy(_M_str, _M_len); } + + ~_Scoped_str() { delete[] _M_str; } + + void + _M_release(const _CharT*& __p, size_t& __n) + { + __p = _M_str; + __n = _M_len; + _M_str = 0; + } + }; + + _Scoped_str __curr_symbol(__mp.curr_symbol()); + _Scoped_str __positive_sign(__mp.positive_sign()); + _Scoped_str __negative_sign(__mp.negative_sign()); + + const string& __g = __mp.grouping(); + const size_t __g_size = __g.size(); + char* const __grouping = new char[__g_size]; + __g.copy(__grouping, __g_size); + + // All allocations succeeded without throwing, OK to modify *this now. + + _M_grouping = __grouping; + _M_grouping_size = __g_size; + _M_use_grouping = (__g_size + && static_cast(__grouping[0]) > 0 + && (__grouping[0] + != __gnu_cxx::__numeric_traits::__max)); + + _M_decimal_point = __mp.decimal_point(); + _M_thousands_sep = __mp.thousands_sep(); + + __curr_symbol._M_release(_M_curr_symbol, _M_curr_symbol_size); + __positive_sign._M_release(_M_positive_sign, _M_positive_sign_size); + __negative_sign._M_release(_M_negative_sign, _M_negative_sign_size); + + _M_frac_digits = __mp.frac_digits(); + _M_pos_format = __mp.pos_format(); + _M_neg_format = __mp.neg_format(); + + const ctype<_CharT>& __ct = use_facet >(__loc); + __ct.widen(money_base::_S_atoms, + money_base::_S_atoms + money_base::_S_end, _M_atoms); + + _M_allocated = true; + } + +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + + template + template + _InIter + money_get<_CharT, _InIter>:: + _M_extract(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, string& __units) const + { + typedef char_traits<_CharT> __traits_type; + typedef typename string_type::size_type size_type; + typedef money_base::part part; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + __use_cache<__cache_type> __uc; + const __cache_type* __lc = __uc(__loc); + const char_type* __lit = __lc->_M_atoms; + + // Deduced sign. + bool __negative = false; + // Sign size. + size_type __sign_size = 0; + // True if sign is mandatory. + const bool __mandatory_sign = (__lc->_M_positive_sign_size + && __lc->_M_negative_sign_size); + // String of grouping info from thousands_sep plucked from __units. + string __grouping_tmp; + if (__lc->_M_use_grouping) + __grouping_tmp.reserve(32); + // Last position before the decimal point. + int __last_pos = 0; + // Separator positions, then, possibly, fractional digits. + int __n = 0; + // If input iterator is in a valid state. + bool __testvalid = true; + // Flag marking when a decimal point is found. + bool __testdecfound = false; + + // The tentative returned string is stored here. + string __res; + __res.reserve(32); + + const char_type* __lit_zero = __lit + money_base::_S_zero; + const money_base::pattern __p = __lc->_M_neg_format; + for (int __i = 0; __i < 4 && __testvalid; ++__i) + { + const part __which = static_cast(__p.field[__i]); + switch (__which) + { + case money_base::symbol: + // According to 22.2.6.1.2, p2, symbol is required + // if (__io.flags() & ios_base::showbase), otherwise + // is optional and consumed only if other characters + // are needed to complete the format. + if (__io.flags() & ios_base::showbase || __sign_size > 1 + || __i == 0 + || (__i == 1 && (__mandatory_sign + || (static_cast(__p.field[0]) + == money_base::sign) + || (static_cast(__p.field[2]) + == money_base::space))) + || (__i == 2 && ((static_cast(__p.field[3]) + == money_base::value) + || (__mandatory_sign + && (static_cast(__p.field[3]) + == money_base::sign))))) + { + const size_type __len = __lc->_M_curr_symbol_size; + size_type __j = 0; + for (; __beg != __end && __j < __len + && *__beg == __lc->_M_curr_symbol[__j]; + ++__beg, (void)++__j); + if (__j != __len + && (__j || __io.flags() & ios_base::showbase)) + __testvalid = false; + } + break; + case money_base::sign: + // Sign might not exist, or be more than one character long. + if (__lc->_M_positive_sign_size && __beg != __end + && *__beg == __lc->_M_positive_sign[0]) + { + __sign_size = __lc->_M_positive_sign_size; + ++__beg; + } + else if (__lc->_M_negative_sign_size && __beg != __end + && *__beg == __lc->_M_negative_sign[0]) + { + __negative = true; + __sign_size = __lc->_M_negative_sign_size; + ++__beg; + } + else if (__lc->_M_positive_sign_size + && !__lc->_M_negative_sign_size) + // "... if no sign is detected, the result is given the sign + // that corresponds to the source of the empty string" + __negative = true; + else if (__mandatory_sign) + __testvalid = false; + break; + case money_base::value: + // Extract digits, remove and stash away the + // grouping of found thousands separators. + for (; __beg != __end; ++__beg) + { + const char_type __c = *__beg; + const char_type* __q = __traits_type::find(__lit_zero, + 10, __c); + if (__q != 0) + { + __res += money_base::_S_atoms[__q - __lit]; + ++__n; + } + else if (__c == __lc->_M_decimal_point + && !__testdecfound) + { + if (__lc->_M_frac_digits <= 0) + break; + + __last_pos = __n; + __n = 0; + __testdecfound = true; + } + else if (__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep + && !__testdecfound) + { + if (__n) + { + // Mark position for later analysis. + __grouping_tmp += static_cast(__n); + __n = 0; + } + else + { + __testvalid = false; + break; + } + } + else + break; + } + if (__res.empty()) + __testvalid = false; + break; + case money_base::space: + // At least one space is required. + if (__beg != __end && __ctype.is(ctype_base::space, *__beg)) + ++__beg; + else + __testvalid = false; + // fallthrough + case money_base::none: + // Only if not at the end of the pattern. + if (__i != 3) + for (; __beg != __end + && __ctype.is(ctype_base::space, *__beg); ++__beg); + break; + } + } + + // Need to get the rest of the sign characters, if they exist. + if (__sign_size > 1 && __testvalid) + { + const char_type* __sign = __negative ? __lc->_M_negative_sign + : __lc->_M_positive_sign; + size_type __i = 1; + for (; __beg != __end && __i < __sign_size + && *__beg == __sign[__i]; ++__beg, (void)++__i); + + if (__i != __sign_size) + __testvalid = false; + } + + if (__testvalid) + { + // Strip leading zeros. + if (__res.size() > 1) + { + const size_type __first = __res.find_first_not_of('0'); + const bool __only_zeros = __first == string::npos; + if (__first) + __res.erase(0, __only_zeros ? __res.size() - 1 : __first); + } + + // 22.2.6.1.2, p4 + if (__negative && __res[0] != '0') + __res.insert(__res.begin(), '-'); + + // Test for grouping fidelity. + if (__grouping_tmp.size()) + { + // Add the ending grouping. + __grouping_tmp += static_cast(__testdecfound ? __last_pos + : __n); + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __grouping_tmp)) + __err |= ios_base::failbit; + } + + // Iff not enough digits were supplied after the decimal-point. + if (__testdecfound && __n != __lc->_M_frac_digits) + __testvalid = false; + } + + // Iff valid sequence is not recognized. + if (!__testvalid) + __err |= ios_base::failbit; + else + __units.swap(__res); + + // Iff no more characters are available. + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + template + _InIter + money_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } +#endif + + template + _InIter + money_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } + + template + _InIter + money_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const + { + typedef typename string::size_type size_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + const size_type __len = __str.size(); + if (__len) + { + __digits.resize(__len); + __ctype.widen(__str.data(), __str.data() + __len, &__digits[0]); + } + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _InIter + money_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, __ibm128& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } +#endif + + template + template + _OutIter + money_put<_CharT, _OutIter>:: + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const + { + typedef typename string_type::size_type size_type; + typedef money_base::part part; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + __use_cache<__cache_type> __uc; + const __cache_type* __lc = __uc(__loc); + const char_type* __lit = __lc->_M_atoms; + + // Determine if negative or positive formats are to be used, and + // discard leading negative_sign if it is present. + const char_type* __beg = __digits.data(); + + money_base::pattern __p; + const char_type* __sign; + size_type __sign_size; + if (!(*__beg == __lit[money_base::_S_minus])) + { + __p = __lc->_M_pos_format; + __sign = __lc->_M_positive_sign; + __sign_size = __lc->_M_positive_sign_size; + } + else + { + __p = __lc->_M_neg_format; + __sign = __lc->_M_negative_sign; + __sign_size = __lc->_M_negative_sign_size; + if (__digits.size()) + ++__beg; + } + + // Look for valid numbers in the ctype facet within input digits. + size_type __len = __ctype.scan_not(ctype_base::digit, __beg, + __beg + __digits.size()) - __beg; + if (__len) + { + // Assume valid input, and attempt to format. + // Break down input numbers into base components, as follows: + // final_value = grouped units + (decimal point) + (digits) + string_type __value; + __value.reserve(2 * __len); + + // Add thousands separators to non-decimal digits, per + // grouping rules. + long __paddec = __len - __lc->_M_frac_digits; + if (__paddec > 0) + { + if (__lc->_M_frac_digits < 0) + __paddec = __len; + if (__lc->_M_grouping_size) + { + __value.assign(2 * __paddec, char_type()); + _CharT* __vend = + std::__add_grouping(&__value[0], __lc->_M_thousands_sep, + __lc->_M_grouping, + __lc->_M_grouping_size, + __beg, __beg + __paddec); + __value.erase(__vend - &__value[0]); + } + else + __value.assign(__beg, __paddec); + } + + // Deal with decimal point, decimal digits. + if (__lc->_M_frac_digits > 0) + { + __value += __lc->_M_decimal_point; + if (__paddec >= 0) + __value.append(__beg + __paddec, __lc->_M_frac_digits); + else + { + // Have to pad zeros in the decimal position. + __value.append(-__paddec, __lit[money_base::_S_zero]); + __value.append(__beg, __len); + } + } + + // Calculate length of resulting string. + const ios_base::fmtflags __f = __io.flags() + & ios_base::adjustfield; + __len = __value.size() + __sign_size; + __len += ((__io.flags() & ios_base::showbase) + ? __lc->_M_curr_symbol_size : 0); + + string_type __res; + __res.reserve(2 * __len); + + const size_type __width = static_cast(__io.width()); + const bool __testipad = (__f == ios_base::internal + && __len < __width); + // Fit formatted digits into the required pattern. + for (int __i = 0; __i < 4; ++__i) + { + const part __which = static_cast(__p.field[__i]); + switch (__which) + { + case money_base::symbol: + if (__io.flags() & ios_base::showbase) + __res.append(__lc->_M_curr_symbol, + __lc->_M_curr_symbol_size); + break; + case money_base::sign: + // Sign might not exist, or be more than one + // character long. In that case, add in the rest + // below. + if (__sign_size) + __res += __sign[0]; + break; + case money_base::value: + __res += __value; + break; + case money_base::space: + // At least one space is required, but if internal + // formatting is required, an arbitrary number of + // fill spaces will be necessary. + if (__testipad) + __res.append(__width - __len, __fill); + else + __res += __fill; + break; + case money_base::none: + if (__testipad) + __res.append(__width - __len, __fill); + break; + } + } + + // Special case of multi-part sign parts. + if (__sign_size > 1) + __res.append(__sign + 1, __sign_size - 1); + + // Pad, if still necessary. + __len = __res.size(); + if (__width > __len) + { + if (__f == ios_base::left) + // After. + __res.append(__width - __len, __fill); + else + // Before. + __res.insert(0, __width - __len, __fill); + __len = __width; + } + + // Write resulting, fully-formatted string to output iterator. + __s = std::__write(__s, __res.data(), __len); + } + __io.width(0); + return __s; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + template + _OutIter + money_put<_CharT, _OutIter>:: + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const + { return this->do_put(__s, __intl, __io, __fill, (long double) __units); } +#endif + + template + _OutIter + money_put<_CharT, _OutIter>:: + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const + { + const locale __loc = __io.getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); +#if _GLIBCXX_USE_C99_STDIO + // First try a buffer perhaps big enough. + int __cs_size = 64; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 328. Bad sprintf format modifier in money_put<>::do_put() + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + } +#else + // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. + const int __cs_size = + __gnu_cxx::__numeric_traits::__max_exponent10 + 3; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", + 0, __units); +#endif + string_type __digits(__len, char_type()); + __ctype.widen(__cs, __cs + __len, &__digits[0]); + return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); + } + + template + _OutIter + money_put<_CharT, _OutIter>:: + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + const string_type& __digits) const + { return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ +extern "C" +__typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__("snprintf"); + + template + _OutIter + money_put<_CharT, _OutIter>:: + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + __ibm128 __units) const + { + const locale __loc = __io.getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + // First try a buffer perhaps big enough. + int __cs_size = 64; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + const __c_locale __old = __gnu_cxx::__uselocale(_S_get_c_locale()); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 328. Bad sprintf format modifier in money_put<>::do_put() + int __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0, + __units); + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0, + __units); + } + __gnu_cxx::__uselocale(__old); + string_type __digits(__len, char_type()); + __ctype.widen(__cs, __cs + __len, &__digits[0]); + return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); + } +#endif + +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 + + // NB: Not especially useful. Without an ios_base object or some + // kind of locale reference, we are left clawing at the air where + // the side of the mountain used to be... + template + time_base::dateorder + time_get<_CharT, _InIter>::do_date_order() const + { return time_base::no_order; } + + // Expand a strptime format string and parse it. E.g., do_get_date() may + // pass %m/%d/%Y => extracted characters. + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format, + __time_get_state &__state) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const ctype<_CharT>& __ctype = use_facet >(__loc); + const size_t __len = char_traits<_CharT>::length(__format); + + ios_base::iostate __tmperr = ios_base::goodbit; + size_t __i = 0; + for (; __beg != __end && __i < __len && !__tmperr; ++__i) + { + if (__ctype.narrow(__format[__i], 0) == '%') + { + // Verify valid formatting code, attempt to extract. + char __c = __ctype.narrow(__format[++__i], 0); + int __mem = 0; + if (__c == 'E' || __c == 'O') + __c = __ctype.narrow(__format[++__i], 0); + switch (__c) + { + const char* __cs; + _CharT __wcs[10]; + case 'a': + case 'A': + // Weekday name (possibly abbreviated) [tm_wday] + const char_type* __days[14]; + __tp._M_days(&__days[0]); + __tp._M_days_abbreviated(&__days[7]); + __beg = _M_extract_name(__beg, __end, __mem, __days, + 14, __io, __tmperr); + if (!__tmperr) + { + __tm->tm_wday = __mem % 7; + __state._M_have_wday = 1; + } + break; + case 'h': + case 'b': + case 'B': + // Month name (possibly abbreviated) [tm_mon] + const char_type* __months[24]; + __tp._M_months(&__months[0]); + __tp._M_months_abbreviated(&__months[12]); + __beg = _M_extract_name(__beg, __end, __mem, + __months, 24, __io, __tmperr); + if (!__tmperr) + { + __tm->tm_mon = __mem % 12; + __state._M_have_mon = 1; + __state._M_want_xday = 1; + } + break; + case 'c': + // Default time and date representation. + const char_type* __dt[2]; + __tp._M_date_time_formats(__dt); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __dt[0], __state); + if (!__tmperr) + __state._M_want_xday = 1; + break; + case 'C': + // Century. + __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2, + __io, __tmperr); + if (!__tmperr) + { + __state._M_century = __mem; + __state._M_have_century = 1; + __state._M_want_xday = 1; + } + break; + case 'd': + case 'e': + // Day [1, 31]. [tm_mday] + if (__ctype.is(ctype_base::space, *__beg)) + ++__beg; + __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_mday = __mem; + __state._M_have_mday = 1; + __state._M_want_xday = 1; + } + break; + case 'D': + // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year] + __cs = "%m/%d/%y"; + __ctype.widen(__cs, __cs + 9, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs, __state); + if (!__tmperr) + __state._M_want_xday = 1; + break; + case 'H': + // Hour [00, 23]. [tm_hour] + __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_hour = __mem; + __state._M_have_I = 0; + } + break; + case 'I': + // Hour [01, 12]. [tm_hour] + __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_hour = __mem % 12; + __state._M_have_I = 1; + } + break; + case 'j': + // Day number of year. + __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_yday = __mem - 1; + __state._M_have_yday = 1; + } + break; + case 'm': + // Month [01, 12]. [tm_mon] + __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_mon = __mem - 1; + __state._M_have_mon = 1; + } + break; + case 'M': + // Minute [00, 59]. [tm_min] + __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_min = __mem; + break; + case 'n': + case 't': + while (__beg != __end + && __ctype.is(ctype_base::space, *__beg)) + ++__beg; + break; + case 'p': + // Locale's a.m. or p.m. + const char_type* __ampm[2]; + __tp._M_am_pm(&__ampm[0]); + if (!__ampm[0][0] || !__ampm[1][0]) + break; + __beg = _M_extract_name(__beg, __end, __mem, __ampm, + 2, __io, __tmperr); + if (!__tmperr && __mem) + __state._M_is_pm = 1; + break; + case 'r': + // Locale's 12-hour clock time format (in C %I:%M:%S %p). + const char_type* __ampm_format; + __tp._M_am_pm_format(&__ampm_format); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __ampm_format, __state); + break; + case 'R': + // Equivalent to (%H:%M). + __cs = "%H:%M"; + __ctype.widen(__cs, __cs + 6, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs, __state); + break; + case 'S': + // Seconds. [tm_sec] + // [00, 60] in C99 (one leap-second), [00, 61] in C89. +#if _GLIBCXX_USE_C99 + __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2, +#else + __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2, +#endif + __io, __tmperr); + if (!__tmperr) + __tm->tm_sec = __mem; + break; + case 'T': + // Equivalent to (%H:%M:%S). + __cs = "%H:%M:%S"; + __ctype.widen(__cs, __cs + 9, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs, __state); + break; + case 'U': + // Week number of the year (Sunday as first day of week). + __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2, + __io, __tmperr); + if (!__tmperr) + { + __state._M_week_no = __mem; + __state._M_have_uweek = 1; + } + break; + case 'w': + // Weekday [tm_wday] + __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_wday = __mem; + __state._M_have_wday = 1; + } + break; + case 'W': + // Week number of the year (Monday as first day of week). + __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2, + __io, __tmperr); + if (!__tmperr) + { + __state._M_week_no = __mem; + __state._M_have_wweek = 1; + } + break; + case 'x': + // Locale's date. + const char_type* __dates[2]; + __tp._M_date_formats(__dates); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __dates[0], __state); + break; + case 'X': + // Locale's time. + const char_type* __times[2]; + __tp._M_time_formats(__times); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __times[0], __state); + break; + case 'y': + // The last 2 digits of year. + __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2, + __io, __tmperr); + if (!__tmperr) + { + __state._M_want_century = 1; + __state._M_want_xday = 1; + // As an extension, if the 2 digits are followed by + // 1-2 further digits, treat it like %Y. + __c = 0; + if (__beg != __end) + __c = __ctype.narrow(*__beg, '*'); + if (__c >= '0' && __c <= '9') + { + ++__beg; + __mem = __mem * 10 + (__c - '0'); + if (__beg != __end) + { + __c = __ctype.narrow(*__beg, '*'); + if (__c >= '0' && __c <= '9') + { + ++__beg; + __mem = __mem * 10 + (__c - '0'); + } + } + __mem -= 1900; + __state._M_want_century = 0; + } + // Otherwise, as per POSIX 2008, 00-68 is 2000-2068, + // while 69-99 is 1969-1999. + else if (__mem < 69) + __mem += 100; + __tm->tm_year = __mem; + } + break; + case 'Y': + // Year. + __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4, + __io, __tmperr); + if (!__tmperr) + { + __tm->tm_year = __mem - 1900; + __state._M_want_century = 0; + __state._M_want_xday = 1; + } + break; + case 'Z': + // Timezone info. + if (__ctype.is(ctype_base::upper, *__beg)) + { + int __tmp; + __beg = _M_extract_name(__beg, __end, __tmp, + __timepunct_cache<_CharT>::_S_timezones, + 14, __io, __tmperr); + + // GMT requires special effort. + if (__beg != __end && !__tmperr && __tmp == 0 + && (*__beg == __ctype.widen('-') + || *__beg == __ctype.widen('+'))) + { + __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2, + __io, __tmperr); + __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2, + __io, __tmperr); + } + } + else + __tmperr |= ios_base::failbit; + break; + case '%': + if (*__beg == __ctype.widen('%')) + ++__beg; + else + __tmperr |= ios_base::failbit; + break; + default: + // Not recognized. + __tmperr |= ios_base::failbit; + } + } + else if (__ctype.is(ctype_base::space, __format[__i])) + { + // Skip any whitespace. + while (__beg != __end + && __ctype.is(ctype_base::space, *__beg)) + ++__beg; + } + else + { + // Verify format and input match, extract and discard. + // TODO real case-insensitive comparison + if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg) + || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg)) + ++__beg; + else + __tmperr |= ios_base::failbit; + } + } + + if (__tmperr || __i != __len) + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format) const + { + __time_get_state __state = __time_get_state(); + return _M_extract_via_format(__beg, __end, __io, __err, __tm, + __format, __state); + } + + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_num(iter_type __beg, iter_type __end, int& __member, + int __min, int __max, size_t __len, + ios_base& __io, ios_base::iostate& __err) const + { + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + size_t __i = 0; + int __value = 0; + for (; __beg != __end && __i < __len; ++__beg, (void)++__i) + { + const char __c = __ctype.narrow(*__beg, '*'); + if (__c >= '0' && __c <= '9') + { + __value = __value * 10 + (__c - '0'); + if (__value > __max) + break; + } + else + break; + } + if (__i && __value >= __min && __value <= __max) + __member = __value; + else + __err |= ios_base::failbit; + + return __beg; + } + + // Assumptions: + // All elements in __names are unique, except if __indexlen is + // even __names in the first half could be the same as corresponding + // __names in the second half (May is abbreviated as May). Some __names + // elements could be prefixes of other __names elements. + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_name(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const + { + typedef char_traits<_CharT> __traits_type; + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + size_t* __matches + = static_cast(__builtin_alloca(2 * sizeof(size_t) + * __indexlen)); + size_t* __lengths = __matches + __indexlen; + size_t __nmatches = 0; + size_t __pos = 0; + bool __testvalid = true; + const char_type* __name; + bool __begupdated = false; + + // Look for initial matches. + if (__beg != __end) + { + const char_type __c = *__beg; + // TODO real case-insensitive comparison + const char_type __cl = __ctype.tolower(__c); + const char_type __cu = __ctype.toupper(__c); + for (size_t __i1 = 0; __i1 < __indexlen; ++__i1) + if (__cl == __ctype.tolower(__names[__i1][0]) + || __cu == __ctype.toupper(__names[__i1][0])) + { + __lengths[__nmatches] + = __traits_type::length(__names[__i1]); + __matches[__nmatches++] = __i1; + } + } + + while (__nmatches > 1) + { + // Find smallest matching string. + size_t __minlen = __lengths[0]; + for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) + __minlen = std::min(__minlen, __lengths[__i2]); + ++__pos; + ++__beg; + if (__pos == __minlen) + { + // If some match has remaining length of 0, + // need to decide if any match with remaining + // length non-zero matches the next character. + // If so, remove all matches with remaining length + // 0 from consideration, otherwise keep only matches + // with remaining length 0. + bool __match_longer = false; + + if (__beg != __end) + { + // TODO real case-insensitive comparison + const char_type __cl = __ctype.tolower(*__beg); + const char_type __cu = __ctype.toupper(*__beg); + for (size_t __i3 = 0; __i3 < __nmatches; ++__i3) + { + __name = __names[__matches[__i3]]; + if (__lengths[__i3] > __pos + && (__ctype.tolower(__name[__pos]) == __cl + || __ctype.toupper(__name[__pos]) == __cu)) + { + __match_longer = true; + break; + } + } + } + for (size_t __i4 = 0; __i4 < __nmatches;) + if (__match_longer == (__lengths[__i4] == __pos)) + { + __matches[__i4] = __matches[--__nmatches]; + __lengths[__i4] = __lengths[__nmatches]; + } + else + ++__i4; + if (__match_longer) + { + __minlen = __lengths[0]; + for (size_t __i5 = 1; __i5 < __nmatches; ++__i5) + __minlen = std::min(__minlen, __lengths[__i5]); + } + else + { + // Deal with May being full as well as abbreviated month + // name. Pick the smaller index. + if (__nmatches == 2 && (__indexlen & 1) == 0) + { + if (__matches[0] < __indexlen / 2) + { + if (__matches[1] == __matches[0] + __indexlen / 2) + __nmatches = 1; + } + else if (__matches[1] == __matches[0] - __indexlen / 2) + { + __matches[0] = __matches[1]; + __lengths[0] = __lengths[1]; + __nmatches = 1; + } + } + __begupdated = true; + break; + } + } + if (__pos < __minlen && __beg != __end) + { + // TODO real case-insensitive comparison + const char_type __cl = __ctype.tolower(*__beg); + const char_type __cu = __ctype.toupper(*__beg); + for (size_t __i6 = 0; __i6 < __nmatches;) + { + __name = __names[__matches[__i6]]; + if (__ctype.tolower(__name[__pos]) != __cl + && __ctype.toupper(__name[__pos]) != __cu) + { + __matches[__i6] = __matches[--__nmatches]; + __lengths[__i6] = __lengths[__nmatches]; + } + else + ++__i6; + } + } + else + break; + } + + if (__nmatches == 1) + { + // Make sure found name is completely extracted. + if (!__begupdated) + { + ++__beg; + ++__pos; + } + __name = __names[__matches[0]]; + const size_t __len = __lengths[0]; + while (__pos < __len + && __beg != __end + // TODO real case-insensitive comparison + && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg) + || (__ctype.toupper(__name[__pos]) + == __ctype.toupper(*__beg)))) + ++__beg, (void)++__pos; + + if (__len == __pos) + __member = __matches[0]; + else + __testvalid = false; + } + else + __testvalid = false; + if (!__testvalid) + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const + { + typedef char_traits<_CharT> __traits_type; + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + int* __matches = static_cast(__builtin_alloca(2 * sizeof(int) + * __indexlen)); + size_t __nmatches = 0; + size_t* __matches_lengths = 0; + size_t __pos = 0; + + if (__beg != __end) + { + const char_type __c = *__beg; + for (size_t __i = 0; __i < 2 * __indexlen; ++__i) + if (__c == __names[__i][0] + || __c == __ctype.toupper(__names[__i][0])) + __matches[__nmatches++] = __i; + } + + if (__nmatches) + { + ++__beg; + ++__pos; + + __matches_lengths + = static_cast(__builtin_alloca(sizeof(size_t) + * __nmatches)); + for (size_t __i = 0; __i < __nmatches; ++__i) + __matches_lengths[__i] + = __traits_type::length(__names[__matches[__i]]); + } + + for (; __beg != __end; ++__beg, (void)++__pos) + { + size_t __nskipped = 0; + const char_type __c = *__beg; + for (size_t __i = 0; __i < __nmatches;) + { + const char_type* __name = __names[__matches[__i]]; + if (__pos >= __matches_lengths[__i]) + ++__nskipped, ++__i; + else if (!(__name[__pos] == __c)) + { + --__nmatches; + __matches[__i] = __matches[__nmatches]; + __matches_lengths[__i] = __matches_lengths[__nmatches]; + } + else + ++__i; + } + if (__nskipped == __nmatches) + break; + } + + if ((__nmatches == 1 && __matches_lengths[0] == __pos) + || (__nmatches == 2 && (__matches_lengths[0] == __pos + || __matches_lengths[1] == __pos))) + __member = (__matches[0] >= (int)__indexlen + ? __matches[0] - (int)__indexlen : __matches[0]); + else + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __times[2]; + __tp._M_time_formats(__times); + __time_get_state __state = __time_get_state(); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __times[0], __state); + __state._M_finalize_state(__tm); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __dates[2]; + __tp._M_date_formats(__dates); + __time_get_state __state = __time_get_state(); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __dates[0], __state); + __state._M_finalize_state(__tm); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __days[14]; + __tp._M_days_abbreviated(__days); + __tp._M_days(__days + 7); + int __tmpwday; + ios_base::iostate __tmperr = ios_base::goodbit; + + __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7, + __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __tmpwday; + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_monthname(iter_type __beg, iter_type __end, + ios_base& __io, ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __months[24]; + __tp._M_months_abbreviated(__months); + __tp._M_months(__months + 12); + int __tmpmon; + ios_base::iostate __tmperr = ios_base::goodbit; + + __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12, + __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __tmpmon; + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + int __tmpyear; + ios_base::iostate __tmperr = ios_base::goodbit; + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2, + __io, __tmperr); + if (!__tmperr) + { + char __c = 0; + if (__beg != __end) + __c = __ctype.narrow(*__beg, '*'); + // For 1-2 digit year, assume 69-99 is 1969-1999, 0-68 is 2000-2068. + // For 3-4 digit year, use it as year. + // __tm->tm_year needs year - 1900 though. + if (__c >= '0' && __c <= '9') + { + ++__beg; + __tmpyear = __tmpyear * 10 + (__c - '0'); + if (__beg != __end) + { + __c = __ctype.narrow(*__beg, '*'); + if (__c >= '0' && __c <= '9') + { + ++__beg; + __tmpyear = __tmpyear * 10 + (__c - '0'); + } + } + __tmpyear -= 1900; + } + else if (__tmpyear < 69) + __tmpyear += 100; + __tm->tm_year = __tmpyear; + } + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if __cplusplus >= 201103L + template + inline + _InIter + time_get<_CharT, _InIter>:: + get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, const char_type* __fmt, + const char_type* __fmtend) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __err = ios_base::goodbit; + bool __use_state = false; +#if __GNUC__ >= 5 && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpmf-conversions" + // Nasty hack. The C++ standard mandates that get invokes the do_get + // virtual method, but unfortunately at least without an ABI change + // for the facets we can't keep state across the different do_get + // calls. So e.g. if __fmt is "%p %I:%M:%S", we can't handle it + // properly, because we first handle the %p am/pm specifier and only + // later the 12-hour format specifier. + if ((void*)(this->*(&time_get::do_get)) == (void*)(&time_get::do_get)) + __use_state = true; +#pragma GCC diagnostic pop +#endif + __time_get_state __state = __time_get_state(); + while (__fmt != __fmtend && + __err == ios_base::goodbit) + { + if (__s == __end) + { + __err = ios_base::eofbit | ios_base::failbit; + break; + } + else if (__ctype.narrow(*__fmt, 0) == '%') + { + const char_type* __fmt_start = __fmt; + char __format; + char __mod = 0; + if (++__fmt == __fmtend) + { + __err = ios_base::failbit; + break; + } + const char __c = __ctype.narrow(*__fmt, 0); + if (__c != 'E' && __c != 'O') + __format = __c; + else if (++__fmt != __fmtend) + { + __mod = __c; + __format = __ctype.narrow(*__fmt, 0); + } + else + { + __err = ios_base::failbit; + break; + } + if (__use_state) + { + char_type __new_fmt[4]; + __new_fmt[0] = __fmt_start[0]; + __new_fmt[1] = __fmt_start[1]; + if (__mod) + { + __new_fmt[2] = __fmt_start[2]; + __new_fmt[3] = char_type(); + } + else + __new_fmt[2] = char_type(); + __s = _M_extract_via_format(__s, __end, __io, __err, __tm, + __new_fmt, __state); + if (__s == __end) + __err |= ios_base::eofbit; + } + else + __s = this->do_get(__s, __end, __io, __err, __tm, __format, + __mod); + ++__fmt; + } + else if (__ctype.is(ctype_base::space, *__fmt)) + { + ++__fmt; + while (__fmt != __fmtend && + __ctype.is(ctype_base::space, *__fmt)) + ++__fmt; + + while (__s != __end && + __ctype.is(ctype_base::space, *__s)) + ++__s; + } + // TODO real case-insensitive comparison + else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) || + __ctype.toupper(*__s) == __ctype.toupper(*__fmt)) + { + ++__s; + ++__fmt; + } + else + { + __err = ios_base::failbit; + break; + } + } + if (__use_state) + __state._M_finalize_state(__tm); + return __s; + } + + template + inline + _InIter + time_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + char __format, char __mod) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __err = ios_base::goodbit; + + char_type __fmt[4]; + __fmt[0] = __ctype.widen('%'); + if (!__mod) + { + __fmt[1] = __format; + __fmt[2] = char_type(); + } + else + { + __fmt[1] = __mod; + __fmt[2] = __format; + __fmt[3] = char_type(); + } + + __time_get_state __state = __time_get_state(); + __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt, + __state); + __state._M_finalize_state(__tm); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#endif // __cplusplus >= 201103L + + template + _OutIter + time_put<_CharT, _OutIter>:: + put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + const _CharT* __beg, const _CharT* __end) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + for (; __beg != __end; ++__beg) + if (__ctype.narrow(*__beg, 0) != '%') + { + *__s = *__beg; + ++__s; + } + else if (++__beg != __end) + { + char __format; + char __mod = 0; + const char __c = __ctype.narrow(*__beg, 0); + if (__c != 'E' && __c != 'O') + __format = __c; + else if (++__beg != __end) + { + __mod = __c; + __format = __ctype.narrow(*__beg, 0); + } + else + break; + __s = this->do_put(__s, __io, __fill, __tm, __format, __mod); + } + else + break; + return __s; + } + + template + _OutIter + time_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm, + char __format, char __mod) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); + + // NB: This size is arbitrary. Should this be a data member, + // initialized at construction? + const size_t __maxlen = 128; + char_type __res[__maxlen]; + + // NB: In IEE 1003.1-200x, and perhaps other locale models, it + // is possible that the format character will be longer than one + // character. Possibilities include 'E' or 'O' followed by a + // format character: if __mod is not the default argument, assume + // it's a valid modifier. + char_type __fmt[4]; + __fmt[0] = __ctype.widen('%'); + if (!__mod) + { + __fmt[1] = __format; + __fmt[2] = char_type(); + } + else + { + __fmt[1] = __mod; + __fmt[2] = __format; + __fmt[3] = char_type(); + } + + __tp._M_put(__res, __maxlen, __fmt, __tm); + + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __res, char_traits::length(__res)); + } + + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class moneypunct; + extern template class moneypunct; + extern template class moneypunct_byname; + extern template class moneypunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put; + extern template class __timepunct; + extern template class time_put; + extern template class time_put_byname; + extern template class time_get; + extern template class time_get_byname; + extern template class messages; + extern template class messages_byname; + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const money_put& + use_facet >(const locale&); + + extern template + const money_get& + use_facet >(const locale&); + + extern template + const __timepunct& + use_facet<__timepunct >(const locale&); + + extern template + const time_put& + use_facet >(const locale&); + + extern template + const time_get& + use_facet >(const locale&); + + extern template + const messages& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet<__timepunct >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class moneypunct; + extern template class moneypunct; + extern template class moneypunct_byname; + extern template class moneypunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put; + extern template class __timepunct; + extern template class time_put; + extern template class time_put_byname; + extern template class time_get; + extern template class time_get_byname; + extern template class messages; + extern template class messages_byname; + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const money_put& + use_facet >(const locale&); + + extern template + const money_get& + use_facet >(const locale&); + + extern template + const __timepunct& + use_facet<__timepunct >(const locale&); + + extern template + const time_put& + use_facet >(const locale&); + + extern template + const time_get& + use_facet >(const locale&); + + extern template + const messages& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet<__timepunct >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..cf2c39d2f4f495783bc95141624abd7b4b62cd09 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@locale_facets_nonio.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h new file mode 100644 index 0000000000000000000000000000000000000000..3555bf23fde40468a8c0e60051b45610c069fd1b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h @@ -0,0 +1,214 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/localefwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FWD_H +#define _LOCALE_FWD_H 1 + +#pragma GCC system_header + +#include +#include // Defines __c_locale, config-specific include +#include // For ostreambuf_iterator, istreambuf_iterator +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup locales Locales + * + * Classes and functions for internationalization and localization. + */ + + // 22.1.1 Locale + class locale; + + template + bool + has_facet(const locale&) throw(); + + template + const _Facet& + use_facet(const locale&); + + // 22.1.3 Convenience interfaces + template + bool + isspace(_CharT, const locale&); + + template + bool + isprint(_CharT, const locale&); + + template + bool + iscntrl(_CharT, const locale&); + + template + bool + isupper(_CharT, const locale&); + + template + bool + islower(_CharT, const locale&); + + template + bool + isalpha(_CharT, const locale&); + + template + bool + isdigit(_CharT, const locale&); + + template + bool + ispunct(_CharT, const locale&); + + template + bool + isxdigit(_CharT, const locale&); + + template + bool + isalnum(_CharT, const locale&); + + template + bool + isgraph(_CharT, const locale&); + +#if __cplusplus >= 201103L + template + bool + isblank(_CharT, const locale&); +#endif + + template + _CharT + toupper(_CharT, const locale&); + + template + _CharT + tolower(_CharT, const locale&); + + // 22.2.1 and 22.2.1.3 ctype + struct ctype_base; + template + class ctype; + template<> class ctype; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> class ctype; +#endif + template + class ctype_byname; + // NB: Specialized for char and wchar_t in locale_facets.h. + + class codecvt_base; + template + class codecvt; + template<> class codecvt; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> class codecvt; +#endif +#if __cplusplus >= 201103L + template<> class codecvt; + template<> class codecvt; +#ifdef _GLIBCXX_USE_CHAR8_T + template<> class codecvt; + template<> class codecvt; +#endif +#endif + template + class codecvt_byname; + + // 22.2.2 and 22.2.3 numeric +_GLIBCXX_BEGIN_NAMESPACE_LDBL + template > + class num_get; + template > + class num_put; +_GLIBCXX_END_NAMESPACE_LDBL +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template class numpunct; + template class numpunct_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + // 22.2.4 collation + template + class collate; + template + class collate_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + + // 22.2.5 date and time + class time_base; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template > + class time_get; + template > + class time_get_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + template > + class time_put; + template > + class time_put_byname; + + // 22.2.6 money + class money_base; +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + template > + class money_get; + template > + class money_put; +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class moneypunct; + template + class moneypunct_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + + // 22.2.7 message retrieval + struct messages_base; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class messages; + template + class messages_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ea22d16aad01e5ed58ba4c03415aa2a683753e52 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@localefwd.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h new file mode 100644 index 0000000000000000000000000000000000000000..94c092455c564cfb9d07b78e9d7c406b1d4815df --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h @@ -0,0 +1,213 @@ +// The template and inlines for the -*- C++ -*- mask_array class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/mask_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _MASK_ARRAY_H +#define _MASK_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to selected subset of an array. + * + * A mask_array is a reference to the actual elements of an array specified + * by a bitmask in the form of an array of bool. The way to get a + * mask_array is to call operator[](valarray) on a valarray. The + * returned mask_array then permits carrying operations out on the + * referenced subset of elements in the original valarray. + * + * For example, if a mask_array is obtained using the array (false, true, + * false, true) as an argument, the mask array has two elements referring + * to array[1] and array[3] in the underlying array. + * + * @param Tp Element type. + */ + template + class mask_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + mask_array (const mask_array&); + + /// Assignment operator. Assigns elements to corresponding elements + /// of @a a. + mask_array& operator=(const mask_array&); + + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp&) const; + + // ~mask_array (); + + template + void operator=(const _Expr<_Dom,_Tp>&) const; + template + void operator*=(const _Expr<_Dom,_Tp>&) const; + template + void operator/=(const _Expr<_Dom,_Tp>&) const; + template + void operator%=(const _Expr<_Dom,_Tp>&) const; + template + void operator+=(const _Expr<_Dom,_Tp>&) const; + template + void operator-=(const _Expr<_Dom,_Tp>&) const; + template + void operator^=(const _Expr<_Dom,_Tp>&) const; + template + void operator&=(const _Expr<_Dom,_Tp>&) const; + template + void operator|=(const _Expr<_Dom,_Tp>&) const; + template + void operator<<=(const _Expr<_Dom,_Tp>&) const; + template + void operator>>=(const _Expr<_Dom,_Tp>&) const; + + private: + mask_array(_Array<_Tp>, size_t, _Array); + friend class valarray<_Tp>; + + const size_t _M_sz; + const _Array _M_mask; + const _Array<_Tp> _M_array; + +#if __cplusplus < 201103L + // not implemented + mask_array(); +#else + public: + mask_array() = delete; +#endif + }; + + template + inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_mask(__a._M_mask), _M_array(__a._M_array) {} + + template + inline + mask_array<_Tp>::mask_array(_Array<_Tp> __a, size_t __s, _Array __m) + : _M_sz(__s), _M_mask(__m), _M_array(__a) {} + + template + inline mask_array<_Tp>& + mask_array<_Tp>::operator=(const mask_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, __a._M_mask, + _M_sz, _M_array, _M_mask); + return *this; + } + + template + inline void + mask_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_sz, _M_mask, __t); } + + template + inline void + mask_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), __v.size(), _M_array, _M_mask); } + + template + template + inline void + mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const + { std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _M_mask, \ + _Array<_Tp>(__v), __v.size()); \ + } \ + \ + template \ + template \ + inline void \ + mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _MASK_ARRAY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ea459251d6fe3fd155e9acf2b1be46a7574ce0b1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@mask_array.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h new file mode 100644 index 0000000000000000000000000000000000000000..751329c0c22bb27919c6f7a85aa77b899d33b0c0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h @@ -0,0 +1,83 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996-1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/memoryfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _MEMORYFWD_H +#define _MEMORYFWD_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup allocators Allocators + * @ingroup memory + * + * Classes encapsulating memory operations. + * + * @{ + */ + + template + class allocator; + + template<> + class allocator; + +#if __cplusplus >= 201103L + /// Declare uses_allocator so it can be specialized in `` etc. + template + struct uses_allocator; + + template + struct allocator_traits; +#endif + + /// @} group memory + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7733a048ee70d5ddc3d5c9e1d2a341e3933fe8fa Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@memoryfwd.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h new file mode 100644 index 0000000000000000000000000000000000000000..af4735426288d880465c04515df6e8efeda72bec --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h @@ -0,0 +1,231 @@ +// Move, forward and identity for C++11 + swap -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/move.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + */ + +#ifndef _MOVE_H +#define _MOVE_H 1 + +#include +#if __cplusplus < 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Used, in C++03 mode too, by allocators, etc. + /** + * @brief Same as C++11 std::addressof + * @ingroup utilities + */ + template + inline _GLIBCXX_CONSTEXPR _Tp* + __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT + { return __builtin_addressof(__r); } + +#if __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include // Brings in std::declval too. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + /** + * @brief Forward an lvalue. + * @return The parameter cast to the specified type. + * + * This function is used to implement "perfect forwarding". + */ + template + _GLIBCXX_NODISCARD + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type& __t) noexcept + { return static_cast<_Tp&&>(__t); } + + /** + * @brief Forward an rvalue. + * @return The parameter cast to the specified type. + * + * This function is used to implement "perfect forwarding". + */ + template + _GLIBCXX_NODISCARD + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type&& __t) noexcept + { + static_assert(!std::is_lvalue_reference<_Tp>::value, + "std::forward must not be used to convert an rvalue to an lvalue"); + return static_cast<_Tp&&>(__t); + } + + /** + * @brief Convert a value to an rvalue. + * @param __t A thing of arbitrary type. + * @return The parameter cast to an rvalue-reference to allow moving it. + */ + template + _GLIBCXX_NODISCARD + constexpr typename std::remove_reference<_Tp>::type&& + move(_Tp&& __t) noexcept + { return static_cast::type&&>(__t); } + + + template + struct __move_if_noexcept_cond + : public __and_<__not_>, + is_copy_constructible<_Tp>>::type { }; + + /** + * @brief Conditionally convert a value to an rvalue. + * @param __x A thing of arbitrary type. + * @return The parameter, possibly cast to an rvalue-reference. + * + * Same as std::move unless the type's move constructor could throw and the + * type is copyable, in which case an lvalue-reference is returned instead. + */ + template + _GLIBCXX_NODISCARD + constexpr + __conditional_t<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&> + move_if_noexcept(_Tp& __x) noexcept + { return std::move(__x); } + + // declval, from type_traits. + +#if __cplusplus > 201402L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2296. std::addressof should be constexpr +# define __cpp_lib_addressof_constexpr 201603L +#endif + /** + * @brief Returns the actual address of the object or function + * referenced by r, even in the presence of an overloaded + * operator&. + * @param __r Reference to an object or function. + * @return The actual address. + */ + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR _Tp* + addressof(_Tp& __r) noexcept + { return std::__addressof(__r); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2598. addressof works on temporaries + template + const _Tp* addressof(const _Tp&&) = delete; + + // C++11 version of std::exchange for internal use. + template + _GLIBCXX20_CONSTEXPR + inline _Tp + __exchange(_Tp& __obj, _Up&& __new_val) + { + _Tp __old_val = std::move(__obj); + __obj = std::forward<_Up>(__new_val); + return __old_val; + } + + /// @} group utilities + +#define _GLIBCXX_FWDREF(_Tp) _Tp&& +#define _GLIBCXX_MOVE(__val) std::move(__val) +#define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val) +#else +#define _GLIBCXX_FWDREF(_Tp) const _Tp& +#define _GLIBCXX_MOVE(__val) (__val) +#define _GLIBCXX_FORWARD(_Tp, __val) (__val) +#endif + + /** + * @addtogroup utilities + * @{ + */ + + /** + * @brief Swaps two values. + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return Nothing. + */ + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus >= 201103L + typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, + is_move_constructible<_Tp>, + is_move_assignable<_Tp>>::value>::type +#else + void +#endif + swap(_Tp& __a, _Tp& __b) + _GLIBCXX_NOEXCEPT_IF(__and_, + is_nothrow_move_assignable<_Tp>>::value) + { +#if __cplusplus < 201103L + // concept requirements + __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) +#endif + _Tp __tmp = _GLIBCXX_MOVE(__a); + __a = _GLIBCXX_MOVE(__b); + __b = _GLIBCXX_MOVE(__tmp); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 809. std::swap should be overloaded for array types. + /// Swap the contents of two arrays. + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus >= 201103L + typename enable_if<__is_swappable<_Tp>::value>::type +#else + void +#endif + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Tp>::value) + { + for (size_t __n = 0; __n < _Nm; ++__n) + swap(__a[__n], __b[__n]); + } + + /// @} group utilities +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _MOVE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..08b3d7b01835e690781f33ac06184049baae9d50 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@move.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h new file mode 100644 index 0000000000000000000000000000000000000000..6f0d5399708ef2e69cd88d9008fc7c89f1da1070 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h @@ -0,0 +1,171 @@ +// Nested Exception support header (nested_exception class) for -*- C++ -*- + +// Copyright (C) 2009-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/nested_exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _GLIBCXX_NESTED_EXCEPTION_H +#define _GLIBCXX_NESTED_EXCEPTION_H 1 + +#pragma GCC visibility push(default) + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +extern "C++" { + +namespace std +{ + /** + * @addtogroup exceptions + * @{ + */ + + /// Exception class with exception_ptr data member. + class nested_exception + { + exception_ptr _M_ptr; + + public: + nested_exception() noexcept : _M_ptr(current_exception()) { } + + nested_exception(const nested_exception&) noexcept = default; + + nested_exception& operator=(const nested_exception&) noexcept = default; + + virtual ~nested_exception() noexcept; + + [[noreturn]] + void + rethrow_nested() const + { + if (_M_ptr) + rethrow_exception(_M_ptr); + std::terminate(); + } + + exception_ptr + nested_ptr() const noexcept + { return _M_ptr; } + }; + + /// @cond undocumented + + template + struct _Nested_exception : public _Except, public nested_exception + { + explicit _Nested_exception(const _Except& __ex) + : _Except(__ex) + { } + + explicit _Nested_exception(_Except&& __ex) + : _Except(static_cast<_Except&&>(__ex)) + { } + }; + + // [except.nested]/8 + // Throw an exception of unspecified type that is publicly derived from + // both remove_reference_t<_Tp> and nested_exception. + template + [[noreturn]] + inline void + __throw_with_nested_impl(_Tp&& __t, true_type) + { + using _Up = typename remove_reference<_Tp>::type; + throw _Nested_exception<_Up>{std::forward<_Tp>(__t)}; + } + + template + [[noreturn]] + inline void + __throw_with_nested_impl(_Tp&& __t, false_type) + { throw std::forward<_Tp>(__t); } + + /// @endcond + + /// If @p __t is derived from nested_exception, throws @p __t. + /// Else, throws an implementation-defined object derived from both. + template + [[noreturn]] + inline void + throw_with_nested(_Tp&& __t) + { + using _Up = typename decay<_Tp>::type; + using _CopyConstructible + = __and_, is_move_constructible<_Up>>; + static_assert(_CopyConstructible::value, + "throw_with_nested argument must be CopyConstructible"); + using __nest = __and_, __bool_constant, + __not_>>; + std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{}); + } + + /// @cond undocumented + + // Determine if dynamic_cast would be well-formed. + template + using __rethrow_if_nested_cond = typename enable_if< + __and_, + __or_<__not_>, + is_convertible<_Tp*, nested_exception*>>>::value + >::type; + + // Attempt dynamic_cast to nested_exception and call rethrow_nested(). + template + inline __rethrow_if_nested_cond<_Ex> + __rethrow_if_nested_impl(const _Ex* __ptr) + { + if (auto __ne_ptr = dynamic_cast(__ptr)) + __ne_ptr->rethrow_nested(); + } + + // Otherwise, no effects. + inline void + __rethrow_if_nested_impl(const void*) + { } + + /// @endcond + + /// If @p __ex is derived from nested_exception, @p __ex.rethrow_nested(). + template + inline void + rethrow_if_nested(const _Ex& __ex) + { std::__rethrow_if_nested_impl(std::__addressof(__ex)); } + + /// @} group exceptions +} // namespace std + +} // extern "C++" + +#endif // C++11 + +#pragma GCC visibility pop + +#endif // _GLIBCXX_NESTED_EXCEPTION_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..68cd4b291a9aebf189947ecf800858049ce95aa7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@nested_exception.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..99f7a2ee51e3a1d54f89904883be7da93690c50b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h @@ -0,0 +1,223 @@ +// Allocator that wraps operator new -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/new_allocator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STD_NEW_ALLOCATOR_H +#define _STD_NEW_ALLOCATOR_H 1 + +#include +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief An allocator that uses global new, as per C++03 [20.4.1]. + * @ingroup allocators + * + * This is precisely the allocator defined in the C++ Standard. + * - all allocation calls operator new + * - all deallocation calls operator delete + * + * @tparam _Tp Type of allocated object. + */ + template + class __new_allocator + { + public: + typedef _Tp value_type; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; +#if __cplusplus <= 201703L + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + template + struct rebind + { typedef __new_allocator<_Tp1> other; }; +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. propagate_on_container_move_assignment + typedef std::true_type propagate_on_container_move_assignment; +#endif + + _GLIBCXX20_CONSTEXPR + __new_allocator() _GLIBCXX_USE_NOEXCEPT { } + + _GLIBCXX20_CONSTEXPR + __new_allocator(const __new_allocator&) _GLIBCXX_USE_NOEXCEPT { } + + template + _GLIBCXX20_CONSTEXPR + __new_allocator(const __new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { } + +#if __cplusplus <= 201703L + ~__new_allocator() _GLIBCXX_USE_NOEXCEPT { } + + pointer + address(reference __x) const _GLIBCXX_NOEXCEPT + { return std::__addressof(__x); } + + const_pointer + address(const_reference __x) const _GLIBCXX_NOEXCEPT + { return std::__addressof(__x); } +#endif + +#if __has_builtin(__builtin_operator_new) >= 201802L +# define _GLIBCXX_OPERATOR_NEW __builtin_operator_new +# define _GLIBCXX_OPERATOR_DELETE __builtin_operator_delete +#else +# define _GLIBCXX_OPERATOR_NEW ::operator new +# define _GLIBCXX_OPERATOR_DELETE ::operator delete +#endif + + // NB: __n is permitted to be 0. The C++ standard says nothing + // about what the return value is when __n == 0. + _GLIBCXX_NODISCARD _Tp* + allocate(size_type __n, const void* = static_cast(0)) + { +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3308. std::allocator().allocate(n) + static_assert(sizeof(_Tp) != 0, "cannot allocate incomplete types"); +#endif + + if (__builtin_expect(__n > this->_M_max_size(), false)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3190. allocator::allocate sometimes returns too little storage + if (__n > (std::size_t(-1) / sizeof(_Tp))) + std::__throw_bad_array_new_length(); + std::__throw_bad_alloc(); + } + +#if __cpp_aligned_new + if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__) + { + std::align_val_t __al = std::align_val_t(alignof(_Tp)); + return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp), + __al)); + } +#endif + return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp))); + } + + // __p is not permitted to be a null pointer. + void + deallocate(_Tp* __p, size_type __n __attribute__ ((__unused__))) + { +#if __cpp_sized_deallocation +# define _GLIBCXX_SIZED_DEALLOC(p, n) (p), (n) * sizeof(_Tp) +#else +# define _GLIBCXX_SIZED_DEALLOC(p, n) (p) +#endif + +#if __cpp_aligned_new + if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__) + { + _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n), + std::align_val_t(alignof(_Tp))); + return; + } +#endif + _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n)); + } + +#undef _GLIBCXX_SIZED_DEALLOC +#undef _GLIBCXX_OPERATOR_DELETE +#undef _GLIBCXX_OPERATOR_NEW + +#if __cplusplus <= 201703L + size_type + max_size() const _GLIBCXX_USE_NOEXCEPT + { return _M_max_size(); } + +#if __cplusplus >= 201103L + template + void + construct(_Up* __p, _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) + { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } + + template + void + destroy(_Up* __p) + noexcept(std::is_nothrow_destructible<_Up>::value) + { __p->~_Up(); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 402. wrong new expression in [some_] allocator::construct + void + construct(pointer __p, const _Tp& __val) + { ::new((void *)__p) _Tp(__val); } + + void + destroy(pointer __p) { __p->~_Tp(); } +#endif +#endif // ! C++20 + + template + friend _GLIBCXX20_CONSTEXPR bool + operator==(const __new_allocator&, const __new_allocator<_Up>&) + _GLIBCXX_NOTHROW + { return true; } + +#if __cpp_impl_three_way_comparison < 201907L + template + friend _GLIBCXX20_CONSTEXPR bool + operator!=(const __new_allocator&, const __new_allocator<_Up>&) + _GLIBCXX_NOTHROW + { return false; } +#endif + + private: + _GLIBCXX_CONSTEXPR size_type + _M_max_size() const _GLIBCXX_USE_NOEXCEPT + { +#if __PTRDIFF_MAX__ < __SIZE_MAX__ + return std::size_t(__PTRDIFF_MAX__) / sizeof(_Tp); +#else + return std::size_t(-1) / sizeof(_Tp); +#endif + } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8cc807073dacfd7e23a84f97ba41be0bfdd708ab Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@new_allocator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc new file mode 100644 index 0000000000000000000000000000000000000000..ba337c81aa85c2e0f9c550e02929496364f040f1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc @@ -0,0 +1,388 @@ +// ostream classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ostream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ostream} + */ + +// +// ISO C++ 14882: 27.6.2 Output streams +// + +#ifndef _OSTREAM_TCC +#define _OSTREAM_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + basic_ostream<_CharT, _Traits>::sentry:: + sentry(basic_ostream<_CharT, _Traits>& __os) + : _M_ok(false), _M_os(__os) + { + // XXX MT + if (__os.tie() && __os.good()) + __os.tie()->flush(); + + if (__os.good()) + _M_ok = true; + else if (__os.bad()) + __os.setstate(ios_base::failbit); + } + + template + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + _M_insert(_ValueT __v) + { + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __num_put_type& __np = __check_facet(this->_M_num_put); + if (__np.put(*this, *this, this->fill(), __v).failed()) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(short __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(int __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(__streambuf_type* __sbin) + { + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this); + if (__cerb && __sbin) + { + __try + { + if (!__copy_streambufs(__sbin, this->rdbuf())) + __err |= ios_base::failbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::failbit); } + } + else if (!__sbin) + __err |= ios_base::badbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + put(char_type __c) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::put(char_type) is an unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __put = this->rdbuf()->sputc(__c); + if (traits_type::eq_int_type(__put, traits_type::eof())) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + write(const _CharT* __s, streamsize __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::write(const char_type*, streamsize) is an + // unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (this->rdbuf()->sputn(__s, __n) != __n) + __err = ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(ios_base::badbit); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + flush() + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::flush() is *not* an unformatted output function. + // 581. flush() not unformatted function + // basic_ostream::flush() *is* an unformatted output function. + if (__streambuf_type* __buf = this->rdbuf()) + { + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (this->rdbuf()->pubsync() == -1) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + } + return *this; + } + + template + typename basic_ostream<_CharT, _Traits>::pos_type + basic_ostream<_CharT, _Traits>:: + tellp() + { + sentry __cerb(*this); + pos_type __ret = pos_type(-1); + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + return __ret; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(pos_type __pos) + { + sentry __cerb(*this); + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekpos(__pos, ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + this->setstate(ios_base::failbit); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(off_type __off, ios_base::seekdir __dir) + { + sentry __cerb(*this); + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, + ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + this->setstate(ios_base::failbit); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) + { + if (!__s) + __out.setstate(ios_base::badbit); + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 167. Improper use of traits_type::length() + const size_t __clen = char_traits::length(__s); + __try + { + struct __ptr_guard + { + _CharT *__p; + __ptr_guard (_CharT *__ip): __p(__ip) { } + ~__ptr_guard() { delete[] __p; } + _CharT* __get() { return __p; } + } __pg (new _CharT[__clen]); + + _CharT *__ws = __pg.__get(); + for (size_t __i = 0; __i < __clen; ++__i) + __ws[__i] = __out.widen(__s[__i]); + __ostream_insert(__out, __ws, __clen); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __out._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __out._M_setstate(ios_base::badbit); } + } + return __out; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_ostream; + extern template ostream& endl(ostream&); + extern template ostream& ends(ostream&); + extern template ostream& flush(ostream&); + extern template ostream& operator<<(ostream&, char); + extern template ostream& operator<<(ostream&, unsigned char); + extern template ostream& operator<<(ostream&, signed char); + extern template ostream& operator<<(ostream&, const char*); + extern template ostream& operator<<(ostream&, const unsigned char*); + extern template ostream& operator<<(ostream&, const signed char*); + + extern template ostream& ostream::_M_insert(long); + extern template ostream& ostream::_M_insert(unsigned long); + extern template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template ostream& ostream::_M_insert(long long); + extern template ostream& ostream::_M_insert(unsigned long long); +#endif + extern template ostream& ostream::_M_insert(double); + extern template ostream& ostream::_M_insert(long double); + extern template ostream& ostream::_M_insert(const void*); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_ostream; + extern template wostream& endl(wostream&); + extern template wostream& ends(wostream&); + extern template wostream& flush(wostream&); + extern template wostream& operator<<(wostream&, wchar_t); + extern template wostream& operator<<(wostream&, char); + extern template wostream& operator<<(wostream&, const wchar_t*); + extern template wostream& operator<<(wostream&, const char*); + + extern template wostream& wostream::_M_insert(long); + extern template wostream& wostream::_M_insert(unsigned long); + extern template wostream& wostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wostream& wostream::_M_insert(long long); + extern template wostream& wostream::_M_insert(unsigned long long); +#endif + extern template wostream& wostream::_M_insert(double); + extern template wostream& wostream::_M_insert(long double); + extern template wostream& wostream::_M_insert(const void*); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..bf7ec71263b5f0f9ca29117502fddcc32484a927 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h new file mode 100644 index 0000000000000000000000000000000000000000..9442ea130d364d230d44195ae0f12965681cc355 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h @@ -0,0 +1,130 @@ +// Helpers for ostream inserters -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ostream_insert.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ostream} + */ + +#ifndef _OSTREAM_INSERT_H +#define _OSTREAM_INSERT_H 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + inline void + __ostream_write(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const streamsize __put = __out.rdbuf()->sputn(__s, __n); + if (__put != __n) + __out.setstate(__ios_base::badbit); + } + + template + inline void + __ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const _CharT __c = __out.fill(); + for (; __n > 0; --__n) + { + const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c); + if (_Traits::eq_int_type(__put, _Traits::eof())) + { + __out.setstate(__ios_base::badbit); + break; + } + } + } + + template + basic_ostream<_CharT, _Traits>& + __ostream_insert(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + typename __ostream_type::sentry __cerb(__out); + if (__cerb) + { + __try + { + const streamsize __w = __out.width(); + if (__w > __n) + { + const bool __left = ((__out.flags() + & __ios_base::adjustfield) + == __ios_base::left); + if (!__left) + __ostream_fill(__out, __w - __n); + if (__out.good()) + __ostream_write(__out, __s, __n); + if (__left && __out.good()) + __ostream_fill(__out, __w - __n); + } + else + __ostream_write(__out, __s, __n); + __out.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __out._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __out._M_setstate(__ios_base::badbit); } + } + return __out; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template ostream& __ostream_insert(ostream&, const char*, streamsize); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wostream& __ostream_insert(wostream&, const wchar_t*, + streamsize); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _OSTREAM_INSERT_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..cfd724b5c7bfd3f1c8634140fe5dda752f9428e1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ostream_insert.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h new file mode 100644 index 0000000000000000000000000000000000000000..ba21d882959c80a187001add6103b074b663e54e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h @@ -0,0 +1,295 @@ +// Components for compile-time parsing of numbers -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/parse_numbers.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{chrono} + */ + +#ifndef _GLIBCXX_PARSE_NUMBERS_H +#define _GLIBCXX_PARSE_NUMBERS_H 1 + +#pragma GCC system_header + +// From n3642.pdf except I added binary literals and digit separator '\''. + +#if __cplusplus >= 201402L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __parse_int +{ + template + struct _Digit; + + template + struct _Digit<_Base, '0'> : integral_constant + { + using __valid = true_type; + }; + + template + struct _Digit<_Base, '1'> : integral_constant + { + using __valid = true_type; + }; + + template + struct _Digit_impl : integral_constant + { + static_assert(_Base > _Val, "invalid digit"); + using __valid = true_type; + }; + + template + struct _Digit<_Base, '2'> : _Digit_impl<_Base, 2> + { }; + + template + struct _Digit<_Base, '3'> : _Digit_impl<_Base, 3> + { }; + + template + struct _Digit<_Base, '4'> : _Digit_impl<_Base, 4> + { }; + + template + struct _Digit<_Base, '5'> : _Digit_impl<_Base, 5> + { }; + + template + struct _Digit<_Base, '6'> : _Digit_impl<_Base, 6> + { }; + + template + struct _Digit<_Base, '7'> : _Digit_impl<_Base, 7> + { }; + + template + struct _Digit<_Base, '8'> : _Digit_impl<_Base, 8> + { }; + + template + struct _Digit<_Base, '9'> : _Digit_impl<_Base, 9> + { }; + + template + struct _Digit<_Base, 'a'> : _Digit_impl<_Base, 0xa> + { }; + + template + struct _Digit<_Base, 'A'> : _Digit_impl<_Base, 0xa> + { }; + + template + struct _Digit<_Base, 'b'> : _Digit_impl<_Base, 0xb> + { }; + + template + struct _Digit<_Base, 'B'> : _Digit_impl<_Base, 0xb> + { }; + + template + struct _Digit<_Base, 'c'> : _Digit_impl<_Base, 0xc> + { }; + + template + struct _Digit<_Base, 'C'> : _Digit_impl<_Base, 0xc> + { }; + + template + struct _Digit<_Base, 'd'> : _Digit_impl<_Base, 0xd> + { }; + + template + struct _Digit<_Base, 'D'> : _Digit_impl<_Base, 0xd> + { }; + + template + struct _Digit<_Base, 'e'> : _Digit_impl<_Base, 0xe> + { }; + + template + struct _Digit<_Base, 'E'> : _Digit_impl<_Base, 0xe> + { }; + + template + struct _Digit<_Base, 'f'> : _Digit_impl<_Base, 0xf> + { }; + + template + struct _Digit<_Base, 'F'> : _Digit_impl<_Base, 0xf> + { }; + + // Digit separator + template + struct _Digit<_Base, '\''> : integral_constant + { + using __valid = false_type; + }; + +//------------------------------------------------------------------------------ + + template + using __ull_constant = integral_constant; + + template + struct _Power_help + { + using __next = typename _Power_help<_Base, _Digs...>::type; + using __valid_digit = typename _Digit<_Base, _Dig>::__valid; + using type + = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>; + }; + + template + struct _Power_help<_Base, _Dig> + { + using __valid_digit = typename _Digit<_Base, _Dig>::__valid; + using type = __ull_constant<__valid_digit::value>; + }; + + template + struct _Power : _Power_help<_Base, _Digs...>::type + { }; + + template + struct _Power<_Base> : __ull_constant<0> + { }; + +//------------------------------------------------------------------------------ + + template + struct _Number_help + { + using __digit = _Digit<_Base, _Dig>; + using __valid_digit = typename __digit::__valid; + using __next = _Number_help<_Base, + __valid_digit::value ? _Pow / _Base : _Pow, + _Digs...>; + using type = __ull_constant<_Pow * __digit::value + __next::type::value>; + static_assert((type::value / _Pow) == __digit::value, + "integer literal does not fit in unsigned long long"); + }; + + // Skip past digit separators: + template + struct _Number_help<_Base, _Pow, '\'', _Dig, _Digs...> + : _Number_help<_Base, _Pow, _Dig, _Digs...> + { }; + + // Terminating case for recursion: + template + struct _Number_help<_Base, 1ULL, _Dig> + { + using type = __ull_constant<_Digit<_Base, _Dig>::value>; + }; + + template + struct _Number + : _Number_help<_Base, _Power<_Base, _Digs...>::value, _Digs...>::type + { }; + + template + struct _Number<_Base> + : __ull_constant<0> + { }; + +//------------------------------------------------------------------------------ + + template + struct _Parse_int; + + template + struct _Parse_int<'0', 'b', _Digs...> + : _Number<2U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'B', _Digs...> + : _Number<2U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'x', _Digs...> + : _Number<16U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'X', _Digs...> + : _Number<16U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', _Digs...> + : _Number<8U, _Digs...>::type + { }; + + template + struct _Parse_int + : _Number<10U, _Digs...>::type + { }; + +} // namespace __parse_int + + +namespace __select_int +{ + template + struct _Select_int_base; + + template + struct _Select_int_base<_Val, _IntType, _Ints...> + : __conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max), + integral_constant<_IntType, (_IntType)_Val>, + _Select_int_base<_Val, _Ints...>> + { }; + + template + struct _Select_int_base<_Val> + { }; + + template + using _Select_int = typename _Select_int_base< + __parse_int::_Parse_int<_Digs...>::value, + unsigned char, + unsigned short, + unsigned int, + unsigned long, + unsigned long long + >::type; + +} // namespace __select_int + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_PARSE_NUMBERS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4de745ae7f02a4e2caef702796dcbd2c3bdaec85 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@parse_numbers.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h new file mode 100644 index 0000000000000000000000000000000000000000..9339a20a162bdc982ebc8302e61b1a0f9659b59c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h @@ -0,0 +1,223 @@ +// Position types -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/postypes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +// +// ISO C++ 14882: 27.4.1 - Types +// ISO C++ 14882: 27.4.3 - Template class fpos +// + +#ifndef _GLIBCXX_POSTYPES_H +#define _GLIBCXX_POSTYPES_H 1 + +#pragma GCC system_header + +#include // For mbstate_t + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The types streamoff, streampos and wstreampos and the class + // template fpos<> are described in clauses 21.1.2, 21.1.3, 27.1.2, + // 27.2, 27.4.1, 27.4.3 and D.6. Despite all this verbiage, the + // behaviour of these types is mostly implementation defined or + // unspecified. The behaviour in this implementation is as noted + // below. + + /** + * @brief Type used by fpos, char_traits, and char_traits. + * + * In clauses 21.1.3.1 and 27.4.1 streamoff is described as an + * implementation defined type. + * Note: In versions of GCC up to and including GCC 3.3, streamoff + * was typedef long. + */ +#ifdef __INT64_TYPE__ + typedef __INT64_TYPE__ streamoff; +#else + typedef long long streamoff; +#endif + + /// Integral type for I/O operation counts and buffer sizes. + typedef ptrdiff_t streamsize; // Signed integral type + + /** + * @brief Class representing stream positions. + * + * The standard places no requirements upon the template parameter StateT. + * In this implementation StateT must be DefaultConstructible, + * CopyConstructible and Assignable. The standard only requires that fpos + * should contain a member of type StateT. In this implementation it also + * contains an offset stored as a signed integer. + * + * @param StateT Type passed to and returned from state(). + */ + template + class fpos + { + private: + streamoff _M_off; + _StateT _M_state; + + public: + // The standard doesn't require that fpos objects can be default + // constructed. This implementation provides a default + // constructor that initializes the offset to 0 and default + // constructs the state. + fpos() + : _M_off(0), _M_state() { } + + // The standard requires that fpos objects can be constructed + // from streamoff objects using the constructor syntax, and + // fails to give any meaningful semantics. In this + // implementation implicit conversion is also allowed, and this + // constructor stores the streamoff as the offset and default + // constructs the state. + /// Construct position from offset. + fpos(streamoff __off) + : _M_off(__off), _M_state() { } + +#if __cplusplus >= 201103L + fpos(const fpos&) = default; + fpos& operator=(const fpos&) = default; + ~fpos() = default; +#endif + + /// Convert to streamoff. + operator streamoff() const { return _M_off; } + + /// Remember the value of @a st. + void + state(_StateT __st) + { _M_state = __st; } + + /// Return the last set value of @a st. + _StateT + state() const + { return _M_state; } + + // The standard requires that this operator must be defined, but + // gives no semantics. In this implementation it just adds its + // argument to the stored offset and returns *this. + /// Add offset to this position. + fpos& + operator+=(streamoff __off) + { + _M_off += __off; + return *this; + } + + // The standard requires that this operator must be defined, but + // gives no semantics. In this implementation it just subtracts + // its argument from the stored offset and returns *this. + /// Subtract offset from this position. + fpos& + operator-=(streamoff __off) + { + _M_off -= __off; + return *this; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator-. In this + // implementation it constructs a copy of *this, adds the + // argument to that copy using operator+= and then returns the + // copy. + /// Add position and offset. + fpos + operator+(streamoff __off) const + { + fpos __pos(*this); + __pos += __off; + return __pos; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator+. In this + // implementation it constructs a copy of *this, subtracts the + // argument from that copy using operator-= and then returns the + // copy. + /// Subtract offset from position. + fpos + operator-(streamoff __off) const + { + fpos __pos(*this); + __pos -= __off; + return __pos; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator+. In this + // implementation it returns the difference between the offset + // stored in *this and in the argument. + /// Subtract position to return offset. + streamoff + operator-(const fpos& __other) const + { return _M_off - __other._M_off; } + }; + + // The standard only requires that operator== must be an + // equivalence relation. In this implementation two fpos + // objects belong to the same equivalence class if the contained + // offsets compare equal. + /// Test if equivalent to another position. + template + inline bool + operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) == streamoff(__rhs); } + + template + inline bool + operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) != streamoff(__rhs); } + + // Clauses 21.1.3.1 and 21.1.3.2 describe streampos and wstreampos + // as implementation defined types, but clause 27.2 requires that + // they must both be typedefs for fpos + /// File position for char streams. + typedef fpos streampos; + /// File position for wchar_t streams. + typedef fpos wstreampos; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// File position for char8_t streams. + typedef fpos u8streampos; +#endif + +#if __cplusplus >= 201103L + /// File position for char16_t streams. + typedef fpos u16streampos; + /// File position for char32_t streams. + typedef fpos u32streampos; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..005311662c88667259c35ee1901ecd9b473571a7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@postypes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..53c350323cb1cb5235449ae72be0c9d99f11368e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h @@ -0,0 +1,407 @@ +// Default predicates for internal use -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file predefined_ops.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _GLIBCXX_PREDEFINED_OPS_H +#define _GLIBCXX_PREDEFINED_OPS_H 1 + +#include + +namespace __gnu_cxx +{ +namespace __ops +{ + struct _Iter_less_iter + { + template + _GLIBCXX14_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) const + { return *__it1 < *__it2; } + }; + + _GLIBCXX14_CONSTEXPR + inline _Iter_less_iter + __iter_less_iter() + { return _Iter_less_iter(); } + + struct _Iter_less_val + { +#if __cplusplus >= 201103L + constexpr _Iter_less_val() = default; +#else + _Iter_less_val() { } +#endif + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_less_val(_Iter_less_iter) { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) const + { return *__it < __val; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_less_val + __iter_less_val() + { return _Iter_less_val(); } + + _GLIBCXX20_CONSTEXPR + inline _Iter_less_val + __iter_comp_val(_Iter_less_iter) + { return _Iter_less_val(); } + + struct _Val_less_iter + { +#if __cplusplus >= 201103L + constexpr _Val_less_iter() = default; +#else + _Val_less_iter() { } +#endif + + _GLIBCXX20_CONSTEXPR + explicit + _Val_less_iter(_Iter_less_iter) { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Value& __val, _Iterator __it) const + { return __val < *__it; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Val_less_iter + __val_less_iter() + { return _Val_less_iter(); } + + _GLIBCXX20_CONSTEXPR + inline _Val_less_iter + __val_comp_iter(_Iter_less_iter) + { return _Val_less_iter(); } + + struct _Iter_equal_to_iter + { + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) const + { return *__it1 == *__it2; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_iter + __iter_equal_to_iter() + { return _Iter_equal_to_iter(); } + + struct _Iter_equal_to_val + { + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) const + { return *__it == __val; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_val + __iter_equal_to_val() + { return _Iter_equal_to_val(); } + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_val + __iter_comp_val(_Iter_equal_to_iter) + { return _Iter_equal_to_val(); } + + template + struct _Iter_comp_iter + { + _Compare _M_comp; + + explicit _GLIBCXX14_CONSTEXPR + _Iter_comp_iter(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + template + _GLIBCXX14_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) + { return bool(_M_comp(*__it1, *__it2)); } + }; + + template + _GLIBCXX14_CONSTEXPR + inline _Iter_comp_iter<_Compare> + __iter_comp_iter(_Compare __comp) + { return _Iter_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Iter_comp_val + { + _Compare _M_comp; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp) + : _M_comp(__comp._M_comp) + { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp) + : _M_comp(std::move(__comp._M_comp)) + { } +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) + { return bool(_M_comp(*__it, __val)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_val<_Compare> + __iter_comp_val(_Compare __comp) + { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_val<_Compare> + __iter_comp_val(_Iter_comp_iter<_Compare> __comp) + { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Val_comp_iter + { + _Compare _M_comp; + + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp) + : _M_comp(__comp._M_comp) + { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp) + : _M_comp(std::move(__comp._M_comp)) + { } +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Value& __val, _Iterator __it) + { return bool(_M_comp(__val, *__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Val_comp_iter<_Compare> + __val_comp_iter(_Compare __comp) + { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + _GLIBCXX20_CONSTEXPR + inline _Val_comp_iter<_Compare> + __val_comp_iter(_Iter_comp_iter<_Compare> __comp) + { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Iter_equals_val + { + _Value& _M_value; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_equals_val(_Value& __value) + : _M_value(__value) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return *__it == _M_value; } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_equals_val<_Value> + __iter_equals_val(_Value& __val) + { return _Iter_equals_val<_Value>(__val); } + + template + struct _Iter_equals_iter + { + _Iterator1 _M_it1; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_equals_iter(_Iterator1 __it1) + : _M_it1(__it1) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator2 __it2) + { return *__it2 == *_M_it1; } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_equals_iter<_Iterator> + __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it) + { return _Iter_equals_iter<_Iterator>(__it); } + + template + struct _Iter_pred + { + _Predicate _M_pred; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_pred(_Predicate __pred) + : _M_pred(_GLIBCXX_MOVE(__pred)) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return bool(_M_pred(*__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_pred<_Predicate> + __pred_iter(_Predicate __pred) + { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); } + + template + struct _Iter_comp_to_val + { + _Compare _M_comp; + _Value& _M_value; + + _GLIBCXX20_CONSTEXPR + _Iter_comp_to_val(_Compare __comp, _Value& __value) + : _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return bool(_M_comp(*__it, _M_value)); } + }; + + template + _Iter_comp_to_val<_Compare, _Value> + _GLIBCXX20_CONSTEXPR + __iter_comp_val(_Compare __comp, _Value &__val) + { + return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val); + } + + template + struct _Iter_comp_to_iter + { + _Compare _M_comp; + _Iterator1 _M_it1; + + _GLIBCXX20_CONSTEXPR + _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) + : _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator2 __it2) + { return bool(_M_comp(*__it2, *_M_it1)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_to_iter<_Compare, _Iterator> + __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it) + { + return _Iter_comp_to_iter<_Compare, _Iterator>( + _GLIBCXX_MOVE(__comp._M_comp), __it); + } + + template + struct _Iter_negate + { + _Predicate _M_pred; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_negate(_Predicate __pred) + : _M_pred(_GLIBCXX_MOVE(__pred)) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return !bool(_M_pred(*__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_negate<_Predicate> + __negate(_Iter_pred<_Predicate> __pred) + { return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); } + +} // namespace __ops +} // namespace __gnu_cxx + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..317517bb2cec978811bfe38cbed5086b00855bb1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@predefined_ops.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..047efa5cf280b78970c325fb2ca415a3378f87d5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h @@ -0,0 +1,287 @@ +// Pointer Traits -*- C++ -*- + +// Copyright (C) 2011-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ptr_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _PTR_TRAITS_H +#define _PTR_TRAITS_H 1 + +#if __cplusplus >= 201103L + +#include + +#if __cplusplus > 201703L +#include +# ifndef __cpp_lib_constexpr_memory +// Defined to a newer value in bits/unique_ptr.h for C++23 +# define __cpp_lib_constexpr_memory 201811L +# endif +namespace __gnu_debug { struct _Safe_iterator_base; } +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + class __undefined; + + // For a specialization `SomeTemplate` the member `type` is T, + // otherwise `type` is `__undefined`. + template + struct __get_first_arg + { using type = __undefined; }; + + template class _SomeTemplate, typename _Tp, + typename... _Types> + struct __get_first_arg<_SomeTemplate<_Tp, _Types...>> + { using type = _Tp; }; + + // For a specialization `SomeTemplate` and a type `U` the member + // `type` is `SomeTemplate`, otherwise there is no member `type`. + template + struct __replace_first_arg + { }; + + template class _SomeTemplate, typename _Up, + typename _Tp, typename... _Types> + struct __replace_first_arg<_SomeTemplate<_Tp, _Types...>, _Up> + { using type = _SomeTemplate<_Up, _Types...>; }; + +#if __cpp_concepts + // When concepts are supported detection of _Ptr::element_type is done + // by a requires-clause, so __ptr_traits_elem_t only needs to do this: + template + using __ptr_traits_elem_t = typename __get_first_arg<_Ptr>::type; +#else + // Detect the element type of a pointer-like type. + template + struct __ptr_traits_elem : __get_first_arg<_Ptr> + { }; + + // Use _Ptr::element_type if is a valid type. + template + struct __ptr_traits_elem<_Ptr, __void_t> + { using type = typename _Ptr::element_type; }; + + template + using __ptr_traits_elem_t = typename __ptr_traits_elem<_Ptr>::type; +#endif + + // Define pointer_traits

::pointer_to. + template::value> + struct __ptr_traits_ptr_to + { + using pointer = _Ptr; + using element_type = _Elt; + + /** + * @brief Obtain a pointer to an object + * @param __r A reference to an object of type `element_type` + * @return `pointer::pointer_to(__e)` + * @pre `pointer::pointer_to(__e)` is a valid expression. + */ + static pointer + pointer_to(element_type& __e) +#if __cpp_lib_concepts + requires requires { + { pointer::pointer_to(__e) } -> convertible_to; + } +#endif + { return pointer::pointer_to(__e); } + }; + + // Do not define pointer_traits

::pointer_to if element type is void. + template + struct __ptr_traits_ptr_to<_Ptr, _Elt, true> + { }; + + // Partial specialization defining pointer_traits::pointer_to(T&). + template + struct __ptr_traits_ptr_to<_Tp*, _Tp, false> + { + using pointer = _Tp*; + using element_type = _Tp; + + /** + * @brief Obtain a pointer to an object + * @param __r A reference to an object of type `element_type` + * @return `addressof(__r)` + */ + static _GLIBCXX20_CONSTEXPR pointer + pointer_to(element_type& __r) noexcept + { return std::addressof(__r); } + }; + + template + struct __ptr_traits_impl : __ptr_traits_ptr_to<_Ptr, _Elt> + { + private: + template + struct __difference { using type = ptrdiff_t; }; + + template +#if __cpp_concepts + requires requires { typename _Tp::difference_type; } + struct __difference<_Tp> +#else + struct __difference<_Tp, __void_t> +#endif + { using type = typename _Tp::difference_type; }; + + template + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template +#if __cpp_concepts + requires requires { typename _Tp::template rebind<_Up>; } + struct __rebind<_Tp, _Up> +#else + struct __rebind<_Tp, _Up, __void_t>> +#endif + { using type = typename _Tp::template rebind<_Up>; }; + + public: + /// The pointer type. + using pointer = _Ptr; + + /// The type pointed to. + using element_type = _Elt; + + /// The type used to represent the difference between two pointers. + using difference_type = typename __difference<_Ptr>::type; + + /// A pointer to a different type. + template + using rebind = typename __rebind<_Ptr, _Up>::type; + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3545. std::pointer_traits should be SFINAE-friendly + template + struct __ptr_traits_impl<_Ptr, __undefined> + { }; + + /** + * @brief Uniform interface to all pointer-like types + * @ingroup pointer_abstractions + * @since C++11 + */ + template + struct pointer_traits : __ptr_traits_impl<_Ptr, __ptr_traits_elem_t<_Ptr>> + { }; + +#if __cpp_concepts + template requires requires { typename _Ptr::element_type; } + struct pointer_traits<_Ptr> + : __ptr_traits_impl<_Ptr, typename _Ptr::element_type> + { }; +#endif + + /** + * @brief Partial specialization for built-in pointers. + * @ingroup pointer_abstractions + * @since C++11 + */ + template + struct pointer_traits<_Tp*> : __ptr_traits_ptr_to<_Tp*, _Tp> + { + /// The pointer type + typedef _Tp* pointer; + /// The type pointed to + typedef _Tp element_type; + /// Type used to represent the difference between two pointers + typedef ptrdiff_t difference_type; + /// A pointer to a different type. + template using rebind = _Up*; + }; + + /// Convenience alias for rebinding pointers. + template + using __ptr_rebind = typename pointer_traits<_Ptr>::template rebind<_Tp>; + + template + constexpr _Tp* + __to_address(_Tp* __ptr) noexcept + { + static_assert(!std::is_function<_Tp>::value, "not a function pointer"); + return __ptr; + } + +#if __cplusplus <= 201703L + template + constexpr typename std::pointer_traits<_Ptr>::element_type* + __to_address(const _Ptr& __ptr) + { return std::__to_address(__ptr.operator->()); } +#else + template + constexpr auto + __to_address(const _Ptr& __ptr) noexcept + -> decltype(std::pointer_traits<_Ptr>::to_address(__ptr)) + { return std::pointer_traits<_Ptr>::to_address(__ptr); } + + template + constexpr auto + __to_address(const _Ptr& __ptr, _None...) noexcept + { + if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>) + return std::__to_address(__ptr.base().operator->()); + else + return std::__to_address(__ptr.operator->()); + } + +#define __cpp_lib_to_address 201711L + + /** + * @brief Obtain address referenced by a pointer to an object + * @param __ptr A pointer to an object + * @return @c __ptr + * @ingroup pointer_abstractions + */ + template + constexpr _Tp* + to_address(_Tp* __ptr) noexcept + { return std::__to_address(__ptr); } + + /** + * @brief Obtain address referenced by a pointer to an object + * @param __ptr A pointer to an object + * @return @c pointer_traits<_Ptr>::to_address(__ptr) if that expression is + well-formed, otherwise @c to_address(__ptr.operator->()) + * @ingroup pointer_abstractions + */ + template + constexpr auto + to_address(const _Ptr& __ptr) noexcept + { return std::__to_address(__ptr); } +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..258379ce1294bd61aec995d0d0c6142ed745cee8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@ptr_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h new file mode 100644 index 0000000000000000000000000000000000000000..fdaaac88c7cd4650230e7f03d52dcb8ed83cea14 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h @@ -0,0 +1,182 @@ +// Helpers for quoted stream manipulators -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/quoted_string.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iomanip} + */ + +#ifndef _GLIBCXX_QUOTED_STRING_H +#define _GLIBCXX_QUOTED_STRING_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail { + /** + * @brief Struct for delimited strings. + */ + template + struct _Quoted_string + { + static_assert(is_reference<_String>::value + || is_pointer<_String>::value, + "String type must be pointer or reference"); + + _Quoted_string(_String __str, _CharT __del, _CharT __esc) + : _M_string(__str), _M_delim{__del}, _M_escape{__esc} + { } + + _Quoted_string& + operator=(_Quoted_string&) = delete; + + _String _M_string; + _CharT _M_delim; + _CharT _M_escape; + }; + +#if __cplusplus >= 201703L + template + struct _Quoted_string, _CharT> + { + _Quoted_string(basic_string_view<_CharT, _Traits> __str, + _CharT __del, _CharT __esc) + : _M_string(__str), _M_delim{__del}, _M_escape{__esc} + { } + + _Quoted_string& + operator=(_Quoted_string&) = delete; + + basic_string_view<_CharT, _Traits> _M_string; + _CharT _M_delim; + _CharT _M_escape; + }; +#endif // C++17 + + /** + * @brief Inserter for quoted strings. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 2344 quoted()'s interaction with padding is unclear + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const _Quoted_string& __str) + { + std::basic_ostringstream<_CharT, _Traits> __ostr; + __ostr << __str._M_delim; + for (const _CharT* __c = __str._M_string; *__c; ++__c) + { + if (*__c == __str._M_delim || *__c == __str._M_escape) + __ostr << __str._M_escape; + __ostr << *__c; + } + __ostr << __str._M_delim; + + return __os << __ostr.str(); + } + + /** + * @brief Inserter for quoted strings. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 2344 quoted()'s interaction with padding is unclear + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const _Quoted_string<_String, _CharT>& __str) + { + std::basic_ostringstream<_CharT, _Traits> __ostr; + __ostr << __str._M_delim; + for (auto __c : __str._M_string) + { + if (__c == __str._M_delim || __c == __str._M_escape) + __ostr << __str._M_escape; + __ostr << __c; + } + __ostr << __str._M_delim; + + return __os << __ostr.str(); + } + + /** + * @brief Extractor for delimited strings. + * The left and right delimiters can be different. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + const _Quoted_string&, + _CharT>& __str) + { + _CharT __c; + __is >> __c; + if (!__is.good()) + return __is; + if (__c != __str._M_delim) + { + __is.unget(); + __is >> __str._M_string; + return __is; + } + __str._M_string.clear(); + std::ios_base::fmtflags __flags + = __is.flags(__is.flags() & ~std::ios_base::skipws); + do + { + __is >> __c; + if (!__is.good()) + break; + if (__c == __str._M_escape) + { + __is >> __c; + if (!__is.good()) + break; + } + else if (__c == __str._M_delim) + break; + __str._M_string += __c; + } + while (true); + __is.setf(__flags); + + return __is; + } + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 +#endif /* _GLIBCXX_QUOTED_STRING_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..863a3800862a948edc889c63c72318ffbfc260b3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@quoted_string.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h new file mode 100644 index 0000000000000000000000000000000000000000..3e6eb9de7d9caa5f5e0ebf29cc80fe35f065367e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h @@ -0,0 +1,6114 @@ +// random number generation -*- C++ -*- + +// Copyright (C) 2009-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _RANDOM_H +#define _RANDOM_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // [26.4] Random number generation + + /** + * @defgroup random Random Number Generation + * @ingroup numerics + * + * A facility for generating random numbers on selected distributions. + * @{ + */ + + // std::uniform_random_bit_generator is defined in + + /** + * @brief A function template for converting the output of a (integral) + * uniform random number generator to a floatng point result in the range + * [0-1). + */ + template + _RealType + generate_canonical(_UniformRandomNumberGenerator& __g); + + /// @cond undocumented + // Implementation-space details. + namespace __detail + { + template + (std::numeric_limits<_UIntType>::digits)> + struct _Shift + { static constexpr _UIntType __value = 0; }; + + template + struct _Shift<_UIntType, __w, true> + { static constexpr _UIntType __value = _UIntType(1) << __w; }; + + template + struct _Select_uint_least_t + { + static_assert(__which < 0, /* needs to be dependent */ + "sorry, would be too much trouble for a slow result"); + }; + + template + struct _Select_uint_least_t<__s, 4> + { using type = unsigned int; }; + + template + struct _Select_uint_least_t<__s, 3> + { using type = unsigned long; }; + + template + struct _Select_uint_least_t<__s, 2> + { using type = unsigned long long; }; + +#if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__ + template + struct _Select_uint_least_t<__s, 1> + { __extension__ using type = unsigned __int128; }; +#endif + + // Assume a != 0, a < m, c < m, x < m. + template= __m - 1), + bool __schrage_ok = __m % __a < __m / __a> + struct _Mod + { + static _Tp + __calc(_Tp __x) + { + using _Tp2 + = typename _Select_uint_least_t::type; + return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); + } + }; + + // Schrage. + template + struct _Mod<_Tp, __m, __a, __c, false, true> + { + static _Tp + __calc(_Tp __x); + }; + + // Special cases: + // - for m == 2^n or m == 0, unsigned integer overflow is safe. + // - a * (m - 1) + c fits in _Tp, there is no overflow. + template + struct _Mod<_Tp, __m, __a, __c, true, __s> + { + static _Tp + __calc(_Tp __x) + { + _Tp __res = __a * __x + __c; + if (__m) + __res %= __m; + return __res; + } + }; + + template + inline _Tp + __mod(_Tp __x) + { + if _GLIBCXX17_CONSTEXPR (__a == 0) + return __c; + else + { + // _Mod must not be instantiated with a == 0 + constexpr _Tp __a1 = __a ? __a : 1; + return _Mod<_Tp, __m, __a1, __c>::__calc(__x); + } + } + + /* + * An adaptor class for converting the output of any Generator into + * the input for a specific Distribution. + */ + template + struct _Adaptor + { + static_assert(std::is_floating_point<_DInputType>::value, + "template argument must be a floating point type"); + + public: + _Adaptor(_Engine& __g) + : _M_g(__g) { } + + _DInputType + min() const + { return _DInputType(0); } + + _DInputType + max() const + { return _DInputType(1); } + + /* + * Converts a value generated by the adapted random number generator + * into a value in the input domain for the dependent random number + * distribution. + */ + _DInputType + operator()() + { + return std::generate_canonical<_DInputType, + std::numeric_limits<_DInputType>::digits, + _Engine>(_M_g); + } + + private: + _Engine& _M_g; + }; + + template + using __seed_seq_generate_t = decltype( + std::declval<_Sseq&>().generate(std::declval(), + std::declval())); + + // Detect whether _Sseq is a valid seed sequence for + // a random number engine _Engine with result type _Res. + template> + using __is_seed_seq = __and_< + __not_, _Engine>>, + is_unsigned, + __not_> + >; + + } // namespace __detail + /// @endcond + + /** + * @addtogroup random_generators Random Number Generators + * @ingroup random + * + * These classes define objects which provide random or pseudorandom + * numbers, either from a discrete or a continuous interval. The + * random number generator supplied as a part of this library are + * all uniform random number generators which provide a sequence of + * random number uniformly distributed over their range. + * + * A number generator is a function object with an operator() that + * takes zero arguments and returns a number. + * + * A compliant random number generator must satisfy the following + * requirements. + * + *
Random Number Generator Requirements
To be documented.
+ * + * @{ + */ + + /** + * @brief A model of a linear congruential random number generator. + * + * A random number generator that produces pseudorandom numbers via + * linear function: + * @f[ + * x_{i+1}\leftarrow(ax_{i} + c) \bmod m + * @f] + * + * The template parameter @p _UIntType must be an unsigned integral type + * large enough to store values up to (__m-1). If the template parameter + * @p __m is 0, the modulus @p __m used is + * std::numeric_limits<_UIntType>::max() plus 1. Otherwise, the template + * parameters @p __a and @p __c must be less than @p __m. + * + * The size of the state is @f$1@f$. + */ + template + class linear_congruential_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(__m == 0u || (__a < __m && __c < __m), + "template argument substituting __m out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, linear_congruential_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + /** The multiplier. */ + static constexpr result_type multiplier = __a; + /** An increment. */ + static constexpr result_type increment = __c; + /** The modulus. */ + static constexpr result_type modulus = __m; + static constexpr result_type default_seed = 1u; + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine with seed 1. + */ + linear_congruential_engine() : linear_congruential_engine(default_seed) + { } + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine with seed @p __s. The default seed value + * is 1. + * + * @param __s The initial seed value. + */ + explicit + linear_congruential_engine(result_type __s) + { seed(__s); } + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + linear_congruential_engine(_Sseq& __q) + { seed(__q); } + + /** + * @brief Reseeds the %linear_congruential_engine random number generator + * engine sequence to the seed @p __s. + * + * @param __s The new seed. + */ + void + seed(result_type __s = default_seed); + + /** + * @brief Reseeds the %linear_congruential_engine random number generator + * engine + * sequence using values from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the smallest possible value in the output range. + * + * The minimum depends on the @p __c parameter: if it is zero, the + * minimum generated must be > 0, otherwise 0 is allowed. + */ + static constexpr result_type + min() + { return __c == 0u ? 1u : 0u; } + + /** + * @brief Gets the largest possible value in the output range. + */ + static constexpr result_type + max() + { return __m - 1u; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next random number in the sequence. + */ + result_type + operator()() + { + _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x); + return _M_x; + } + + /** + * @brief Compares two linear congruential random number generator + * objects of the same type for equality. + * + * @param __lhs A linear congruential random number generator object. + * @param __rhs Another linear congruential random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const linear_congruential_engine& __lhs, + const linear_congruential_engine& __rhs) + { return __lhs._M_x == __rhs._M_x; } + + /** + * @brief Writes the textual representation of the state x(i) of x to + * @p __os. + * + * @param __os The output stream. + * @param __lcr A % linear_congruential_engine random number generator. + * @returns __os. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::linear_congruential_engine<_UIntType1, + __a1, __c1, __m1>& __lcr); + + /** + * @brief Sets the state of the engine by reading its textual + * representation from @p __is. + * + * The textual representation must have been previously written using + * an output stream whose imbued locale and whose type's template + * specialization arguments _CharT and _Traits were the same as those + * of @p __is. + * + * @param __is The input stream. + * @param __lcr A % linear_congruential_engine random number generator. + * @returns __is. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::linear_congruential_engine<_UIntType1, __a1, + __c1, __m1>& __lcr); + + private: + _UIntType _M_x; + }; + + /** + * @brief Compares two linear congruential random number generator + * objects of the same type for inequality. + * + * @param __lhs A linear congruential random number generator object. + * @param __rhs Another linear congruential random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::linear_congruential_engine<_UIntType, __a, + __c, __m>& __lhs, + const std::linear_congruential_engine<_UIntType, __a, + __c, __m>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * A generalized feedback shift register discrete random number generator. + * + * This algorithm avoids multiplication and division and is designed to be + * friendly to a pipelined architecture. If the parameters are chosen + * correctly, this generator will produce numbers with a very long period and + * fairly good apparent entropy, although still not cryptographically strong. + * + * The best way to use this generator is with the predefined mt19937 class. + * + * This algorithm was originally invented by Makoto Matsumoto and + * Takuji Nishimura. + * + * @tparam __w Word size, the number of bits in each element of + * the state vector. + * @tparam __n The degree of recursion. + * @tparam __m The period parameter. + * @tparam __r The separation point bit index. + * @tparam __a The last row of the twist matrix. + * @tparam __u The first right-shift tempering matrix parameter. + * @tparam __d The first right-shift tempering matrix mask. + * @tparam __s The first left-shift tempering matrix parameter. + * @tparam __b The first left-shift tempering matrix mask. + * @tparam __t The second left-shift tempering matrix parameter. + * @tparam __c The second left-shift tempering matrix mask. + * @tparam __l The second right-shift tempering matrix parameter. + * @tparam __f Initialization multiplier. + */ + template + class mersenne_twister_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(1u <= __m && __m <= __n, + "template argument substituting __m out of bounds"); + static_assert(__r <= __w, "template argument substituting " + "__r out of bound"); + static_assert(__u <= __w, "template argument substituting " + "__u out of bound"); + static_assert(__s <= __w, "template argument substituting " + "__s out of bound"); + static_assert(__t <= __w, "template argument substituting " + "__t out of bound"); + static_assert(__l <= __w, "template argument substituting " + "__l out of bound"); + static_assert(__w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bound"); + static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __a out of bound"); + static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __b out of bound"); + static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __c out of bound"); + static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __d out of bound"); + static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __f out of bound"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, mersenne_twister_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + // parameter values + static constexpr size_t word_size = __w; + static constexpr size_t state_size = __n; + static constexpr size_t shift_size = __m; + static constexpr size_t mask_bits = __r; + static constexpr result_type xor_mask = __a; + static constexpr size_t tempering_u = __u; + static constexpr result_type tempering_d = __d; + static constexpr size_t tempering_s = __s; + static constexpr result_type tempering_b = __b; + static constexpr size_t tempering_t = __t; + static constexpr result_type tempering_c = __c; + static constexpr size_t tempering_l = __l; + static constexpr result_type initialization_multiplier = __f; + static constexpr result_type default_seed = 5489u; + + // constructors and member functions + + mersenne_twister_engine() : mersenne_twister_engine(default_seed) { } + + explicit + mersenne_twister_engine(result_type __sd) + { seed(__sd); } + + /** + * @brief Constructs a %mersenne_twister_engine random number generator + * engine seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + mersenne_twister_engine(_Sseq& __q) + { seed(__q); } + + void + seed(result_type __sd = default_seed); + + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the smallest possible value in the output range. + */ + static constexpr result_type + min() + { return 0; } + + /** + * @brief Gets the largest possible value in the output range. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z); + + result_type + operator()(); + + /** + * @brief Compares two % mersenne_twister_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A % mersenne_twister_engine random number generator + * object. + * @param __rhs Another % mersenne_twister_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const mersenne_twister_engine& __lhs, + const mersenne_twister_engine& __rhs) + { return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x) + && __lhs._M_p == __rhs._M_p); } + + /** + * @brief Inserts the current state of a % mersenne_twister_engine + * random number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A % mersenne_twister_engine random number generator + * engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::mersenne_twister_engine<_UIntType1, __w1, __n1, + __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, + __l1, __f1>& __x); + + /** + * @brief Extracts the current state of a % mersenne_twister_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A % mersenne_twister_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::mersenne_twister_engine<_UIntType1, __w1, __n1, __m1, + __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, + __l1, __f1>& __x); + + private: + void _M_gen_rand(); + + _UIntType _M_x[state_size]; + size_t _M_p; + }; + + /** + * @brief Compares two % mersenne_twister_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A % mersenne_twister_engine random number generator + * object. + * @param __rhs Another % mersenne_twister_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __lhs, + const std::mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * @brief The Marsaglia-Zaman generator. + * + * This is a model of a Generalized Fibonacci discrete random number + * generator, sometimes referred to as the SWC generator. + * + * A discrete random number generator that produces pseudorandom + * numbers using: + * @f[ + * x_{i}\leftarrow(x_{i - s} - x_{i - r} - carry_{i-1}) \bmod m + * @f] + * + * The size of the state is @f$r@f$ + * and the maximum period of the generator is @f$(m^r - m^s - 1)@f$. + */ + template + class subtract_with_carry_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(0u < __s && __s < __r, + "0 < s < r"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, subtract_with_carry_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + // parameter values + static constexpr size_t word_size = __w; + static constexpr size_t short_lag = __s; + static constexpr size_t long_lag = __r; + static constexpr result_type default_seed = 19780503u; + + subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) + { } + + /** + * @brief Constructs an explicitly seeded %subtract_with_carry_engine + * random number generator. + */ + explicit + subtract_with_carry_engine(result_type __sd) + { seed(__sd); } + + /** + * @brief Constructs a %subtract_with_carry_engine random number engine + * seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + subtract_with_carry_engine(_Sseq& __q) + { seed(__q); } + + /** + * @brief Seeds the initial state @f$x_0@f$ of the random number + * generator. + * + * N1688[4.19] modifies this as follows. If @p __value == 0, + * sets value to 19780503. In any case, with a linear + * congruential generator lcg(i) having parameters @f$ m_{lcg} = + * 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value + * @f$, sets @f$ x_{-r} \dots x_{-1} @f$ to @f$ lcg(1) \bmod m + * \dots lcg(r) \bmod m @f$ respectively. If @f$ x_{-1} = 0 @f$ + * set carry to 1, otherwise sets carry to 0. + */ + void + seed(result_type __sd = default_seed); + + /** + * @brief Seeds the initial state @f$x_0@f$ of the + * % subtract_with_carry_engine random number generator. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the inclusive minimum value of the range of random + * integers returned by this generator. + */ + static constexpr result_type + min() + { return 0; } + + /** + * @brief Gets the inclusive maximum value of the range of random + * integers returned by this generator. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next random number in the sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two % subtract_with_carry_engine random number + * generator objects of the same type for equality. + * + * @param __lhs A % subtract_with_carry_engine random number generator + * object. + * @param __rhs Another % subtract_with_carry_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const subtract_with_carry_engine& __lhs, + const subtract_with_carry_engine& __rhs) + { return (std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x) + && __lhs._M_carry == __rhs._M_carry + && __lhs._M_p == __rhs._M_p); } + + /** + * @brief Inserts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A % subtract_with_carry_engine random number generator + * engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::subtract_with_carry_engine<_UIntType1, __w1, + __s1, __r1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A % subtract_with_carry_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::subtract_with_carry_engine<_UIntType1, __w1, + __s1, __r1>& __x); + + private: + /// The state of the generator. This is a ring buffer. + _UIntType _M_x[long_lag]; + _UIntType _M_carry; ///< The carry + size_t _M_p; ///< Current index of x(i - r). + }; + + /** + * @brief Compares two % subtract_with_carry_engine random number + * generator objects of the same type for inequality. + * + * @param __lhs A % subtract_with_carry_engine random number generator + * object. + * @param __rhs Another % subtract_with_carry_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::subtract_with_carry_engine<_UIntType, __w, + __s, __r>& __lhs, + const std::subtract_with_carry_engine<_UIntType, __w, + __s, __r>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * Produces random numbers from some base engine by discarding blocks of + * data. + * + * 0 <= @p __r <= @p __p + */ + template + class discard_block_engine + { + static_assert(1 <= __r && __r <= __p, + "template argument substituting __r out of bounds"); + + public: + /** The type of the generated random value. */ + typedef typename _RandomNumberEngine::result_type result_type; + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, discard_block_engine, result_type>::value>::type; + + // parameter values + static constexpr size_t block_size = __p; + static constexpr size_t used_block = __r; + + /** + * @brief Constructs a default %discard_block_engine engine. + * + * The underlying engine is default constructed as well. + */ + discard_block_engine() + : _M_b(), _M_n(0) { } + + /** + * @brief Copy constructs a %discard_block_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + discard_block_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng), _M_n(0) { } + + /** + * @brief Move constructs a %discard_block_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + discard_block_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)), _M_n(0) { } + + /** + * @brief Seed constructs a %discard_block_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + discard_block_engine(result_type __s) + : _M_b(__s), _M_n(0) { } + + /** + * @brief Generator construct a %discard_block_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + discard_block_engine(_Sseq& __q) + : _M_b(__q), _M_n(0) + { } + + /** + * @brief Reseeds the %discard_block_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed() + { + _M_b.seed(); + _M_n = 0; + } + + /** + * @brief Reseeds the %discard_block_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed(result_type __s) + { + _M_b.seed(__s); + _M_n = 0; + } + + /** + * @brief Reseeds the %discard_block_engine object with the given seed + * sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { + _M_b.seed(__q); + _M_n = 0; + } + + /** + * @brief Gets a const reference to the underlying generator engine + * object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * @brief Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return _RandomNumberEngine::min(); } + + /** + * @brief Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return _RandomNumberEngine::max(); } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two %discard_block_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A %discard_block_engine random number generator object. + * @param __rhs Another %discard_block_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const discard_block_engine& __lhs, + const discard_block_engine& __rhs) + { return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; } + + /** + * @brief Inserts the current state of a %discard_block_engine random + * number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A %discard_block_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::discard_block_engine<_RandomNumberEngine1, + __p1, __r1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %discard_block_engine random number generator engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::discard_block_engine<_RandomNumberEngine1, + __p1, __r1>& __x); + + private: + _RandomNumberEngine _M_b; + size_t _M_n; + }; + + /** + * @brief Compares two %discard_block_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A %discard_block_engine random number generator object. + * @param __rhs Another %discard_block_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::discard_block_engine<_RandomNumberEngine, __p, + __r>& __lhs, + const std::discard_block_engine<_RandomNumberEngine, __p, + __r>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * Produces random numbers by combining random numbers from some base + * engine to produce random numbers with a specified number of bits @p __w. + */ + template + class independent_bits_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, independent_bits_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + /** + * @brief Constructs a default %independent_bits_engine engine. + * + * The underlying engine is default constructed as well. + */ + independent_bits_engine() + : _M_b() { } + + /** + * @brief Copy constructs a %independent_bits_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + independent_bits_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng) { } + + /** + * @brief Move constructs a %independent_bits_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + independent_bits_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)) { } + + /** + * @brief Seed constructs a %independent_bits_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + independent_bits_engine(result_type __s) + : _M_b(__s) { } + + /** + * @brief Generator construct a %independent_bits_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + independent_bits_engine(_Sseq& __q) + : _M_b(__q) + { } + + /** + * @brief Reseeds the %independent_bits_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed() + { _M_b.seed(); } + + /** + * @brief Reseeds the %independent_bits_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed(result_type __s) + { _M_b.seed(__s); } + + /** + * @brief Reseeds the %independent_bits_engine object with the given + * seed sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { _M_b.seed(__q); } + + /** + * @brief Gets a const reference to the underlying generator engine + * object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * @brief Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return 0U; } + + /** + * @brief Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two %independent_bits_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A %independent_bits_engine random number generator + * object. + * @param __rhs Another %independent_bits_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const independent_bits_engine& __lhs, + const independent_bits_engine& __rhs) + { return __lhs._M_b == __rhs._M_b; } + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %independent_bits_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::independent_bits_engine<_RandomNumberEngine, + __w, _UIntType>& __x) + { + __is >> __x._M_b; + return __is; + } + + private: + _RandomNumberEngine _M_b; + }; + + /** + * @brief Compares two %independent_bits_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A %independent_bits_engine random number generator + * object. + * @param __rhs Another %independent_bits_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::independent_bits_engine<_RandomNumberEngine, __w, + _UIntType>& __lhs, + const std::independent_bits_engine<_RandomNumberEngine, __w, + _UIntType>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Inserts the current state of a %independent_bits_engine random + * number generator engine @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %independent_bits_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::independent_bits_engine<_RandomNumberEngine, + __w, _UIntType>& __x) + { + __os << __x.base(); + return __os; + } + + + /** + * @brief Produces random numbers by reordering random numbers from some + * base engine. + * + * The values from the base engine are stored in a sequence of size @p __k + * and shuffled by an algorithm that depends on those values. + */ + template + class shuffle_order_engine + { + static_assert(1u <= __k, "template argument substituting " + "__k out of bound"); + + public: + /** The type of the generated random value. */ + typedef typename _RandomNumberEngine::result_type result_type; + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, shuffle_order_engine, result_type>::value>::type; + + static constexpr size_t table_size = __k; + + /** + * @brief Constructs a default %shuffle_order_engine engine. + * + * The underlying engine is default constructed as well. + */ + shuffle_order_engine() + : _M_b() + { _M_initialize(); } + + /** + * @brief Copy constructs a %shuffle_order_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + shuffle_order_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng) + { _M_initialize(); } + + /** + * @brief Move constructs a %shuffle_order_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + shuffle_order_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)) + { _M_initialize(); } + + /** + * @brief Seed constructs a %shuffle_order_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + shuffle_order_engine(result_type __s) + : _M_b(__s) + { _M_initialize(); } + + /** + * @brief Generator construct a %shuffle_order_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + shuffle_order_engine(_Sseq& __q) + : _M_b(__q) + { _M_initialize(); } + + /** + * @brief Reseeds the %shuffle_order_engine object with the default seed + for the underlying base class generator engine. + */ + void + seed() + { + _M_b.seed(); + _M_initialize(); + } + + /** + * @brief Reseeds the %shuffle_order_engine object with the default seed + * for the underlying base class generator engine. + */ + void + seed(result_type __s) + { + _M_b.seed(__s); + _M_initialize(); + } + + /** + * @brief Reseeds the %shuffle_order_engine object with the given seed + * sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { + _M_b.seed(__q); + _M_initialize(); + } + + /** + * Gets a const reference to the underlying generator engine object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return _RandomNumberEngine::min(); } + + /** + * Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return _RandomNumberEngine::max(); } + + /** + * Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * Compares two %shuffle_order_engine random number generator objects + * of the same type for equality. + * + * @param __lhs A %shuffle_order_engine random number generator object. + * @param __rhs Another %shuffle_order_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const shuffle_order_engine& __lhs, + const shuffle_order_engine& __rhs) + { return (__lhs._M_b == __rhs._M_b + && std::equal(__lhs._M_v, __lhs._M_v + __k, __rhs._M_v) + && __lhs._M_y == __rhs._M_y); } + + /** + * @brief Inserts the current state of a %shuffle_order_engine random + * number generator engine @p __x into the output stream + @p __os. + * + * @param __os An output stream. + * @param __x A %shuffle_order_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::shuffle_order_engine<_RandomNumberEngine1, + __k1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %shuffle_order_engine random number generator engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::shuffle_order_engine<_RandomNumberEngine1, __k1>& __x); + + private: + void _M_initialize() + { + for (size_t __i = 0; __i < __k; ++__i) + _M_v[__i] = _M_b(); + _M_y = _M_b(); + } + + _RandomNumberEngine _M_b; + result_type _M_v[__k]; + result_type _M_y; + }; + + /** + * Compares two %shuffle_order_engine random number generator objects + * of the same type for inequality. + * + * @param __lhs A %shuffle_order_engine random number generator object. + * @param __rhs Another %shuffle_order_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::shuffle_order_engine<_RandomNumberEngine, + __k>& __lhs, + const std::shuffle_order_engine<_RandomNumberEngine, + __k>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * The classic Minimum Standard rand0 of Lewis, Goodman, and Miller. + */ + typedef linear_congruential_engine + minstd_rand0; + + /** + * An alternative LCR (Lehmer Generator function). + */ + typedef linear_congruential_engine + minstd_rand; + + /** + * The classic Mersenne Twister. + * + * Reference: + * M. Matsumoto and T. Nishimura, Mersenne Twister: A 623-Dimensionally + * Equidistributed Uniform Pseudo-Random Number Generator, ACM Transactions + * on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + */ + typedef mersenne_twister_engine< + uint_fast32_t, + 32, 624, 397, 31, + 0x9908b0dfUL, 11, + 0xffffffffUL, 7, + 0x9d2c5680UL, 15, + 0xefc60000UL, 18, 1812433253UL> mt19937; + + /** + * An alternative Mersenne Twister. + */ + typedef mersenne_twister_engine< + uint_fast64_t, + 64, 312, 156, 31, + 0xb5026f5aa96619e9ULL, 29, + 0x5555555555555555ULL, 17, + 0x71d67fffeda60000ULL, 37, + 0xfff7eee000000000ULL, 43, + 6364136223846793005ULL> mt19937_64; + + typedef subtract_with_carry_engine + ranlux24_base; + + typedef subtract_with_carry_engine + ranlux48_base; + + typedef discard_block_engine ranlux24; + + typedef discard_block_engine ranlux48; + + typedef shuffle_order_engine knuth_b; + + typedef minstd_rand0 default_random_engine; + + /** + * A standard interface to a platform-specific non-deterministic + * random number generator (if any are available). + */ + class random_device + { + public: + /** The type of the generated random value. */ + typedef unsigned int result_type; + + // constructors, destructors and member functions + + random_device() { _M_init("default"); } + + explicit + random_device(const std::string& __token) { _M_init(__token); } + +#if defined _GLIBCXX_USE_DEV_RANDOM + ~random_device() + { _M_fini(); } +#endif + + static constexpr result_type + min() + { return std::numeric_limits::min(); } + + static constexpr result_type + max() + { return std::numeric_limits::max(); } + + double + entropy() const noexcept + { +#ifdef _GLIBCXX_USE_DEV_RANDOM + return this->_M_getentropy(); +#else + return 0.0; +#endif + } + + result_type + operator()() + { return this->_M_getval(); } + + // No copy functions. + random_device(const random_device&) = delete; + void operator=(const random_device&) = delete; + + private: + + void _M_init(const std::string& __token); + void _M_init_pretr1(const std::string& __token); + void _M_fini(); + + result_type _M_getval(); + result_type _M_getval_pretr1(); + double _M_getentropy() const noexcept; + + void _M_init(const char*, size_t); // not exported from the shared library + + __extension__ union + { + struct + { + void* _M_file; + result_type (*_M_func)(void*); + int _M_fd; + }; + mt19937 _M_mt; + }; + }; + + /// @} group random_generators + + /** + * @addtogroup random_distributions Random Number Distributions + * @ingroup random + * @{ + */ + + /** + * @addtogroup random_distributions_uniform Uniform Distributions + * @ingroup random_distributions + * @{ + */ + + // std::uniform_int_distribution is defined in + + /** + * @brief Return true if two uniform integer distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::uniform_int_distribution<_IntType>& __d1, + const std::uniform_int_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %uniform_int_distribution random number + * distribution @p __x into the output stream @p os. + * + * @param __os An output stream. + * @param __x A %uniform_int_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::uniform_int_distribution<_IntType>&); + + /** + * @brief Extracts a %uniform_int_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %uniform_int_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::uniform_int_distribution<_IntType>&); + + + /** + * @brief Uniform continuous distribution for random numbers. + * + * A continuous random distribution on the range [min, max) with equal + * probability throughout the range. The URNG should be real-valued and + * deliver number in the range [0, 1). + */ + template + class uniform_real_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef uniform_real_distribution<_RealType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1)) + : _M_a(__a), _M_b(__b) + { + __glibcxx_assert(_M_a <= _M_b); + } + + result_type + a() const + { return _M_a; } + + result_type + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + public: + /** + * @brief Constructs a uniform_real_distribution object. + * + * The lower bound is set to 0.0 and the upper bound to 1.0 + */ + uniform_real_distribution() : uniform_real_distribution(0.0) { } + + /** + * @brief Constructs a uniform_real_distribution object. + * + * @param __a [IN] The lower bound of the distribution. + * @param __b [IN] The upper bound of the distribution. + */ + explicit + uniform_real_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + uniform_real_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the uniform real distribution. + */ + void + reset() { } + + result_type + a() const + { return _M_param.a(); } + + result_type + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the inclusive lower bound of the distribution range. + */ + result_type + min() const + { return this->a(); } + + /** + * @brief Returns the inclusive upper bound of the distribution range. + */ + result_type + max() const + { return this->b(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return (__aurng() * (__p.b() - __p.a())) + __p.a(); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two uniform real distributions have + * the same parameters. + */ + friend bool + operator==(const uniform_real_distribution& __d1, + const uniform_real_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two uniform real distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::uniform_real_distribution<_IntType>& __d1, + const std::uniform_real_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %uniform_real_distribution random number + * distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %uniform_real_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::uniform_real_distribution<_RealType>&); + + /** + * @brief Extracts a %uniform_real_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %uniform_real_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::uniform_real_distribution<_RealType>&); + + /// @} group random_distributions_uniform + + /** + * @addtogroup random_distributions_normal Normal Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A normal continuous distribution for random numbers. + * + * The formula for the normal probability density function is + * @f[ + * p(x|\mu,\sigma) = \frac{1}{\sigma \sqrt{2 \pi}} + * e^{- \frac{{x - \mu}^ {2}}{2 \sigma ^ {2}} } + * @f] + */ + template + class normal_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef normal_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __mean, _RealType __stddev = _RealType(1)) + : _M_mean(__mean), _M_stddev(__stddev) + { + __glibcxx_assert(_M_stddev > _RealType(0)); + } + + _RealType + mean() const + { return _M_mean; } + + _RealType + stddev() const + { return _M_stddev; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return (__p1._M_mean == __p2._M_mean + && __p1._M_stddev == __p2._M_stddev); } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_mean; + _RealType _M_stddev; + }; + + public: + normal_distribution() : normal_distribution(0.0) { } + + /** + * Constructs a normal distribution with parameters @f$mean@f$ and + * standard deviation. + */ + explicit + normal_distribution(result_type __mean, + result_type __stddev = result_type(1)) + : _M_param(__mean, __stddev) + { } + + explicit + normal_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_saved_available = false; } + + /** + * @brief Returns the mean of the distribution. + */ + _RealType + mean() const + { return _M_param.mean(); } + + /** + * @brief Returns the standard deviation of the distribution. + */ + _RealType + stddev() const + { return _M_param.stddev(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two normal distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + template + friend bool + operator==(const std::normal_distribution<_RealType1>& __d1, + const std::normal_distribution<_RealType1>& __d2); + + /** + * @brief Inserts a %normal_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %normal_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::normal_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %normal_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %normal_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::normal_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + result_type _M_saved = 0; + bool _M_saved_available = false; + }; + + /** + * @brief Return true if two normal distributions are different. + */ + template + inline bool + operator!=(const std::normal_distribution<_RealType>& __d1, + const std::normal_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A lognormal_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|m,s) = \frac{1}{sx\sqrt{2\pi}} + * \exp{-\frac{(\ln{x} - m)^2}{2s^2}} + * @f] + */ + template + class lognormal_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef lognormal_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __m, _RealType __s = _RealType(1)) + : _M_m(__m), _M_s(__s) + { } + + _RealType + m() const + { return _M_m; } + + _RealType + s() const + { return _M_s; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_m == __p2._M_m && __p1._M_s == __p2._M_s; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_m; + _RealType _M_s; + }; + + lognormal_distribution() : lognormal_distribution(0.0) { } + + explicit + lognormal_distribution(_RealType __m, _RealType __s = _RealType(1)) + : _M_param(__m, __s), _M_nd() + { } + + explicit + lognormal_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * + */ + _RealType + m() const + { return _M_param.m(); } + + _RealType + s() const + { return _M_param.s(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two lognormal distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const lognormal_distribution& __d1, + const lognormal_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd); } + + /** + * @brief Inserts a %lognormal_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %lognormal_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::lognormal_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %lognormal_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %lognormal_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::lognormal_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two lognormal distributions are different. + */ + template + inline bool + operator!=(const std::lognormal_distribution<_RealType>& __d1, + const std::lognormal_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A gamma continuous distribution for random numbers. + * + * The formula for the gamma probability density function is: + * @f[ + * p(x|\alpha,\beta) = \frac{1}{\beta\Gamma(\alpha)} + * (x/\beta)^{\alpha - 1} e^{-x/\beta} + * @f] + */ + template + class gamma_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef gamma_distribution<_RealType> distribution_type; + friend class gamma_distribution<_RealType>; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1)) + : _M_alpha(__alpha_val), _M_beta(__beta_val) + { + __glibcxx_assert(_M_alpha > _RealType(0)); + _M_initialize(); + } + + _RealType + alpha() const + { return _M_alpha; } + + _RealType + beta() const + { return _M_beta; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return (__p1._M_alpha == __p2._M_alpha + && __p1._M_beta == __p2._M_beta); } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + _RealType _M_alpha; + _RealType _M_beta; + + _RealType _M_malpha, _M_a2; + }; + + public: + /** + * @brief Constructs a gamma distribution with parameters 1 and 1. + */ + gamma_distribution() : gamma_distribution(1.0) { } + + /** + * @brief Constructs a gamma distribution with parameters + * @f$\alpha@f$ and @f$\beta@f$. + */ + explicit + gamma_distribution(_RealType __alpha_val, + _RealType __beta_val = _RealType(1)) + : _M_param(__alpha_val, __beta_val), _M_nd() + { } + + explicit + gamma_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the @f$\alpha@f$ of the distribution. + */ + _RealType + alpha() const + { return _M_param.alpha(); } + + /** + * @brief Returns the @f$\beta@f$ of the distribution. + */ + _RealType + beta() const + { return _M_param.beta(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two gamma distributions have the same + * parameters and the sequences that would be generated + * are equal. + */ + friend bool + operator==(const gamma_distribution& __d1, + const gamma_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd); } + + /** + * @brief Inserts a %gamma_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %gamma_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::gamma_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %gamma_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %gamma_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::gamma_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two gamma distributions are different. + */ + template + inline bool + operator!=(const std::gamma_distribution<_RealType>& __d1, + const std::gamma_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A chi_squared_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f$p(x|n) = \frac{x^{(n/2) - 1}e^{-x/2}}{\Gamma(n/2) 2^{n/2}}@f$ + */ + template + class chi_squared_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef chi_squared_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __n) + : _M_n(__n) + { } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_n; + }; + + chi_squared_distribution() : chi_squared_distribution(1) { } + + explicit + chi_squared_distribution(_RealType __n) + : _M_param(__n), _M_gd(__n / 2) + { } + + explicit + chi_squared_distribution(const param_type& __p) + : _M_param(__p), _M_gd(__p.n() / 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_gd.reset(); } + + /** + * + */ + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { + _M_param = __param; + typedef typename std::gamma_distribution::param_type + param_type; + _M_gd.param(param_type{__param.n() / 2}); + } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return 2 * _M_gd(__urng); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + return 2 * _M_gd(__urng, param_type(__p.n() / 2)); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { typename std::gamma_distribution::param_type + __p2(__p.n() / 2); + this->__generate_impl(__f, __t, __urng, __p2); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { typename std::gamma_distribution::param_type + __p2(__p.n() / 2); + this->__generate_impl(__f, __t, __urng, __p2); } + + /** + * @brief Return true if two Chi-squared distributions have + * the same parameters and the sequences that would be + * generated are equal. + */ + friend bool + operator==(const chi_squared_distribution& __d1, + const chi_squared_distribution& __d2) + { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; } + + /** + * @brief Inserts a %chi_squared_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %chi_squared_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::chi_squared_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %chi_squared_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %chi_squared_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::chi_squared_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const typename + std::gamma_distribution::param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two Chi-squared distributions are different. + */ + template + inline bool + operator!=(const std::chi_squared_distribution<_RealType>& __d1, + const std::chi_squared_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A cauchy_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f$p(x|a,b) = (\pi b (1 + (\frac{x-a}{b})^2))^{-1}@f$ + */ + template + class cauchy_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef cauchy_distribution<_RealType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + cauchy_distribution() : cauchy_distribution(0.0) { } + + explicit + cauchy_distribution(_RealType __a, _RealType __b = 1.0) + : _M_param(__a, __b) + { } + + explicit + cauchy_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * + */ + _RealType + a() const + { return _M_param.a(); } + + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Cauchy distributions have + * the same parameters. + */ + friend bool + operator==(const cauchy_distribution& __d1, + const cauchy_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Cauchy distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::cauchy_distribution<_RealType>& __d1, + const std::cauchy_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %cauchy_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %cauchy_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::cauchy_distribution<_RealType>& __x); + + /** + * @brief Extracts a %cauchy_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %cauchy_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::cauchy_distribution<_RealType>& __x); + + + /** + * @brief A fisher_f_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|m,n) = \frac{\Gamma((m+n)/2)}{\Gamma(m/2)\Gamma(n/2)} + * (\frac{m}{n})^{m/2} x^{(m/2)-1} + * (1 + \frac{mx}{n})^{-(m+n)/2} + * @f] + */ + template + class fisher_f_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef fisher_f_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __m, _RealType __n = _RealType(1)) + : _M_m(__m), _M_n(__n) + { } + + _RealType + m() const + { return _M_m; } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_m == __p2._M_m && __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_m; + _RealType _M_n; + }; + + fisher_f_distribution() : fisher_f_distribution(1.0) { } + + explicit + fisher_f_distribution(_RealType __m, + _RealType __n = _RealType(1)) + : _M_param(__m, __n), _M_gd_x(__m / 2), _M_gd_y(__n / 2) + { } + + explicit + fisher_f_distribution(const param_type& __p) + : _M_param(__p), _M_gd_x(__p.m() / 2), _M_gd_y(__p.n() / 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { + _M_gd_x.reset(); + _M_gd_y.reset(); + } + + /** + * + */ + _RealType + m() const + { return _M_param.m(); } + + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return (_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + return ((_M_gd_x(__urng, param_type(__p.m() / 2)) * n()) + / (_M_gd_y(__urng, param_type(__p.n() / 2)) * m())); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Fisher f distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const fisher_f_distribution& __d1, + const fisher_f_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_gd_x == __d2._M_gd_x + && __d1._M_gd_y == __d2._M_gd_y); } + + /** + * @brief Inserts a %fisher_f_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %fisher_f_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::fisher_f_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %fisher_f_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %fisher_f_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::fisher_f_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd_x, _M_gd_y; + }; + + /** + * @brief Return true if two Fisher f distributions are different. + */ + template + inline bool + operator!=(const std::fisher_f_distribution<_RealType>& __d1, + const std::fisher_f_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief A student_t_distribution random number distribution. + * + * The formula for the normal probability mass function is: + * @f[ + * p(x|n) = \frac{1}{\sqrt(n\pi)} \frac{\Gamma((n+1)/2)}{\Gamma(n/2)} + * (1 + \frac{x^2}{n}) ^{-(n+1)/2} + * @f] + */ + template + class student_t_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef student_t_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __n) + : _M_n(__n) + { } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_n; + }; + + student_t_distribution() : student_t_distribution(1.0) { } + + explicit + student_t_distribution(_RealType __n) + : _M_param(__n), _M_nd(), _M_gd(__n / 2, 2) + { } + + explicit + student_t_distribution(const param_type& __p) + : _M_param(__p), _M_nd(), _M_gd(__p.n() / 2, 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { + _M_nd.reset(); + _M_gd.reset(); + } + + /** + * + */ + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + + const result_type __g = _M_gd(__urng, param_type(__p.n() / 2, 2)); + return _M_nd(__urng) * std::sqrt(__p.n() / __g); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Student t distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const student_t_distribution& __d1, + const student_t_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); } + + /** + * @brief Inserts a %student_t_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %student_t_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::student_t_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %student_t_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %student_t_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::student_t_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two Student t distributions are different. + */ + template + inline bool + operator!=(const std::student_t_distribution<_RealType>& __d1, + const std::student_t_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_normal + + /** + * @addtogroup random_distributions_bernoulli Bernoulli Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A Bernoulli random number distribution. + * + * Generates a sequence of true and false values with likelihood @f$p@f$ + * that true will come up and @f$(1 - p)@f$ that false will appear. + */ + class bernoulli_distribution + { + public: + /** The type of the range of the distribution. */ + typedef bool result_type; + + /** Parameter type. */ + struct param_type + { + typedef bernoulli_distribution distribution_type; + + param_type() : param_type(0.5) { } + + explicit + param_type(double __p) + : _M_p(__p) + { + __glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0)); + } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + double _M_p; + }; + + public: + /** + * @brief Constructs a Bernoulli distribution with likelihood 0.5. + */ + bernoulli_distribution() : bernoulli_distribution(0.5) { } + + /** + * @brief Constructs a Bernoulli distribution with likelihood @p p. + * + * @param __p [IN] The likelihood of a true result being returned. + * Must be in the interval @f$[0, 1]@f$. + */ + explicit + bernoulli_distribution(double __p) + : _M_param(__p) + { } + + explicit + bernoulli_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for a Bernoulli distribution. + */ + void + reset() { } + + /** + * @brief Returns the @p p parameter of the distribution. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::min(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + if ((__aurng() - __aurng.min()) + < __p.p() * (__aurng.max() - __aurng.min())) + return true; + return false; + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Bernoulli distributions have + * the same parameters. + */ + friend bool + operator==(const bernoulli_distribution& __d1, + const bernoulli_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Bernoulli distributions have + * different parameters. + */ + inline bool + operator!=(const std::bernoulli_distribution& __d1, + const std::bernoulli_distribution& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %bernoulli_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %bernoulli_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::bernoulli_distribution& __x); + + /** + * @brief Extracts a %bernoulli_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %bernoulli_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + inline std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::bernoulli_distribution& __x) + { + double __p; + if (__is >> __p) + __x.param(bernoulli_distribution::param_type(__p)); + return __is; + } + + + /** + * @brief A discrete binomial random number distribution. + * + * The formula for the binomial probability density function is + * @f$p(i|t,p) = \binom{t}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$ + * and @f$p@f$ are the parameters of the distribution. + */ + template + class binomial_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef binomial_distribution<_IntType> distribution_type; + friend class binomial_distribution<_IntType>; + + param_type() : param_type(1) { } + + explicit + param_type(_IntType __t, double __p = 0.5) + : _M_t(__t), _M_p(__p) + { + __glibcxx_assert((_M_t >= _IntType(0)) + && (_M_p >= 0.0) + && (_M_p <= 1.0)); + _M_initialize(); + } + + _IntType + t() const + { return _M_t; } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_t == __p2._M_t && __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + _IntType _M_t; + double _M_p; + + double _M_q; +#if _GLIBCXX_USE_C99_MATH_TR1 + double _M_d1, _M_d2, _M_s1, _M_s2, _M_c, + _M_a1, _M_a123, _M_s, _M_lf, _M_lp1p; +#endif + bool _M_easy; + }; + + // constructors and member functions + + binomial_distribution() : binomial_distribution(1) { } + + explicit + binomial_distribution(_IntType __t, double __p = 0.5) + : _M_param(__t, __p), _M_nd() + { } + + explicit + binomial_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the distribution @p t parameter. + */ + _IntType + t() const + { return _M_param.t(); } + + /** + * @brief Returns the distribution @p p parameter. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return _M_param.t(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two binomial distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const binomial_distribution& __d1, + const binomial_distribution& __d2) +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; } +#else + { return __d1._M_param == __d2._M_param; } +#endif + + /** + * @brief Inserts a %binomial_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %binomial_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::binomial_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %binomial_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %binomial_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::binomial_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + result_type + _M_waiting(_UniformRandomNumberGenerator& __urng, + _IntType __t, double __q); + + param_type _M_param; + + // NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined. + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two binomial distributions are different. + */ + template + inline bool + operator!=(const std::binomial_distribution<_IntType>& __d1, + const std::binomial_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A discrete geometric random number distribution. + * + * The formula for the geometric probability density function is + * @f$p(i|p) = p(1 - p)^{i}@f$ where @f$p@f$ is the parameter of the + * distribution. + */ + template + class geometric_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef geometric_distribution<_IntType> distribution_type; + friend class geometric_distribution<_IntType>; + + param_type() : param_type(0.5) { } + + explicit + param_type(double __p) + : _M_p(__p) + { + __glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0)); + _M_initialize(); + } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize() + { _M_log_1_p = std::log(1.0 - _M_p); } + + double _M_p; + + double _M_log_1_p; + }; + + // constructors and member functions + + geometric_distribution() : geometric_distribution(0.5) { } + + explicit + geometric_distribution(double __p) + : _M_param(__p) + { } + + explicit + geometric_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the geometric distribution. + */ + void + reset() { } + + /** + * @brief Returns the distribution parameter @p p. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two geometric distributions have + * the same parameters. + */ + friend bool + operator==(const geometric_distribution& __d1, + const geometric_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two geometric distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::geometric_distribution<_IntType>& __d1, + const std::geometric_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %geometric_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %geometric_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::geometric_distribution<_IntType>& __x); + + /** + * @brief Extracts a %geometric_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %geometric_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::geometric_distribution<_IntType>& __x); + + + /** + * @brief A negative_binomial_distribution random number distribution. + * + * The formula for the negative binomial probability mass function is + * @f$p(i) = \binom{n}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$ + * and @f$p@f$ are the parameters of the distribution. + */ + template + class negative_binomial_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef negative_binomial_distribution<_IntType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_IntType __k, double __p = 0.5) + : _M_k(__k), _M_p(__p) + { + __glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0)); + } + + _IntType + k() const + { return _M_k; } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_k == __p2._M_k && __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _IntType _M_k; + double _M_p; + }; + + negative_binomial_distribution() : negative_binomial_distribution(1) { } + + explicit + negative_binomial_distribution(_IntType __k, double __p = 0.5) + : _M_param(__k, __p), _M_gd(__k, (1.0 - __p) / __p) + { } + + explicit + negative_binomial_distribution(const param_type& __p) + : _M_param(__p), _M_gd(__p.k(), (1.0 - __p.p()) / __p.p()) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_gd.reset(); } + + /** + * @brief Return the @f$k@f$ parameter of the distribution. + */ + _IntType + k() const + { return _M_param.k(); } + + /** + * @brief Return the @f$p@f$ parameter of the distribution. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng); + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two negative binomial distributions have + * the same parameters and the sequences that would be + * generated are equal. + */ + friend bool + operator==(const negative_binomial_distribution& __d1, + const negative_binomial_distribution& __d2) + { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; } + + /** + * @brief Inserts a %negative_binomial_distribution random + * number distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %negative_binomial_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::negative_binomial_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %negative_binomial_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %negative_binomial_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::negative_binomial_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two negative binomial distributions are different. + */ + template + inline bool + operator!=(const std::negative_binomial_distribution<_IntType>& __d1, + const std::negative_binomial_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_bernoulli + + /** + * @addtogroup random_distributions_poisson Poisson Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A discrete Poisson random number distribution. + * + * The formula for the Poisson probability density function is + * @f$p(i|\mu) = \frac{\mu^i}{i!} e^{-\mu}@f$ where @f$\mu@f$ is the + * parameter of the distribution. + */ + template + class poisson_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef poisson_distribution<_IntType> distribution_type; + friend class poisson_distribution<_IntType>; + + param_type() : param_type(1.0) { } + + explicit + param_type(double __mean) + : _M_mean(__mean) + { + __glibcxx_assert(_M_mean > 0.0); + _M_initialize(); + } + + double + mean() const + { return _M_mean; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_mean == __p2._M_mean; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + // Hosts either log(mean) or the threshold of the simple method. + void + _M_initialize(); + + double _M_mean; + + double _M_lm_thr; +#if _GLIBCXX_USE_C99_MATH_TR1 + double _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb; +#endif + }; + + // constructors and member functions + + poisson_distribution() : poisson_distribution(1.0) { } + + explicit + poisson_distribution(double __mean) + : _M_param(__mean), _M_nd() + { } + + explicit + poisson_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the distribution parameter @p mean. + */ + double + mean() const + { return _M_param.mean(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Poisson distributions have the same + * parameters and the sequences that would be generated + * are equal. + */ + friend bool + operator==(const poisson_distribution& __d1, + const poisson_distribution& __d2) +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; } +#else + { return __d1._M_param == __d2._M_param; } +#endif + + /** + * @brief Inserts a %poisson_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %poisson_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::poisson_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %poisson_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %poisson_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::poisson_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + // NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined. + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two Poisson distributions are different. + */ + template + inline bool + operator!=(const std::poisson_distribution<_IntType>& __d1, + const std::poisson_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief An exponential continuous distribution for random numbers. + * + * The formula for the exponential probability density function is + * @f$p(x|\lambda) = \lambda e^{-\lambda x}@f$. + * + * + * + * + * + * + * + * + *
Distribution Statistics
Mean@f$\frac{1}{\lambda}@f$
Median@f$\frac{\ln 2}{\lambda}@f$
Mode@f$zero@f$
Range@f$[0, \infty]@f$
Standard Deviation@f$\frac{1}{\lambda}@f$
+ */ + template + class exponential_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef exponential_distribution<_RealType> distribution_type; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __lambda) + : _M_lambda(__lambda) + { + __glibcxx_assert(_M_lambda > _RealType(0)); + } + + _RealType + lambda() const + { return _M_lambda; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_lambda == __p2._M_lambda; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_lambda; + }; + + public: + /** + * @brief Constructs an exponential distribution with inverse scale + * parameter 1.0 + */ + exponential_distribution() : exponential_distribution(1.0) { } + + /** + * @brief Constructs an exponential distribution with inverse scale + * parameter @f$\lambda@f$. + */ + explicit + exponential_distribution(_RealType __lambda) + : _M_param(__lambda) + { } + + explicit + exponential_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Has no effect on exponential distributions. + */ + void + reset() { } + + /** + * @brief Returns the inverse scale parameter of the distribution. + */ + _RealType + lambda() const + { return _M_param.lambda(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return -std::log(result_type(1) - __aurng()) / __p.lambda(); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two exponential distributions have the same + * parameters. + */ + friend bool + operator==(const exponential_distribution& __d1, + const exponential_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two exponential distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::exponential_distribution<_RealType>& __d1, + const std::exponential_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %exponential_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %exponential_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::exponential_distribution<_RealType>& __x); + + /** + * @brief Extracts a %exponential_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %exponential_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::exponential_distribution<_RealType>& __x); + + + /** + * @brief A weibull_distribution random number distribution. + * + * The formula for the normal probability density function is: + * @f[ + * p(x|\alpha,\beta) = \frac{\alpha}{\beta} (\frac{x}{\beta})^{\alpha-1} + * \exp{(-(\frac{x}{\beta})^\alpha)} + * @f] + */ + template + class weibull_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef weibull_distribution<_RealType> distribution_type; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1.0)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + weibull_distribution() : weibull_distribution(1.0) { } + + explicit + weibull_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + weibull_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the @f$a@f$ parameter of the distribution. + */ + _RealType + a() const + { return _M_param.a(); } + + /** + * @brief Return the @f$b@f$ parameter of the distribution. + */ + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Weibull distributions have the same + * parameters. + */ + friend bool + operator==(const weibull_distribution& __d1, + const weibull_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Weibull distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::weibull_distribution<_RealType>& __d1, + const std::weibull_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %weibull_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %weibull_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::weibull_distribution<_RealType>& __x); + + /** + * @brief Extracts a %weibull_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %weibull_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::weibull_distribution<_RealType>& __x); + + + /** + * @brief A extreme_value_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|a,b) = \frac{1}{b} + * \exp( \frac{a-x}{b} - \exp(\frac{a-x}{b})) + * @f] + */ + template + class extreme_value_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef extreme_value_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1.0)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + extreme_value_distribution() : extreme_value_distribution(0.0) { } + + explicit + extreme_value_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + extreme_value_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the @f$a@f$ parameter of the distribution. + */ + _RealType + a() const + { return _M_param.a(); } + + /** + * @brief Return the @f$b@f$ parameter of the distribution. + */ + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two extreme value distributions have the same + * parameters. + */ + friend bool + operator==(const extreme_value_distribution& __d1, + const extreme_value_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two extreme value distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::extreme_value_distribution<_RealType>& __d1, + const std::extreme_value_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %extreme_value_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %extreme_value_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::extreme_value_distribution<_RealType>& __x); + + /** + * @brief Extracts a %extreme_value_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %extreme_value_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::extreme_value_distribution<_RealType>& __x); + + + /** + * @brief A discrete_distribution random number distribution. + * + * The formula for the discrete probability mass function is + * + */ + template + class discrete_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef discrete_distribution<_IntType> distribution_type; + friend class discrete_distribution<_IntType>; + + param_type() + : _M_prob(), _M_cp() + { } + + template + param_type(_InputIterator __wbegin, + _InputIterator __wend) + : _M_prob(__wbegin, __wend), _M_cp() + { _M_initialize(); } + + param_type(initializer_list __wil) + : _M_prob(__wil.begin(), __wil.end()), _M_cp() + { _M_initialize(); } + + template + param_type(size_t __nw, double __xmin, double __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector + probabilities() const + { return _M_prob.empty() ? std::vector(1, 1.0) : _M_prob; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_prob == __p2._M_prob; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector _M_prob; + std::vector _M_cp; + }; + + discrete_distribution() + : _M_param() + { } + + template + discrete_distribution(_InputIterator __wbegin, + _InputIterator __wend) + : _M_param(__wbegin, __wend) + { } + + discrete_distribution(initializer_list __wl) + : _M_param(__wl) + { } + + template + discrete_distribution(size_t __nw, double __xmin, double __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + discrete_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Returns the probabilities of the distribution. + */ + std::vector + probabilities() const + { + return _M_param._M_prob.empty() + ? std::vector(1, 1.0) : _M_param._M_prob; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_prob.empty() + ? result_type(0) : result_type(_M_param._M_prob.size() - 1); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two discrete distributions have the same + * parameters. + */ + friend bool + operator==(const discrete_distribution& __d1, + const discrete_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %discrete_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %discrete_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::discrete_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %discrete_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %discrete_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::discrete_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two discrete distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::discrete_distribution<_IntType>& __d1, + const std::discrete_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A piecewise_constant_distribution random number distribution. + * + * The formula for the piecewise constant probability mass function is + * + */ + template + class piecewise_constant_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef piecewise_constant_distribution<_RealType> distribution_type; + friend class piecewise_constant_distribution<_RealType>; + + param_type() + : _M_int(), _M_den(), _M_cp() + { } + + template + param_type(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin); + + template + param_type(initializer_list<_RealType> __bi, _Func __fw); + + template + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector<_RealType> + intervals() const + { + if (_M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_int; + } + + std::vector + densities() const + { return _M_den.empty() ? std::vector(1, 1.0) : _M_den; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector<_RealType> _M_int; + std::vector _M_den; + std::vector _M_cp; + }; + + piecewise_constant_distribution() + : _M_param() + { } + + template + piecewise_constant_distribution(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_param(__bfirst, __bend, __wbegin) + { } + + template + piecewise_constant_distribution(initializer_list<_RealType> __bl, + _Func __fw) + : _M_param(__bl, __fw) + { } + + template + piecewise_constant_distribution(size_t __nw, + _RealType __xmin, _RealType __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + piecewise_constant_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Returns a vector of the intervals. + */ + std::vector<_RealType> + intervals() const + { + if (_M_param._M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_param._M_int; + } + + /** + * @brief Returns a vector of the probability densities. + */ + std::vector + densities() const + { + return _M_param._M_den.empty() + ? std::vector(1, 1.0) : _M_param._M_den; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { + return _M_param._M_int.empty() + ? result_type(0) : _M_param._M_int.front(); + } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_int.empty() + ? result_type(1) : _M_param._M_int.back(); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two piecewise constant distributions have the + * same parameters. + */ + friend bool + operator==(const piecewise_constant_distribution& __d1, + const piecewise_constant_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %piecewise_constant_distribution random + * number distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %piecewise_constant_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::piecewise_constant_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %piecewise_constant_distribution random + * number distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %piecewise_constant_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::piecewise_constant_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two piecewise constant distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::piecewise_constant_distribution<_RealType>& __d1, + const std::piecewise_constant_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A piecewise_linear_distribution random number distribution. + * + * The formula for the piecewise linear probability mass function is + * + */ + template + class piecewise_linear_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef piecewise_linear_distribution<_RealType> distribution_type; + friend class piecewise_linear_distribution<_RealType>; + + param_type() + : _M_int(), _M_den(), _M_cp(), _M_m() + { } + + template + param_type(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin); + + template + param_type(initializer_list<_RealType> __bl, _Func __fw); + + template + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector<_RealType> + intervals() const + { + if (_M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_int; + } + + std::vector + densities() const + { return _M_den.empty() ? std::vector(2, 1.0) : _M_den; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector<_RealType> _M_int; + std::vector _M_den; + std::vector _M_cp; + std::vector _M_m; + }; + + piecewise_linear_distribution() + : _M_param() + { } + + template + piecewise_linear_distribution(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_param(__bfirst, __bend, __wbegin) + { } + + template + piecewise_linear_distribution(initializer_list<_RealType> __bl, + _Func __fw) + : _M_param(__bl, __fw) + { } + + template + piecewise_linear_distribution(size_t __nw, + _RealType __xmin, _RealType __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + piecewise_linear_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the intervals of the distribution. + */ + std::vector<_RealType> + intervals() const + { + if (_M_param._M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_param._M_int; + } + + /** + * @brief Return a vector of the probability densities of the + * distribution. + */ + std::vector + densities() const + { + return _M_param._M_den.empty() + ? std::vector(2, 1.0) : _M_param._M_den; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { + return _M_param._M_int.empty() + ? result_type(0) : _M_param._M_int.front(); + } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_int.empty() + ? result_type(1) : _M_param._M_int.back(); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two piecewise linear distributions have the + * same parameters. + */ + friend bool + operator==(const piecewise_linear_distribution& __d1, + const piecewise_linear_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %piecewise_linear_distribution random number + * distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %piecewise_linear_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::piecewise_linear_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %piecewise_linear_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %piecewise_linear_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::piecewise_linear_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two piecewise linear distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::piecewise_linear_distribution<_RealType>& __d1, + const std::piecewise_linear_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_poisson + + /// @} *group random_distributions + + /** + * @addtogroup random_utilities Random Number Utilities + * @ingroup random + * @{ + */ + + /** + * @brief The seed_seq class generates sequences of seeds for random + * number generators. + */ + class seed_seq + { + public: + /** The type of the seed vales. */ + typedef uint_least32_t result_type; + + /** Default constructor. */ + seed_seq() noexcept + : _M_v() + { } + + template>> + seed_seq(std::initializer_list<_IntType> __il); + + template + seed_seq(_InputIterator __begin, _InputIterator __end); + + // generating functions + template + void + generate(_RandomAccessIterator __begin, _RandomAccessIterator __end); + + // property functions + size_t size() const noexcept + { return _M_v.size(); } + + template + void + param(_OutputIterator __dest) const + { std::copy(_M_v.begin(), _M_v.end(), __dest); } + + // no copy functions + seed_seq(const seed_seq&) = delete; + seed_seq& operator=(const seed_seq&) = delete; + + private: + std::vector _M_v; + }; + + /// @} group random_utilities + + /// @} group random + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9f28123e93c5a3362a305db31368a1cb786ec87c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc new file mode 100644 index 0000000000000000000000000000000000000000..87a16a2133672f6df29066f31bff7ac2a1ab9a0c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc @@ -0,0 +1,3391 @@ +// random number generation (out of line) -*- C++ -*- + +// Copyright (C) 2009-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/random.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _RANDOM_TCC +#define _RANDOM_TCC 1 + +#include // std::accumulate and std::partial_sum + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @cond undocumented + // (Further) implementation-space details. + namespace __detail + { + // General case for x = (ax + c) mod m -- use Schrage's algorithm + // to avoid integer overflow. + // + // Preconditions: a > 0, m > 0. + // + // Note: only works correctly for __m % __a < __m / __a. + template + _Tp + _Mod<_Tp, __m, __a, __c, false, true>:: + __calc(_Tp __x) + { + if (__a == 1) + __x %= __m; + else + { + static const _Tp __q = __m / __a; + static const _Tp __r = __m % __a; + + _Tp __t1 = __a * (__x % __q); + _Tp __t2 = __r * (__x / __q); + if (__t1 >= __t2) + __x = __t1 - __t2; + else + __x = __m - __t2 + __t1; + } + + if (__c != 0) + { + const _Tp __d = __m - __x; + if (__d > __c) + __x += __c; + else + __x = __c - __d; + } + return __x; + } + + template + _OutputIterator + __normalize(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, const _Tp& __factor) + { + for (; __first != __last; ++__first, ++__result) + *__result = *__first / __factor; + return __result; + } + + } // namespace __detail + /// @endcond + +#if ! __cpp_inline_variables + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::increment; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; +#endif + + /** + * Seeds the LCR with integral value @p __s, adjusted so that the + * ring identity is never a member of the convergence set. + */ + template + void + linear_congruential_engine<_UIntType, __a, __c, __m>:: + seed(result_type __s) + { + if ((__detail::__mod<_UIntType, __m>(__c) == 0) + && (__detail::__mod<_UIntType, __m>(__s) == 0)) + _M_x = 1; + else + _M_x = __detail::__mod<_UIntType, __m>(__s); + } + + /** + * Seeds the LCR engine with a value generated by @p __q. + */ + template + template + auto + linear_congruential_engine<_UIntType, __a, __c, __m>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const _UIntType __k0 = __m == 0 ? std::numeric_limits<_UIntType>::digits + : std::__lg(__m); + const _UIntType __k = (__k0 + 31) / 32; + uint_least32_t __arr[__k + 3]; + __q.generate(__arr + 0, __arr + __k + 3); + _UIntType __factor = 1u; + _UIntType __sum = 0u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__j + 3] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + seed(__sum); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const linear_congruential_engine<_UIntType, + __a, __c, __m>& __lcr) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__os.widen(' ')); + + __os << __lcr._M_x; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec); + + __is >> __lcr._M_x; + + __is.flags(__flags); + return __is; + } + +#if ! __cpp_inline_variables + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::word_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::state_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::shift_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::mask_bits; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::xor_mask; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_u; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_d; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_s; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_b; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_t; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_c; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_l; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + initialization_multiplier; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::default_seed; +#endif + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + seed(result_type __sd) + { + _M_x[0] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sd); + + for (size_t __i = 1; __i < state_size; ++__i) + { + _UIntType __x = _M_x[__i - 1]; + __x ^= __x >> (__w - 2); + __x *= __f; + __x += __detail::__mod<_UIntType, __n>(__i); + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__x); + } + _M_p = state_size; + } + + template + template + auto + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const _UIntType __upper_mask = (~_UIntType()) << __r; + const size_t __k = (__w + 31) / 32; + uint_least32_t __arr[__n * __k]; + __q.generate(__arr + 0, __arr + __n * __k); + + bool __zero = true; + for (size_t __i = 0; __i < state_size; ++__i) + { + _UIntType __factor = 1u; + _UIntType __sum = 0u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__k * __i + __j] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + + if (__zero) + { + if (__i == 0) + { + if ((_M_x[0] & __upper_mask) != 0u) + __zero = false; + } + else if (_M_x[__i] != 0u) + __zero = false; + } + } + if (__zero) + _M_x[0] = __detail::_Shift<_UIntType, __w - 1>::__value; + _M_p = state_size; + } + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + _M_gen_rand(void) + { + const _UIntType __upper_mask = (~_UIntType()) << __r; + const _UIntType __lower_mask = ~__upper_mask; + + for (size_t __k = 0; __k < (__n - __m); ++__k) + { + _UIntType __y = ((_M_x[__k] & __upper_mask) + | (_M_x[__k + 1] & __lower_mask)); + _M_x[__k] = (_M_x[__k + __m] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + } + + for (size_t __k = (__n - __m); __k < (__n - 1); ++__k) + { + _UIntType __y = ((_M_x[__k] & __upper_mask) + | (_M_x[__k + 1] & __lower_mask)); + _M_x[__k] = (_M_x[__k + (__m - __n)] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + } + + _UIntType __y = ((_M_x[__n - 1] & __upper_mask) + | (_M_x[0] & __lower_mask)); + _M_x[__n - 1] = (_M_x[__m - 1] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + _M_p = 0; + } + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + discard(unsigned long long __z) + { + while (__z > state_size - _M_p) + { + __z -= state_size - _M_p; + _M_gen_rand(); + } + _M_p += __z; + } + + template + typename + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + operator()() + { + // Reload the vector - cost is O(n) amortized over n calls. + if (_M_p >= state_size) + _M_gen_rand(); + + // Calculate o(x(i)). + result_type __z = _M_x[_M_p++]; + __z ^= (__z >> __u) & __d; + __z ^= (__z << __s) & __b; + __z ^= (__z << __t) & __c; + __z ^= (__z >> __l); + + return __z; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + for (size_t __i = 0; __i < __n; ++__i) + __os << __x._M_x[__i] << __space; + __os << __x._M_p; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + for (size_t __i = 0; __i < __n; ++__i) + __is >> __x._M_x[__i]; + __is >> __x._M_p; + + __is.flags(__flags); + return __is; + } + +#if ! __cpp_inline_variables + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; + + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; + + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; + + template + constexpr _UIntType + subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; +#endif + + template + void + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + seed(result_type __value) + { + std::linear_congruential_engine + __lcg(__value == 0u ? default_seed : __value); + + const size_t __n = (__w + 31) / 32; + + for (size_t __i = 0; __i < long_lag; ++__i) + { + _UIntType __sum = 0u; + _UIntType __factor = 1u; + for (size_t __j = 0; __j < __n; ++__j) + { + __sum += __detail::__mod::__value> + (__lcg()) * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + } + _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; + _M_p = 0; + } + + template + template + auto + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const size_t __k = (__w + 31) / 32; + uint_least32_t __arr[__r * __k]; + __q.generate(__arr + 0, __arr + __r * __k); + + for (size_t __i = 0; __i < long_lag; ++__i) + { + _UIntType __sum = 0u; + _UIntType __factor = 1u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__k * __i + __j] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + } + _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; + _M_p = 0; + } + + template + typename subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + result_type + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + operator()() + { + // Derive short lag index from current index. + long __ps = _M_p - short_lag; + if (__ps < 0) + __ps += long_lag; + + // Calculate new x(i) without overflow or division. + // NB: Thanks to the requirements for _UIntType, _M_x[_M_p] + _M_carry + // cannot overflow. + _UIntType __xi; + if (_M_x[__ps] >= _M_x[_M_p] + _M_carry) + { + __xi = _M_x[__ps] - _M_x[_M_p] - _M_carry; + _M_carry = 0; + } + else + { + __xi = (__detail::_Shift<_UIntType, __w>::__value + - _M_x[_M_p] - _M_carry + _M_x[__ps]); + _M_carry = 1; + } + _M_x[_M_p] = __xi; + + // Adjust current index to loop around in ring buffer. + if (++_M_p >= long_lag) + _M_p = 0; + + return __xi; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const subtract_with_carry_engine<_UIntType, + __w, __s, __r>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + for (size_t __i = 0; __i < __r; ++__i) + __os << __x._M_x[__i] << __space; + __os << __x._M_carry << __space << __x._M_p; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + for (size_t __i = 0; __i < __r; ++__i) + __is >> __x._M_x[__i]; + __is >> __x._M_carry; + __is >> __x._M_p; + + __is.flags(__flags); + return __is; + } + +#if ! __cpp_inline_variables + template + constexpr size_t + discard_block_engine<_RandomNumberEngine, __p, __r>::block_size; + + template + constexpr size_t + discard_block_engine<_RandomNumberEngine, __p, __r>::used_block; +#endif + + template + typename discard_block_engine<_RandomNumberEngine, + __p, __r>::result_type + discard_block_engine<_RandomNumberEngine, __p, __r>:: + operator()() + { + if (_M_n >= used_block) + { + _M_b.discard(block_size - _M_n); + _M_n = 0; + } + ++_M_n; + return _M_b(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const discard_block_engine<_RandomNumberEngine, + __p, __r>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + __os << __x.base() << __space << __x._M_n; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + discard_block_engine<_RandomNumberEngine, __p, __r>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + __is >> __x._M_b >> __x._M_n; + + __is.flags(__flags); + return __is; + } + + + template + typename independent_bits_engine<_RandomNumberEngine, __w, _UIntType>:: + result_type + independent_bits_engine<_RandomNumberEngine, __w, _UIntType>:: + operator()() + { + typedef typename _RandomNumberEngine::result_type _Eresult_type; + const _Eresult_type __r + = (_M_b.max() - _M_b.min() < std::numeric_limits<_Eresult_type>::max() + ? _M_b.max() - _M_b.min() + 1 : 0); + const unsigned __edig = std::numeric_limits<_Eresult_type>::digits; + const unsigned __m = __r ? std::__lg(__r) : __edig; + + typedef typename std::common_type<_Eresult_type, result_type>::type + __ctype; + const unsigned __cdig = std::numeric_limits<__ctype>::digits; + + unsigned __n, __n0; + __ctype __s0, __s1, __y0, __y1; + + for (size_t __i = 0; __i < 2; ++__i) + { + __n = (__w + __m - 1) / __m + __i; + __n0 = __n - __w % __n; + const unsigned __w0 = __w / __n; // __w0 <= __m + + __s0 = 0; + __s1 = 0; + if (__w0 < __cdig) + { + __s0 = __ctype(1) << __w0; + __s1 = __s0 << 1; + } + + __y0 = 0; + __y1 = 0; + if (__r) + { + __y0 = __s0 * (__r / __s0); + if (__s1) + __y1 = __s1 * (__r / __s1); + + if (__r - __y0 <= __y0 / __n) + break; + } + else + break; + } + + result_type __sum = 0; + for (size_t __k = 0; __k < __n0; ++__k) + { + __ctype __u; + do + __u = _M_b() - _M_b.min(); + while (__y0 && __u >= __y0); + __sum = __s0 * __sum + (__s0 ? __u % __s0 : __u); + } + for (size_t __k = __n0; __k < __n; ++__k) + { + __ctype __u; + do + __u = _M_b() - _M_b.min(); + while (__y1 && __u >= __y1); + __sum = __s1 * __sum + (__s1 ? __u % __s1 : __u); + } + return __sum; + } + +#if ! __cpp_inline_variables + template + constexpr size_t + shuffle_order_engine<_RandomNumberEngine, __k>::table_size; +#endif + + namespace __detail + { + // Determine whether an integer is representable as double. + template + constexpr bool + __representable_as_double(_Tp __x) noexcept + { + static_assert(numeric_limits<_Tp>::is_integer, ""); + static_assert(!numeric_limits<_Tp>::is_signed, ""); + // All integers <= 2^53 are representable. + return (__x <= (1ull << __DBL_MANT_DIG__)) + // Between 2^53 and 2^54 only even numbers are representable. + || (!(__x & 1) && __detail::__representable_as_double(__x >> 1)); + } + + // Determine whether x+1 is representable as double. + template + constexpr bool + __p1_representable_as_double(_Tp __x) noexcept + { + static_assert(numeric_limits<_Tp>::is_integer, ""); + static_assert(!numeric_limits<_Tp>::is_signed, ""); + return numeric_limits<_Tp>::digits < __DBL_MANT_DIG__ + || (bool(__x + 1u) // return false if x+1 wraps around to zero + && __detail::__representable_as_double(__x + 1u)); + } + } + + template + typename shuffle_order_engine<_RandomNumberEngine, __k>::result_type + shuffle_order_engine<_RandomNumberEngine, __k>:: + operator()() + { + constexpr result_type __range = max() - min(); + size_t __j = __k; + const result_type __y = _M_y - min(); + // Avoid using slower long double arithmetic if possible. + if _GLIBCXX17_CONSTEXPR (__detail::__p1_representable_as_double(__range)) + __j *= __y / (__range + 1.0); + else + __j *= __y / (__range + 1.0L); + _M_y = _M_v[__j]; + _M_v[__j] = _M_b(); + + return _M_y; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const shuffle_order_engine<_RandomNumberEngine, __k>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + __os << __x.base(); + for (size_t __i = 0; __i < __k; ++__i) + __os << __space << __x._M_v[__i]; + __os << __space << __x._M_y; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + shuffle_order_engine<_RandomNumberEngine, __k>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + __is >> __x._M_b; + for (size_t __i = 0; __i < __k; ++__i) + __is >> __x._M_v[__i]; + __is >> __x._M_y; + + __is.flags(__flags); + return __is; + } + + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const uniform_int_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + uniform_int_distribution<_IntType>& __x) + { + using param_type + = typename uniform_int_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _IntType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + uniform_real_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + auto __range = __p.b() - __p.a(); + while (__f != __t) + *__f++ = __aurng() * __range + __p.a(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const uniform_real_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + uniform_real_distribution<_RealType>& __x) + { + using param_type + = typename uniform_real_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + void + std::bernoulli_distribution:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + auto __limit = __p.p() * (__aurng.max() - __aurng.min()); + + while (__f != __t) + *__f++ = (__aurng() - __aurng.min()) < __limit; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bernoulli_distribution& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.p(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + + template + template + typename geometric_distribution<_IntType>::result_type + geometric_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + // About the epsilon thing see this thread: + // http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + // The largest _RealType convertible to _IntType. + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + double __cand; + do + __cand = std::floor(std::log(1.0 - __aurng()) / __param._M_log_1_p); + while (__cand >= __thr); + + return result_type(__cand + __naf); + } + + template + template + void + geometric_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // About the epsilon thing see this thread: + // http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + // The largest _RealType convertible to _IntType. + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + while (__f != __t) + { + double __cand; + do + __cand = std::floor(std::log(1.0 - __aurng()) + / __param._M_log_1_p); + while (__cand >= __thr); + + *__f++ = __cand + __naf; + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const geometric_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.p(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + geometric_distribution<_IntType>& __x) + { + using param_type = typename geometric_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + double __p; + if (__is >> __p) + __x.param(param_type(__p)); + + __is.flags(__flags); + return __is; + } + + // This is Leger's algorithm, also in Devroye, Ch. X, Example 1.5. + template + template + typename negative_binomial_distribution<_IntType>::result_type + negative_binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng) + { + const double __y = _M_gd(__urng); + + // XXX Is the constructor too slow? + std::poisson_distribution __poisson(__y); + return __poisson(__urng); + } + + template + template + typename negative_binomial_distribution<_IntType>::result_type + negative_binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + + const double __y = + _M_gd(__urng, param_type(__p.k(), (1.0 - __p.p()) / __p.p())); + + std::poisson_distribution __poisson(__y); + return __poisson(__urng); + } + + template + template + void + negative_binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + { + const double __y = _M_gd(__urng); + + // XXX Is the constructor too slow? + std::poisson_distribution __poisson(__y); + *__f++ = __poisson(__urng); + } + } + + template + template + void + negative_binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typename std::gamma_distribution::param_type + __p2(__p.k(), (1.0 - __p.p()) / __p.p()); + + while (__f != __t) + { + const double __y = _M_gd(__urng, __p2); + + std::poisson_distribution __poisson(__y); + *__f++ = __poisson(__urng); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const negative_binomial_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.k() << __space << __x.p() + << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + negative_binomial_distribution<_IntType>& __x) + { + using param_type + = typename negative_binomial_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + _IntType __k; + double __p; + if (__is >> __k >> __p >> __x._M_gd) + __x.param(param_type(__k, __p)); + + __is.flags(__flags); + return __is; + } + + + template + void + poisson_distribution<_IntType>::param_type:: + _M_initialize() + { +#if _GLIBCXX_USE_C99_MATH_TR1 + if (_M_mean >= 12) + { + const double __m = std::floor(_M_mean); + _M_lm_thr = std::log(_M_mean); + _M_lfm = std::lgamma(__m + 1); + _M_sm = std::sqrt(__m); + + const double __pi_4 = 0.7853981633974483096156608458198757L; + const double __dx = std::sqrt(2 * __m * std::log(32 * __m + / __pi_4)); + _M_d = std::round(std::max(6.0, std::min(__m, __dx))); + const double __cx = 2 * __m + _M_d; + _M_scx = std::sqrt(__cx / 2); + _M_1cx = 1 / __cx; + + _M_c2b = std::sqrt(__pi_4 * __cx) * std::exp(_M_1cx); + _M_cb = 2 * __cx * std::exp(-_M_d * _M_1cx * (1 + _M_d / 2)) + / _M_d; + } + else +#endif + _M_lm_thr = std::exp(-_M_mean); + } + + /** + * A rejection algorithm when mean >= 12 and a simple method based + * upon the multiplication of uniform random variates otherwise. + * NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 + * is defined. + * + * Reference: + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. X, Sects. 3.3 & 3.4 (+ Errata!). + */ + template + template + typename poisson_distribution<_IntType>::result_type + poisson_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); +#if _GLIBCXX_USE_C99_MATH_TR1 + if (__param.mean() >= 12) + { + double __x; + + // See comments above... + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + + const double __m = std::floor(__param.mean()); + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + const double __c1 = __param._M_sm * __spi_2; + const double __c2 = __param._M_c2b + __c1; + const double __c3 = __c2 + 1; + const double __c4 = __c3 + 1; + // 1 / 78 + const double __178 = 0.0128205128205128205128205128205128L; + // e^(1 / 78) + const double __e178 = 1.0129030479320018583185514777512983L; + const double __c5 = __c4 + __e178; + const double __c = __param._M_cb + __c5; + const double __2cx = 2 * (2 * __m + __param._M_d); + + bool __reject = true; + do + { + const double __u = __c * __aurng(); + const double __e = -std::log(1.0 - __aurng()); + + double __w = 0.0; + + if (__u <= __c1) + { + const double __n = _M_nd(__urng); + const double __y = -std::abs(__n) * __param._M_sm - 1; + __x = std::floor(__y); + __w = -__n * __n / 2; + if (__x < -__m) + continue; + } + else if (__u <= __c2) + { + const double __n = _M_nd(__urng); + const double __y = 1 + std::abs(__n) * __param._M_scx; + __x = std::ceil(__y); + __w = __y * (2 - __y) * __param._M_1cx; + if (__x > __param._M_d) + continue; + } + else if (__u <= __c3) + // NB: This case not in the book, nor in the Errata, + // but should be ok... + __x = -1; + else if (__u <= __c4) + __x = 0; + else if (__u <= __c5) + { + __x = 1; + // Only in the Errata, see libstdc++/83237. + __w = __178; + } + else + { + const double __v = -std::log(1.0 - __aurng()); + const double __y = __param._M_d + + __v * __2cx / __param._M_d; + __x = std::ceil(__y); + __w = -__param._M_d * __param._M_1cx * (1 + __y / 2); + } + + __reject = (__w - __e - __x * __param._M_lm_thr + > __param._M_lfm - std::lgamma(__x + __m + 1)); + + __reject |= __x + __m >= __thr; + + } while (__reject); + + return result_type(__x + __m + __naf); + } + else +#endif + { + _IntType __x = 0; + double __prod = 1.0; + + do + { + __prod *= __aurng(); + __x += 1; + } + while (__prod > __param._M_lm_thr); + + return __x - 1; + } + } + + template + template + void + poisson_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const poisson_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.mean() << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + poisson_distribution<_IntType>& __x) + { + using param_type = typename poisson_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + double __mean; + if (__is >> __mean >> __x._M_nd) + __x.param(param_type(__mean)); + + __is.flags(__flags); + return __is; + } + + + template + void + binomial_distribution<_IntType>::param_type:: + _M_initialize() + { + const double __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p; + + _M_easy = true; + +#if _GLIBCXX_USE_C99_MATH_TR1 + if (_M_t * __p12 >= 8) + { + _M_easy = false; + const double __np = std::floor(_M_t * __p12); + const double __pa = __np / _M_t; + const double __1p = 1 - __pa; + + const double __pi_4 = 0.7853981633974483096156608458198757L; + const double __d1x = + std::sqrt(__np * __1p * std::log(32 * __np + / (81 * __pi_4 * __1p))); + _M_d1 = std::round(std::max(1.0, __d1x)); + const double __d2x = + std::sqrt(__np * __1p * std::log(32 * _M_t * __1p + / (__pi_4 * __pa))); + _M_d2 = std::round(std::max(1.0, __d2x)); + + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + _M_s1 = std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np)); + _M_s2 = std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * _M_t * __1p)); + _M_c = 2 * _M_d1 / __np; + _M_a1 = std::exp(_M_c) * _M_s1 * __spi_2; + const double __a12 = _M_a1 + _M_s2 * __spi_2; + const double __s1s = _M_s1 * _M_s1; + _M_a123 = __a12 + (std::exp(_M_d1 / (_M_t * __1p)) + * 2 * __s1s / _M_d1 + * std::exp(-_M_d1 * _M_d1 / (2 * __s1s))); + const double __s2s = _M_s2 * _M_s2; + _M_s = (_M_a123 + 2 * __s2s / _M_d2 + * std::exp(-_M_d2 * _M_d2 / (2 * __s2s))); + _M_lf = (std::lgamma(__np + 1) + + std::lgamma(_M_t - __np + 1)); + _M_lp1p = std::log(__pa / __1p); + + _M_q = -std::log(1 - (__p12 - __pa) / __1p); + } + else +#endif + _M_q = -std::log(1 - __p12); + } + + template + template + typename binomial_distribution<_IntType>::result_type + binomial_distribution<_IntType>:: + _M_waiting(_UniformRandomNumberGenerator& __urng, + _IntType __t, double __q) + { + _IntType __x = 0; + double __sum = 0.0; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + do + { + if (__t == __x) + return __x; + const double __e = -std::log(1.0 - __aurng()); + __sum += __e / (__t - __x); + __x += 1; + } + while (__sum <= __q); + + return __x - 1; + } + + /** + * A rejection algorithm when t * p >= 8 and a simple waiting time + * method - the second in the referenced book - otherwise. + * NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 + * is defined. + * + * Reference: + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. X, Sect. 4 (+ Errata!). + */ + template + template + typename binomial_distribution<_IntType>::result_type + binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + result_type __ret; + const _IntType __t = __param.t(); + const double __p = __param.p(); + const double __p12 = __p <= 0.5 ? __p : 1.0 - __p; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + +#if _GLIBCXX_USE_C99_MATH_TR1 + if (!__param._M_easy) + { + double __x; + + // See comments above... + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + + const double __np = std::floor(__t * __p12); + + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + const double __a1 = __param._M_a1; + const double __a12 = __a1 + __param._M_s2 * __spi_2; + const double __a123 = __param._M_a123; + const double __s1s = __param._M_s1 * __param._M_s1; + const double __s2s = __param._M_s2 * __param._M_s2; + + bool __reject; + do + { + const double __u = __param._M_s * __aurng(); + + double __v; + + if (__u <= __a1) + { + const double __n = _M_nd(__urng); + const double __y = __param._M_s1 * std::abs(__n); + __reject = __y >= __param._M_d1; + if (!__reject) + { + const double __e = -std::log(1.0 - __aurng()); + __x = std::floor(__y); + __v = -__e - __n * __n / 2 + __param._M_c; + } + } + else if (__u <= __a12) + { + const double __n = _M_nd(__urng); + const double __y = __param._M_s2 * std::abs(__n); + __reject = __y >= __param._M_d2; + if (!__reject) + { + const double __e = -std::log(1.0 - __aurng()); + __x = std::floor(-__y); + __v = -__e - __n * __n / 2; + } + } + else if (__u <= __a123) + { + const double __e1 = -std::log(1.0 - __aurng()); + const double __e2 = -std::log(1.0 - __aurng()); + + const double __y = __param._M_d1 + + 2 * __s1s * __e1 / __param._M_d1; + __x = std::floor(__y); + __v = (-__e2 + __param._M_d1 * (1 / (__t - __np) + -__y / (2 * __s1s))); + __reject = false; + } + else + { + const double __e1 = -std::log(1.0 - __aurng()); + const double __e2 = -std::log(1.0 - __aurng()); + + const double __y = __param._M_d2 + + 2 * __s2s * __e1 / __param._M_d2; + __x = std::floor(-__y); + __v = -__e2 - __param._M_d2 * __y / (2 * __s2s); + __reject = false; + } + + __reject = __reject || __x < -__np || __x > __t - __np; + if (!__reject) + { + const double __lfx = + std::lgamma(__np + __x + 1) + + std::lgamma(__t - (__np + __x) + 1); + __reject = __v > __param._M_lf - __lfx + + __x * __param._M_lp1p; + } + + __reject |= __x + __np >= __thr; + } + while (__reject); + + __x += __np + __naf; + + const _IntType __z = _M_waiting(__urng, __t - _IntType(__x), + __param._M_q); + __ret = _IntType(__x) + __z; + } + else +#endif + __ret = _M_waiting(__urng, __t, __param._M_q); + + if (__p12 != __p) + __ret = __t - __ret; + return __ret; + } + + template + template + void + binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const binomial_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.t() << __space << __x.p() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + binomial_distribution<_IntType>& __x) + { + using param_type = typename binomial_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _IntType __t; + double __p; + if (__is >> __t >> __p >> __x._M_nd) + __x.param(param_type(__t, __p)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::exponential_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + while (__f != __t) + *__f++ = -std::log(result_type(1) - __aurng()) / __p.lambda(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const exponential_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.lambda(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + exponential_distribution<_RealType>& __x) + { + using param_type + = typename exponential_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __lambda; + if (__is >> __lambda) + __x.param(param_type(__lambda)); + + __is.flags(__flags); + return __is; + } + + + /** + * Polar method due to Marsaglia. + * + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. V, Sect. 4.4. + */ + template + template + typename normal_distribution<_RealType>::result_type + normal_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + result_type __ret; + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + if (_M_saved_available) + { + _M_saved_available = false; + __ret = _M_saved; + } + else + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + __ret = __y * __mult; + } + + __ret = __ret * __param.stddev() + __param.mean(); + return __ret; + } + + template + template + void + normal_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + + if (__f == __t) + return; + + if (_M_saved_available) + { + _M_saved_available = false; + *__f++ = _M_saved * __param.stddev() + __param.mean(); + + if (__f == __t) + return; + } + + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + while (__f + 1 < __t) + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + *__f++ = __y * __mult * __param.stddev() + __param.mean(); + *__f++ = __x * __mult * __param.stddev() + __param.mean(); + } + + if (__f != __t) + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + *__f = __y * __mult * __param.stddev() + __param.mean(); + } + } + + template + bool + operator==(const std::normal_distribution<_RealType>& __d1, + const std::normal_distribution<_RealType>& __d2) + { + if (__d1._M_param == __d2._M_param + && __d1._M_saved_available == __d2._M_saved_available) + { + if (__d1._M_saved_available + && __d1._M_saved == __d2._M_saved) + return true; + else if(!__d1._M_saved_available) + return true; + else + return false; + } + else + return false; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const normal_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.mean() << __space << __x.stddev() + << __space << __x._M_saved_available; + if (__x._M_saved_available) + __os << __space << __x._M_saved; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + normal_distribution<_RealType>& __x) + { + using param_type = typename normal_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + double __mean, __stddev; + bool __saved_avail; + if (__is >> __mean >> __stddev >> __saved_avail) + { + if (!__saved_avail || (__is >> __x._M_saved)) + { + __x._M_saved_available = __saved_avail; + __x.param(param_type(__mean, __stddev)); + } + } + + __is.flags(__flags); + return __is; + } + + + template + template + void + lognormal_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = std::exp(__p.s() * _M_nd(__urng) + __p.m()); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const lognormal_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.m() << __space << __x.s() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + lognormal_distribution<_RealType>& __x) + { + using param_type + = typename lognormal_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __m, __s; + if (__is >> __m >> __s >> __x._M_nd) + __x.param(param_type(__m, __s)); + + __is.flags(__flags); + return __is; + } + + template + template + void + std::chi_squared_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = 2 * _M_gd(__urng); + } + + template + template + void + std::chi_squared_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const typename + std::gamma_distribution::param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = 2 * _M_gd(__urng, __p); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const chi_squared_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.n() << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + chi_squared_distribution<_RealType>& __x) + { + using param_type + = typename chi_squared_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __n; + if (__is >> __n >> __x._M_gd) + __x.param(param_type(__n)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename cauchy_distribution<_RealType>::result_type + cauchy_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + _RealType __u; + do + __u = __aurng(); + while (__u == 0.5); + + const _RealType __pi = 3.1415926535897932384626433832795029L; + return __p.a() + __p.b() * std::tan(__pi * __u); + } + + template + template + void + cauchy_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + const _RealType __pi = 3.1415926535897932384626433832795029L; + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + while (__f != __t) + { + _RealType __u; + do + __u = __aurng(); + while (__u == 0.5); + + *__f++ = __p.a() + __p.b() * std::tan(__pi * __u); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const cauchy_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + cauchy_distribution<_RealType>& __x) + { + using param_type = typename cauchy_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::fisher_f_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = ((_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m())); + } + + template + template + void + std::fisher_f_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typedef typename std::gamma_distribution::param_type + param_type; + param_type __p1(__p.m() / 2); + param_type __p2(__p.n() / 2); + while (__f != __t) + *__f++ = ((_M_gd_x(__urng, __p1) * n()) + / (_M_gd_y(__urng, __p2) * m())); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const fisher_f_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.m() << __space << __x.n() + << __space << __x._M_gd_x << __space << __x._M_gd_y; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + fisher_f_distribution<_RealType>& __x) + { + using param_type + = typename fisher_f_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __m, __n; + if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y) + __x.param(param_type(__m, __n)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::student_t_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); + } + + template + template + void + std::student_t_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typename std::gamma_distribution::param_type + __p2(__p.n() / 2, 2); + while (__f != __t) + *__f++ = _M_nd(__urng) * std::sqrt(__p.n() / _M_gd(__urng, __p2)); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const student_t_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.n() << __space << __x._M_nd << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + student_t_distribution<_RealType>& __x) + { + using param_type + = typename student_t_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __n; + if (__is >> __n >> __x._M_nd >> __x._M_gd) + __x.param(param_type(__n)); + + __is.flags(__flags); + return __is; + } + + + template + void + gamma_distribution<_RealType>::param_type:: + _M_initialize() + { + _M_malpha = _M_alpha < 1.0 ? _M_alpha + _RealType(1.0) : _M_alpha; + + const _RealType __a1 = _M_malpha - _RealType(1.0) / _RealType(3.0); + _M_a2 = _RealType(1.0) / std::sqrt(_RealType(9.0) * __a1); + } + + /** + * Marsaglia, G. and Tsang, W. W. + * "A Simple Method for Generating Gamma Variables" + * ACM Transactions on Mathematical Software, 26, 3, 363-372, 2000. + */ + template + template + typename gamma_distribution<_RealType>::result_type + gamma_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + result_type __u, __v, __n; + const result_type __a1 = (__param._M_malpha + - _RealType(1.0) / _RealType(3.0)); + + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + if (__param.alpha() == __param._M_malpha) + return __a1 * __v * __param.beta(); + else + { + do + __u = __aurng(); + while (__u == 0.0); + + return (std::pow(__u, result_type(1.0) / __param.alpha()) + * __a1 * __v * __param.beta()); + } + } + + template + template + void + gamma_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + result_type __u, __v, __n; + const result_type __a1 = (__param._M_malpha + - _RealType(1.0) / _RealType(3.0)); + + if (__param.alpha() == __param._M_malpha) + while (__f != __t) + { + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + *__f++ = __a1 * __v * __param.beta(); + } + else + while (__f != __t) + { + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + do + __u = __aurng(); + while (__u == 0.0); + + *__f++ = (std::pow(__u, result_type(1.0) / __param.alpha()) + * __a1 * __v * __param.beta()); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const gamma_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.alpha() << __space << __x.beta() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + gamma_distribution<_RealType>& __x) + { + using param_type = typename gamma_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __alpha_val, __beta_val; + if (__is >> __alpha_val >> __beta_val >> __x._M_nd) + __x.param(param_type(__alpha_val, __beta_val)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename weibull_distribution<_RealType>::result_type + weibull_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return __p.b() * std::pow(-std::log(result_type(1) - __aurng()), + result_type(1) / __p.a()); + } + + template + template + void + weibull_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + auto __inv_a = result_type(1) / __p.a(); + + while (__f != __t) + *__f++ = __p.b() * std::pow(-std::log(result_type(1) - __aurng()), + __inv_a); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const weibull_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + weibull_distribution<_RealType>& __x) + { + using param_type = typename weibull_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename extreme_value_distribution<_RealType>::result_type + extreme_value_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return __p.a() - __p.b() * std::log(-std::log(result_type(1) + - __aurng())); + } + + template + template + void + extreme_value_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + while (__f != __t) + *__f++ = __p.a() - __p.b() * std::log(-std::log(result_type(1) + - __aurng())); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const extreme_value_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + extreme_value_distribution<_RealType>& __x) + { + using param_type + = typename extreme_value_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + void + discrete_distribution<_IntType>::param_type:: + _M_initialize() + { + if (_M_prob.size() < 2) + { + _M_prob.clear(); + return; + } + + const double __sum = std::accumulate(_M_prob.begin(), + _M_prob.end(), 0.0); + __glibcxx_assert(__sum > 0); + // Now normalize the probabilites. + __detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(), + __sum); + // Accumulate partial sums. + _M_cp.reserve(_M_prob.size()); + std::partial_sum(_M_prob.begin(), _M_prob.end(), + std::back_inserter(_M_cp)); + // Make sure the last cumulative probability is one. + _M_cp[_M_cp.size() - 1] = 1.0; + } + + template + template + discrete_distribution<_IntType>::param_type:: + param_type(size_t __nw, double __xmin, double __xmax, _Func __fw) + : _M_prob(), _M_cp() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const double __delta = (__xmax - __xmin) / __n; + + _M_prob.reserve(__n); + for (size_t __k = 0; __k < __nw; ++__k) + _M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta)); + + _M_initialize(); + } + + template + template + typename discrete_distribution<_IntType>::result_type + discrete_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + if (__param._M_cp.empty()) + return result_type(0); + + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + + return __pos - __param._M_cp.begin(); + } + + template + template + void + discrete_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + + if (__param._M_cp.empty()) + { + while (__f != __t) + *__f++ = result_type(0); + return; + } + + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + while (__f != __t) + { + const double __p = __aurng(); + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + + *__f++ = __pos - __param._M_cp.begin(); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const discrete_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + std::vector __prob = __x.probabilities(); + __os << __prob.size(); + for (auto __dit = __prob.begin(); __dit != __prob.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + +namespace __detail +{ + template + basic_istream<_CharT, _Traits>& + __extract_params(basic_istream<_CharT, _Traits>& __is, + vector<_ValT>& __vals, size_t __n) + { + __vals.reserve(__n); + while (__n--) + { + _ValT __val; + if (__is >> __val) + __vals.push_back(__val); + else + break; + } + return __is; + } +} // namespace __detail + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + discrete_distribution<_IntType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + std::vector __prob_vec; + if (__detail::__extract_params(__is, __prob_vec, __n)) + __x.param({__prob_vec.begin(), __prob_vec.end()}); + } + + __is.flags(__flags); + return __is; + } + + + template + void + piecewise_constant_distribution<_RealType>::param_type:: + _M_initialize() + { + if (_M_int.size() < 2 + || (_M_int.size() == 2 + && _M_int[0] == _RealType(0) + && _M_int[1] == _RealType(1))) + { + _M_int.clear(); + _M_den.clear(); + return; + } + + const double __sum = std::accumulate(_M_den.begin(), + _M_den.end(), 0.0); + __glibcxx_assert(__sum > 0); + + __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(), + __sum); + + _M_cp.reserve(_M_den.size()); + std::partial_sum(_M_den.begin(), _M_den.end(), + std::back_inserter(_M_cp)); + + // Make sure the last cumulative probability is one. + _M_cp[_M_cp.size() - 1] = 1.0; + + for (size_t __k = 0; __k < _M_den.size(); ++__k) + _M_den[__k] /= _M_int[__k + 1] - _M_int[__k]; + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(_InputIteratorB __bbegin, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_int(), _M_den(), _M_cp() + { + if (__bbegin != __bend) + { + for (;;) + { + _M_int.push_back(*__bbegin); + ++__bbegin; + if (__bbegin == __bend) + break; + + _M_den.push_back(*__wbegin); + ++__wbegin; + } + } + + _M_initialize(); + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(initializer_list<_RealType> __bl, _Func __fw) + : _M_int(), _M_den(), _M_cp() + { + _M_int.reserve(__bl.size()); + for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter) + _M_int.push_back(*__biter); + + _M_den.reserve(_M_int.size() - 1); + for (size_t __k = 0; __k < _M_int.size() - 1; ++__k) + _M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k]))); + + _M_initialize(); + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw) + : _M_int(), _M_den(), _M_cp() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const _RealType __delta = (__xmax - __xmin) / __n; + + _M_int.reserve(__n + 1); + for (size_t __k = 0; __k <= __nw; ++__k) + _M_int.push_back(__xmin + __k * __delta); + + _M_den.reserve(__n); + for (size_t __k = 0; __k < __nw; ++__k) + _M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta)); + + _M_initialize(); + } + + template + template + typename piecewise_constant_distribution<_RealType>::result_type + piecewise_constant_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + if (__param._M_cp.empty()) + return __p; + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i]; + } + + template + template + void + piecewise_constant_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + if (__param._M_cp.empty()) + { + while (__f != __t) + *__f++ = __aurng(); + return; + } + + while (__f != __t) + { + const double __p = __aurng(); + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + *__f++ = (__param._M_int[__i] + + (__p - __pref) / __param._M_den[__i]); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const piecewise_constant_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + std::vector<_RealType> __int = __x.intervals(); + __os << __int.size() - 1; + + for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit) + __os << __space << *__xit; + + std::vector __den = __x.densities(); + for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + piecewise_constant_distribution<_RealType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + std::vector<_RealType> __int_vec; + if (__detail::__extract_params(__is, __int_vec, __n + 1)) + { + std::vector __den_vec; + if (__detail::__extract_params(__is, __den_vec, __n)) + { + __x.param({ __int_vec.begin(), __int_vec.end(), + __den_vec.begin() }); + } + } + } + + __is.flags(__flags); + return __is; + } + + + template + void + piecewise_linear_distribution<_RealType>::param_type:: + _M_initialize() + { + if (_M_int.size() < 2 + || (_M_int.size() == 2 + && _M_int[0] == _RealType(0) + && _M_int[1] == _RealType(1) + && _M_den[0] == _M_den[1])) + { + _M_int.clear(); + _M_den.clear(); + return; + } + + double __sum = 0.0; + _M_cp.reserve(_M_int.size() - 1); + _M_m.reserve(_M_int.size() - 1); + for (size_t __k = 0; __k < _M_int.size() - 1; ++__k) + { + const _RealType __delta = _M_int[__k + 1] - _M_int[__k]; + __sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta; + _M_cp.push_back(__sum); + _M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta); + } + __glibcxx_assert(__sum > 0); + + // Now normalize the densities... + __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(), + __sum); + // ... and partial sums... + __detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum); + // ... and slopes. + __detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum); + + // Make sure the last cumulative probablility is one. + _M_cp[_M_cp.size() - 1] = 1.0; + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(_InputIteratorB __bbegin, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + for (; __bbegin != __bend; ++__bbegin, ++__wbegin) + { + _M_int.push_back(*__bbegin); + _M_den.push_back(*__wbegin); + } + + _M_initialize(); + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(initializer_list<_RealType> __bl, _Func __fw) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + _M_int.reserve(__bl.size()); + _M_den.reserve(__bl.size()); + for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter) + { + _M_int.push_back(*__biter); + _M_den.push_back(__fw(*__biter)); + } + + _M_initialize(); + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const _RealType __delta = (__xmax - __xmin) / __n; + + _M_int.reserve(__n + 1); + _M_den.reserve(__n + 1); + for (size_t __k = 0; __k <= __nw; ++__k) + { + _M_int.push_back(__xmin + __k * __delta); + _M_den.push_back(__fw(_M_int[__k] + __delta)); + } + + _M_initialize(); + } + + template + template + typename piecewise_linear_distribution<_RealType>::result_type + piecewise_linear_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + if (__param._M_cp.empty()) + return __p; + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + const double __a = 0.5 * __param._M_m[__i]; + const double __b = __param._M_den[__i]; + const double __cm = __p - __pref; + + _RealType __x = __param._M_int[__i]; + if (__a == 0) + __x += __cm / __b; + else + { + const double __d = __b * __b + 4.0 * __a * __cm; + __x += 0.5 * (std::sqrt(__d) - __b) / __a; + } + + return __x; + } + + template + template + void + piecewise_linear_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const piecewise_linear_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + std::vector<_RealType> __int = __x.intervals(); + __os << __int.size() - 1; + + for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit) + __os << __space << *__xit; + + std::vector __den = __x.densities(); + for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + piecewise_linear_distribution<_RealType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + vector<_RealType> __int_vec; + if (__detail::__extract_params(__is, __int_vec, __n + 1)) + { + vector __den_vec; + if (__detail::__extract_params(__is, __den_vec, __n + 1)) + { + __x.param({ __int_vec.begin(), __int_vec.end(), + __den_vec.begin() }); + } + } + } + __is.flags(__flags); + return __is; + } + + + template + seed_seq::seed_seq(std::initializer_list<_IntType> __il) + { + _M_v.reserve(__il.size()); + for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter) + _M_v.push_back(__detail::__mod::__value>(*__iter)); + } + + template + seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end) + { + if _GLIBCXX17_CONSTEXPR (__is_random_access_iter<_InputIterator>::value) + _M_v.reserve(std::distance(__begin, __end)); + + for (_InputIterator __iter = __begin; __iter != __end; ++__iter) + _M_v.push_back(__detail::__mod::__value>(*__iter)); + } + + template + void + seed_seq::generate(_RandomAccessIterator __begin, + _RandomAccessIterator __end) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _Type; + + if (__begin == __end) + return; + + std::fill(__begin, __end, _Type(0x8b8b8b8bu)); + + const size_t __n = __end - __begin; + const size_t __s = _M_v.size(); + const size_t __t = (__n >= 623) ? 11 + : (__n >= 68) ? 7 + : (__n >= 39) ? 5 + : (__n >= 7) ? 3 + : (__n - 1) / 2; + const size_t __p = (__n - __t) / 2; + const size_t __q = __p + __t; + const size_t __m = std::max(size_t(__s + 1), __n); + +#ifndef __UINT32_TYPE__ + struct _Up + { + _Up(uint_least32_t v) : _M_v(v & 0xffffffffu) { } + + operator uint_least32_t() const { return _M_v; } + + uint_least32_t _M_v; + }; + using uint32_t = _Up; +#endif + + // k == 0, every element in [begin,end) equals 0x8b8b8b8bu + { + uint32_t __r1 = 1371501266u; + uint32_t __r2 = __r1 + __s; + __begin[__p] += __r1; + __begin[__q] = (uint32_t)__begin[__q] + __r2; + __begin[0] = __r2; + } + + for (size_t __k = 1; __k <= __s; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + ^ __begin[__kpn] + ^ __begin[(__k - 1) % __n]); + uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27)); + uint32_t __r2 = __r1 + (uint32_t)__kn + _M_v[__k - 1]; + __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1; + __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2; + __begin[__kn] = __r2; + } + + for (size_t __k = __s + 1; __k < __m; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + ^ __begin[__kpn] + ^ __begin[(__k - 1) % __n]); + uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27)); + uint32_t __r2 = __r1 + (uint32_t)__kn; + __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1; + __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2; + __begin[__kn] = __r2; + } + + for (size_t __k = __m; __k < __m + __n; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + + __begin[__kpn] + + __begin[(__k - 1) % __n]); + uint32_t __r3 = 1566083941u * (__arg ^ (__arg >> 27)); + uint32_t __r4 = __r3 - __kn; + __begin[__kpn] ^= __r3; + __begin[__kqn] ^= __r4; + __begin[__kn] = __r4; + } + } + + template + _RealType + generate_canonical(_UniformRandomNumberGenerator& __urng) + { + static_assert(std::is_floating_point<_RealType>::value, + "template argument must be a floating point type"); + + const size_t __b + = std::min(static_cast(std::numeric_limits<_RealType>::digits), + __bits); + const long double __r = static_cast(__urng.max()) + - static_cast(__urng.min()) + 1.0L; + const size_t __log2r = std::log(__r) / std::log(2.0L); + const size_t __m = std::max(1UL, + (__b + __log2r - 1UL) / __log2r); + _RealType __ret; + _RealType __sum = _RealType(0); + _RealType __tmp = _RealType(1); + for (size_t __k = __m; __k != 0; --__k) + { + __sum += _RealType(__urng() - __urng.min()) * __tmp; + __tmp *= __r; + } + __ret = __sum / __tmp; + if (__builtin_expect(__ret >= _RealType(1), 0)) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + __ret = std::nextafter(_RealType(1), _RealType(0)); +#else + __ret = _RealType(1) + - std::numeric_limits<_RealType>::epsilon() / _RealType(2); +#endif + } + return __ret; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..93df8a53ffd7da6ab1b10aee73331ec2a3c0db4a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@random.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h new file mode 100644 index 0000000000000000000000000000000000000000..78fdfe66035cb59438b26432896394a9f13f758b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h @@ -0,0 +1,371 @@ +// Range access functions for containers -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/range_access.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _GLIBCXX_RANGE_ACCESS_H +#define _GLIBCXX_RANGE_ACCESS_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include +#include // common_type_t, make_signed_t +#include // reverse_iterator + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Return an iterator pointing to the first element of + * the container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + begin(_Container& __cont) -> decltype(__cont.begin()) + { return __cont.begin(); } + + /** + * @brief Return an iterator pointing to the first element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + begin(const _Container& __cont) -> decltype(__cont.begin()) + { return __cont.begin(); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + end(_Container& __cont) -> decltype(__cont.end()) + { return __cont.end(); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + end(const _Container& __cont) -> decltype(__cont.end()) + { return __cont.end(); } + + /** + * @brief Return an iterator pointing to the first element of the array. + * @param __arr Array. + */ + template + [[__nodiscard__]] + inline _GLIBCXX14_CONSTEXPR _Tp* + begin(_Tp (&__arr)[_Nm]) noexcept + { return __arr; } + + /** + * @brief Return an iterator pointing to one past the last element + * of the array. + * @param __arr Array. + */ + template + [[__nodiscard__]] + inline _GLIBCXX14_CONSTEXPR _Tp* + end(_Tp (&__arr)[_Nm]) noexcept + { return __arr + _Nm; } + +#if __cplusplus >= 201402L + + template class valarray; + // These overloads must be declared for cbegin and cend to use them. + template _Tp* begin(valarray<_Tp>&) noexcept; + template const _Tp* begin(const valarray<_Tp>&) noexcept; + template _Tp* end(valarray<_Tp>&) noexcept; + template const _Tp* end(const valarray<_Tp>&) noexcept; + + /** + * @brief Return an iterator pointing to the first element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + constexpr auto + cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont))) + -> decltype(std::begin(__cont)) + { return std::begin(__cont); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + constexpr auto + cend(const _Container& __cont) noexcept(noexcept(std::end(__cont))) + -> decltype(std::end(__cont)) + { return std::end(__cont); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + rbegin(_Container& __cont) -> decltype(__cont.rbegin()) + { return __cont.rbegin(); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + rbegin(const _Container& __cont) -> decltype(__cont.rbegin()) + { return __cont.rbegin(); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + rend(_Container& __cont) -> decltype(__cont.rend()) + { return __cont.rend(); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + rend(const _Container& __cont) -> decltype(__cont.rend()) + { return __cont.rend(); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the array. + * @param __arr Array. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rbegin(_Tp (&__arr)[_Nm]) noexcept + { return reverse_iterator<_Tp*>(__arr + _Nm); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the array. + * @param __arr Array. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rend(_Tp (&__arr)[_Nm]) noexcept + { return reverse_iterator<_Tp*>(__arr); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the initializer_list. + * @param __il initializer_list. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin(initializer_list<_Tp> __il) noexcept + { return reverse_iterator(__il.end()); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the initializer_list. + * @param __il initializer_list. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rend(initializer_list<_Tp> __il) noexcept + { return reverse_iterator(__il.begin()); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont)) + { return std::rbegin(__cont); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the const container. + * @param __cont Container. + */ + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + crend(const _Container& __cont) -> decltype(std::rend(__cont)) + { return std::rend(__cont); } + +#endif // C++14 + +#if __cplusplus >= 201703L +#define __cpp_lib_nonmember_container_access 201411L + + /** + * @brief Return the size of a container. + * @param __cont Container. + */ + template + [[nodiscard]] + constexpr auto + size(const _Container& __cont) noexcept(noexcept(__cont.size())) + -> decltype(__cont.size()) + { return __cont.size(); } + + /** + * @brief Return the size of an array. + */ + template + [[nodiscard]] + constexpr size_t + size(const _Tp (&)[_Nm]) noexcept + { return _Nm; } + + /** + * @brief Return whether a container is empty. + * @param __cont Container. + */ + template + [[nodiscard]] constexpr auto + empty(const _Container& __cont) noexcept(noexcept(__cont.empty())) + -> decltype(__cont.empty()) + { return __cont.empty(); } + + /** + * @brief Return whether an array is empty (always false). + */ + template + [[nodiscard]] constexpr bool + empty(const _Tp (&)[_Nm]) noexcept + { return false; } + + /** + * @brief Return whether an initializer_list is empty. + * @param __il Initializer list. + */ + template + [[nodiscard]] constexpr bool + empty(initializer_list<_Tp> __il) noexcept + { return __il.size() == 0;} + + /** + * @brief Return the data pointer of a container. + * @param __cont Container. + */ + template + [[nodiscard]] + constexpr auto + data(_Container& __cont) noexcept(noexcept(__cont.data())) + -> decltype(__cont.data()) + { return __cont.data(); } + + /** + * @brief Return the data pointer of a const container. + * @param __cont Container. + */ + template + [[nodiscard]] + constexpr auto + data(const _Container& __cont) noexcept(noexcept(__cont.data())) + -> decltype(__cont.data()) + { return __cont.data(); } + + /** + * @brief Return the data pointer of an array. + * @param __array Array. + */ + template + [[nodiscard]] + constexpr _Tp* + data(_Tp (&__array)[_Nm]) noexcept + { return __array; } + + /** + * @brief Return the data pointer of an initializer list. + * @param __il Initializer list. + */ + template + [[nodiscard]] + constexpr const _Tp* + data(initializer_list<_Tp> __il) noexcept + { return __il.begin(); } + +#if __cplusplus > 201703L +#define __cpp_lib_ssize 201902L + template + [[nodiscard]] + constexpr auto + ssize(const _Container& __cont) + noexcept(noexcept(__cont.size())) + -> common_type_t> + { + using type = make_signed_t; + return static_cast>(__cont.size()); + } + + template + [[nodiscard]] + constexpr ptrdiff_t + ssize(const _Tp (&)[_Num]) noexcept + { return _Num; } +#endif // C++20 + +#endif // C++17 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif // _GLIBCXX_RANGE_ACCESS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1aa2cc6378e9dbeebcc1bcfc23331484f19c7a28 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@range_access.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h new file mode 100644 index 0000000000000000000000000000000000000000..8016f87478eb436ca35b5422ef7a8fa12804d585 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h @@ -0,0 +1,410 @@ +// Implementation of std::reference_wrapper -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/refwrap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_REFWRAP_H +#define _GLIBCXX_REFWRAP_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include +#include +#include // for unary_function and binary_function + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @cond undocumented + + /** + * Derives from @c unary_function or @c binary_function, or perhaps + * nothing, depending on the number of arguments provided. The + * primary template is the basis case, which derives nothing. + */ + template + struct _Maybe_unary_or_binary_function { }; + +// Ignore warnings about unary_function and binary_function. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /// Derives from @c unary_function, as appropriate. + template + struct _Maybe_unary_or_binary_function<_Res, _T1> + : std::unary_function<_T1, _Res> { }; + + /// Derives from @c binary_function, as appropriate. + template + struct _Maybe_unary_or_binary_function<_Res, _T1, _T2> + : std::binary_function<_T1, _T2, _Res> { }; + +#pragma GCC diagnostic pop + + template + struct _Mem_fn_traits; + + template + struct _Mem_fn_traits_base + { + using __result_type = _Res; + using __maybe_type + = _Maybe_unary_or_binary_function<_Res, _Class*, _ArgTypes...>; + using __arity = integral_constant; + }; + +#define _GLIBCXX_MEM_FN_TRAITS2(_CV, _REF, _LVAL, _RVAL) \ + template \ + struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) _CV _REF> \ + : _Mem_fn_traits_base<_Res, _CV _Class, _ArgTypes...> \ + { \ + using __vararg = false_type; \ + }; \ + template \ + struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) _CV _REF> \ + : _Mem_fn_traits_base<_Res, _CV _Class, _ArgTypes...> \ + { \ + using __vararg = true_type; \ + }; + +#define _GLIBCXX_MEM_FN_TRAITS(_REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2( , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(const , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(volatile , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(const volatile, _REF, _LVAL, _RVAL) + +_GLIBCXX_MEM_FN_TRAITS( , true_type, true_type) +_GLIBCXX_MEM_FN_TRAITS(&, true_type, false_type) +_GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) + +#if __cplusplus > 201402L +_GLIBCXX_MEM_FN_TRAITS(noexcept, true_type, true_type) +_GLIBCXX_MEM_FN_TRAITS(& noexcept, true_type, false_type) +_GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type) +#endif + +#undef _GLIBCXX_MEM_FN_TRAITS +#undef _GLIBCXX_MEM_FN_TRAITS2 + + /// If we have found a result_type, extract it. + template> + struct _Maybe_get_result_type + { }; + + template + struct _Maybe_get_result_type<_Functor, + __void_t> + { typedef typename _Functor::result_type result_type; }; + + /** + * Base class for any function object that has a weak result type, as + * defined in 20.8.2 [func.require] of C++11. + */ + template + struct _Weak_result_type_impl + : _Maybe_get_result_type<_Functor> + { }; + + /// Retrieve the result type for a function type. + template + struct _Weak_result_type_impl<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a varargs function type. + template + struct _Weak_result_type_impl<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a function pointer. + template + struct _Weak_result_type_impl<_Res(*)(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a varargs function pointer. + template + struct + _Weak_result_type_impl<_Res(*)(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + // Let _Weak_result_type_impl perform the real work. + template::value> + struct _Weak_result_type_memfun + : _Weak_result_type_impl<_Functor> + { }; + + // A pointer to member function has a weak result type. + template + struct _Weak_result_type_memfun<_MemFunPtr, true> + { + using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; + }; + + // A pointer to data member doesn't have a weak result type. + template + struct _Weak_result_type_memfun<_Func _Class::*, false> + { }; + + /** + * Strip top-level cv-qualifiers from the function object and let + * _Weak_result_type_memfun perform the real work. + */ + template + struct _Weak_result_type + : _Weak_result_type_memfun::type> + { }; + +#if __cplusplus <= 201703L + // Detect nested argument_type. + template> + struct _Refwrap_base_arg1 + { }; + + // Nested argument_type. + template + struct _Refwrap_base_arg1<_Tp, + __void_t> + { + typedef typename _Tp::argument_type argument_type; + }; + + // Detect nested first_argument_type and second_argument_type. + template> + struct _Refwrap_base_arg2 + { }; + + // Nested first_argument_type and second_argument_type. + template + struct _Refwrap_base_arg2<_Tp, + __void_t> + { + typedef typename _Tp::first_argument_type first_argument_type; + typedef typename _Tp::second_argument_type second_argument_type; + }; + + /** + * Derives from unary_function or binary_function when it + * can. Specializations handle all of the easy cases. The primary + * template determines what to do with a class type, which may + * derive from both unary_function and binary_function. + */ + template + struct _Reference_wrapper_base + : _Weak_result_type<_Tp>, _Refwrap_base_arg1<_Tp>, _Refwrap_base_arg2<_Tp> + { }; + +// Ignore warnings about unary_function and binary_function. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + // - a function type (unary) + template + struct _Reference_wrapper_base<_Res(_T1) _GLIBCXX_NOEXCEPT_QUAL> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) const> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) volatile> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) const volatile> + : unary_function<_T1, _Res> + { }; + + // - a function type (binary) + template + struct _Reference_wrapper_base<_Res(_T1, _T2) _GLIBCXX_NOEXCEPT_QUAL> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) const> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) volatile> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) const volatile> + : binary_function<_T1, _T2, _Res> + { }; + + // - a function pointer type (unary) + template + struct _Reference_wrapper_base<_Res(*)(_T1) _GLIBCXX_NOEXCEPT_QUAL> + : unary_function<_T1, _Res> + { }; + + // - a function pointer type (binary) + template + struct _Reference_wrapper_base<_Res(*)(_T1, _T2) _GLIBCXX_NOEXCEPT_QUAL> + : binary_function<_T1, _T2, _Res> + { }; + + template::value> + struct _Reference_wrapper_base_memfun + : _Reference_wrapper_base<_Tp> + { }; + + template + struct _Reference_wrapper_base_memfun<_MemFunPtr, true> + : _Mem_fn_traits<_MemFunPtr>::__maybe_type + { + using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; + }; +#pragma GCC diagnostic pop +#endif // ! C++20 + + /// @endcond + + /** + * @brief Primary class template for reference_wrapper. + * @ingroup functors + */ + template + class reference_wrapper +#if __cplusplus <= 201703L + // In C++20 std::reference_wrapper allows T to be incomplete, + // so checking for nested types could result in ODR violations. + : public _Reference_wrapper_base_memfun::type> +#endif + { + _Tp* _M_data; + + _GLIBCXX20_CONSTEXPR + static _Tp* _S_fun(_Tp& __r) noexcept { return std::__addressof(__r); } + + static void _S_fun(_Tp&&) = delete; + + template> + using __not_same + = typename enable_if::value>::type; + + public: + typedef _Tp type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2993. reference_wrapper conversion from T&& + // 3041. Unnecessary decay in reference_wrapper + template, typename + = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))> + _GLIBCXX20_CONSTEXPR + reference_wrapper(_Up&& __uref) + noexcept(noexcept(reference_wrapper::_S_fun(std::declval<_Up>()))) + : _M_data(reference_wrapper::_S_fun(std::forward<_Up>(__uref))) + { } + + reference_wrapper(const reference_wrapper&) = default; + + reference_wrapper& + operator=(const reference_wrapper&) = default; + + _GLIBCXX20_CONSTEXPR + operator _Tp&() const noexcept + { return this->get(); } + + _GLIBCXX20_CONSTEXPR + _Tp& + get() const noexcept + { return *_M_data; } + + template + _GLIBCXX20_CONSTEXPR + typename result_of<_Tp&(_Args&&...)>::type + operator()(_Args&&... __args) const + { +#if __cplusplus > 201703L + if constexpr (is_object_v) + static_assert(sizeof(type), "type must be complete"); +#endif + return std::__invoke(get(), std::forward<_Args>(__args)...); + } + }; + +#if __cpp_deduction_guides + template + reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; +#endif + + /// @relates reference_wrapper @{ + + /// Denotes a reference should be taken to a variable. + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper<_Tp> + ref(_Tp& __t) noexcept + { return reference_wrapper<_Tp>(__t); } + + /// Denotes a const reference should be taken to a variable. + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper + cref(const _Tp& __t) noexcept + { return reference_wrapper(__t); } + + template + void ref(const _Tp&&) = delete; + + template + void cref(const _Tp&&) = delete; + + /// std::ref overload to prevent wrapping a reference_wrapper + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper<_Tp> + ref(reference_wrapper<_Tp> __t) noexcept + { return __t; } + + /// std::cref overload to prevent wrapping a reference_wrapper + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper + cref(reference_wrapper<_Tp> __t) noexcept + { return { __t.get() }; } + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_REFWRAP_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b954c74812cd1e5b6d7ba3666e62d61d53ccce6f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@refwrap.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h new file mode 100644 index 0000000000000000000000000000000000000000..46c168010bf6a7bd7c0e0bc35860d2364794c680 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h @@ -0,0 +1,3026 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class basic_regex; + + template + class match_results; + +_GLIBCXX_END_NAMESPACE_CXX11 + +namespace __detail +{ + enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; + + template + bool + __regex_algo_impl(_BiIter __s, _BiIter __e, + match_results<_BiIter, _Alloc>& __m, + const basic_regex<_CharT, _TraitsT>& __re, + regex_constants::match_flag_type __flags, + _RegexExecutorPolicy __policy, + bool __match_mode); + + template + class _Executor; + + template + struct __is_contiguous_iter : false_type { }; + + template + struct __is_contiguous_iter<_Tp*> : true_type { }; + + template + struct __is_contiguous_iter<__gnu_cxx::__normal_iterator<_Tp*, _Cont>> + : true_type { }; +} + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @addtogroup regex + * @{ + */ + + /** + * @brief Describes aspects of a regular expression. + * + * A regular expression traits class that satisfies the requirements of + * section [28.7]. + * + * The class %regex is parameterized around a set of related types and + * functions used to complete the definition of its semantics. This class + * satisfies the requirements of such a traits class. + */ + template + class regex_traits + { + public: + typedef _Ch_type char_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + + private: + struct _RegexMask + { + typedef std::ctype_base::mask _BaseType; + _BaseType _M_base; + unsigned char _M_extended; + static constexpr unsigned char _S_under = 1 << 0; + static constexpr unsigned char _S_valid_mask = 0x1; + + constexpr _RegexMask(_BaseType __base = 0, + unsigned char __extended = 0) + : _M_base(__base), _M_extended(__extended) + { } + + constexpr _RegexMask + operator&(_RegexMask __other) const + { + return _RegexMask(_M_base & __other._M_base, + _M_extended & __other._M_extended); + } + + constexpr _RegexMask + operator|(_RegexMask __other) const + { + return _RegexMask(_M_base | __other._M_base, + _M_extended | __other._M_extended); + } + + constexpr _RegexMask + operator^(_RegexMask __other) const + { + return _RegexMask(_M_base ^ __other._M_base, + _M_extended ^ __other._M_extended); + } + + constexpr _RegexMask + operator~() const + { return _RegexMask(~_M_base, ~_M_extended); } + + _RegexMask& + operator&=(_RegexMask __other) + { return *this = (*this) & __other; } + + _RegexMask& + operator|=(_RegexMask __other) + { return *this = (*this) | __other; } + + _RegexMask& + operator^=(_RegexMask __other) + { return *this = (*this) ^ __other; } + + constexpr bool + operator==(_RegexMask __other) const + { + return (_M_extended & _S_valid_mask) + == (__other._M_extended & _S_valid_mask) + && _M_base == __other._M_base; + } + +#if __cpp_impl_three_way_comparison < 201907L + constexpr bool + operator!=(_RegexMask __other) const + { return !((*this) == __other); } +#endif + }; + + public: + typedef _RegexMask char_class_type; + + public: + /** + * @brief Constructs a default traits object. + */ + regex_traits() { } + + /** + * @brief Gives the length of a C-style string starting at @p __p. + * + * @param __p a pointer to the start of a character sequence. + * + * @returns the number of characters between @p *__p and the first + * default-initialized value of type @p char_type. In other words, uses + * the C-string algorithm for determining the length of a sequence of + * characters. + */ + static std::size_t + length(const char_type* __p) + { return string_type::traits_type::length(__p); } + + /** + * @brief Performs the identity translation. + * + * @param __c A character to the locale-specific character set. + * + * @returns __c. + */ + char_type + translate(char_type __c) const + { return __c; } + + /** + * @brief Translates a character into a case-insensitive equivalent. + * + * @param __c A character to the locale-specific character set. + * + * @returns the locale-specific lower-case equivalent of __c. + * @throws std::bad_cast if the imbued locale does not support the ctype + * facet. + */ + char_type + translate_nocase(char_type __c) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + return __fctyp.tolower(__c); + } + + /** + * @brief Gets a sort key for a character sequence. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * + * Returns a sort key for the character sequence designated by the + * iterator range [F1, F2) such that if the character sequence [G1, G2) + * sorts before the character sequence [H1, H2) then + * v.transform(G1, G2) < v.transform(H1, H2). + * + * What this really does is provide a more efficient way to compare a + * string to multiple other strings in locales with fancy collation + * rules and equivalence classes. + * + * @returns a locale-specific sort key equivalent to the input range. + * + * @throws std::bad_cast if the current locale does not have a collate + * facet. + */ + template + string_type + transform(_Fwd_iter __first, _Fwd_iter __last) const + { + typedef std::collate __collate_type; + const __collate_type& __fclt(use_facet<__collate_type>(_M_locale)); + string_type __s(__first, __last); + return __fclt.transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Gets a sort key for a character sequence, independent of case. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * + * Effects: if typeid(use_facet >) == + * typeid(collate_byname<_Ch_type>) and the form of the sort key + * returned by collate_byname<_Ch_type>::transform(__first, __last) + * is known and can be converted into a primary sort key + * then returns that key, otherwise returns an empty string. + * + * @todo Implement this function correctly. + */ + template + string_type + transform_primary(_Fwd_iter __first, _Fwd_iter __last) const + { + // TODO : this is not entirely correct. + // This function requires extra support from the platform. + // + // Read http://gcc.gnu.org/ml/libstdc++/2013-09/msg00117.html and + // http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2003/n1429.htm + // for details. + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + _GLIBCXX_STD_C::vector __s(__first, __last); + __fctyp.tolower(__s.data(), __s.data() + __s.size()); + return this->transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Gets a collation element by name. + * + * @param __first beginning of the collation element name. + * @param __last one-past-the-end of the collation element name. + * + * @returns a sequence of one or more characters that represents the + * collating element consisting of the character sequence designated by + * the iterator range [__first, __last). Returns an empty string if the + * character sequence is not a valid collating element. + */ + template + string_type + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Maps one or more characters to a named character + * classification. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * @param __icase ignores the case of the classification name. + * + * @returns an unspecified value that represents the character + * classification named by the character sequence designated by + * the iterator range [__first, __last). If @p icase is true, + * the returned mask identifies the classification regardless of + * the case of the characters to be matched (for example, + * [[:lower:]] is the same as [[:alpha:]]), otherwise a + * case-dependent classification is returned. The value + * returned shall be independent of the case of the characters + * in the character sequence. If the name is not recognized then + * returns a value that compares equal to 0. + * + * At least the following names (or their wide-character equivalent) are + * supported. + * - d + * - w + * - s + * - alnum + * - alpha + * - blank + * - cntrl + * - digit + * - graph + * - lower + * - print + * - punct + * - space + * - upper + * - xdigit + */ + template + char_class_type + lookup_classname(_Fwd_iter __first, _Fwd_iter __last, + bool __icase = false) const; + + /** + * @brief Determines if @p c is a member of an identified class. + * + * @param __c a character. + * @param __f a class type (as returned from lookup_classname). + * + * @returns true if the character @p __c is a member of the classification + * represented by @p __f, false otherwise. + * + * @throws std::bad_cast if the current locale does not have a ctype + * facet. + */ + bool + isctype(_Ch_type __c, char_class_type __f) const; + + /** + * @brief Converts a digit to an int. + * + * @param __ch a character representing a digit. + * @param __radix the radix if the numeric conversion (limited to 8, 10, + * or 16). + * + * @returns the value represented by the digit __ch in base radix if the + * character __ch is a valid digit in base radix; otherwise returns -1. + */ + int + value(_Ch_type __ch, int __radix) const; + + /** + * @brief Imbues the regex_traits object with a copy of a new locale. + * + * @param __loc A locale. + * + * @returns a copy of the previous locale in use by the regex_traits + * object. + * + * @note Calling imbue with a different locale than the one currently in + * use invalidates all cached data held by *this. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(_M_locale, __loc); + return __loc; + } + + /** + * @brief Gets a copy of the current locale in use by the regex_traits + * object. + */ + locale_type + getloc() const + { return _M_locale; } + + protected: + locale_type _M_locale; + }; + + // [7.8] Class basic_regex + /** + * Objects of specializations of this class represent regular expressions + * constructed from sequences of character type @p _Ch_type. + * + * Storage for the regular expression is allocated and deallocated as + * necessary by the member functions of this class. + */ + template> + class basic_regex + { + public: + static_assert(is_same<_Ch_type, typename _Rx_traits::char_type>::value, + "regex traits class must have the same char_type"); + + // types: + typedef _Ch_type value_type; + typedef _Rx_traits traits_type; + typedef typename traits_type::string_type string_type; + typedef regex_constants::syntax_option_type flag_type; + typedef typename traits_type::locale_type locale_type; + + /** + * @name Constants + * std [28.8.1](1) + */ + ///@{ + static constexpr flag_type icase = regex_constants::icase; + static constexpr flag_type nosubs = regex_constants::nosubs; + static constexpr flag_type optimize = regex_constants::optimize; + static constexpr flag_type collate = regex_constants::collate; + static constexpr flag_type ECMAScript = regex_constants::ECMAScript; + static constexpr flag_type basic = regex_constants::basic; + static constexpr flag_type extended = regex_constants::extended; + static constexpr flag_type awk = regex_constants::awk; + static constexpr flag_type grep = regex_constants::grep; + static constexpr flag_type egrep = regex_constants::egrep; +#if __cplusplus >= 201703L || !defined __STRICT_ANSI__ + static constexpr flag_type multiline = regex_constants::multiline; +#endif + ///@} + + // [7.8.2] construct/copy/destroy + /** + * Constructs a basic regular expression that does not match any + * character sequence. + */ + basic_regex() noexcept + : _M_flags(ECMAScript), _M_loc(), _M_automaton(nullptr) + { } + + /** + * @brief Constructs a basic regular expression from the + * sequence [__p, __p + char_traits<_Ch_type>::length(__p)) + * interpreted according to the flags in @p __f. + * + * @param __p A pointer to the start of a C-style null-terminated string + * containing a regular expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __p is not a valid regular expression. + */ + explicit + basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript) + { _M_compile(__p, __p + _Rx_traits::length(__p), __f); } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + len) interpreted according to the flags in @p f. + * + * @param __p A pointer to the start of a string containing a regular + * expression. + * @param __len The length of the string containing the regular + * expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __p is not a valid regular expression. + */ + basic_regex(const _Ch_type* __p, std::size_t __len, + flag_type __f = ECMAScript) + { + __glibcxx_requires_string_len(__p, __len); + _M_compile(__p, __p + __len, __f); + } + + /** + * @brief Copy-constructs a basic regular expression. + * + * @param __rhs A @p regex object. + */ + basic_regex(const basic_regex& __rhs) = default; + + /** + * @brief Move-constructs a basic regular expression. + * + * @param __rhs A @p regex object. + */ + basic_regex(basic_regex&& __rhs) noexcept = default; + + /** + * @brief Constructs a basic regular expression from the string + * @p s interpreted according to the flags in @p f. + * + * @param __s A string containing a regular expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __s is not a valid regular expression. + */ + template + explicit + basic_regex(const std::basic_string<_Ch_type, _Ch_traits, + _Ch_alloc>& __s, + flag_type __f = ECMAScript) + { _M_compile(__s.data(), __s.data() + __s.size(), __f); } + + /** + * @brief Constructs a basic regular expression from the range + * [first, last) interpreted according to the flags in @p f. + * + * @param __first The start of a range containing a valid regular + * expression. + * @param __last The end of a range containing a valid regular + * expression. + * @param __f The format flags of the regular expression. + * + * @throws regex_error if @p [__first, __last) is not a valid regular + * expression. + */ + template + basic_regex(_FwdIter __first, _FwdIter __last, + flag_type __f = ECMAScript) + { this->assign(__first, __last, __f); } + + /** + * @brief Constructs a basic regular expression from an initializer list. + * + * @param __l The initializer list. + * @param __f The format flags of the regular expression. + * + * @throws regex_error if @p __l is not a valid regular expression. + */ + basic_regex(initializer_list<_Ch_type> __l, flag_type __f = ECMAScript) + { _M_compile(__l.begin(), __l.end(), __f); } + + /** + * @brief Destroys a basic regular expression. + */ + ~basic_regex() + { } + + /** + * @brief Assigns one regular expression to another. + */ + basic_regex& + operator=(const basic_regex&) = default; + + /** + * @brief Move-assigns one regular expression to another. + */ + basic_regex& + operator=(basic_regex&&) = default; + + /** + * @brief Replaces a regular expression with a new one constructed from + * a C-style null-terminated string. + * + * @param __p A pointer to the start of a null-terminated C-style string + * containing a regular expression. + */ + basic_regex& + operator=(const _Ch_type* __p) + { return this->assign(__p); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * an initializer list. + * + * @param __l The initializer list. + * + * @throws regex_error if @p __l is not a valid regular expression. + */ + basic_regex& + operator=(initializer_list<_Ch_type> __l) + { return this->assign(__l); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a string. + * + * @param __s A pointer to a string containing a regular expression. + */ + template + basic_regex& + operator=(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s) + { return this->assign(__s); } + + // [7.8.3] assign + /** + * @brief Assigns one regular expression to another. + * + * @param __rhs Another regular expression object. + */ + basic_regex& + assign(const basic_regex& __rhs) noexcept + { return *this = __rhs; } + + /** + * @brief Move-assigns one regular expression to another. + * + * @param __rhs Another regular expression object. + */ + basic_regex& + assign(basic_regex&& __rhs) noexcept + { return *this = std::move(__rhs); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style null-terminated string containing a regular expression + * pattern. + * + * @param __p A pointer to a C-style null-terminated string containing + * a regular expression pattern. + * @param __flags Syntax option flags. + * + * @throws regex_error if __p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, flag_type __flags = ECMAScript) + { + _M_compile(__p, __p + _Rx_traits::length(__p), __flags); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style string containing a regular expression pattern. + * + * @param __p A pointer to a C-style string containing a + * regular expression pattern. + * @param __len The length of the regular expression pattern string. + * @param __flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3296. Inconsistent default argument for basic_regex<>::assign + basic_regex& + assign(const _Ch_type* __p, size_t __len, flag_type __flags = ECMAScript) + { + _M_compile(__p, __p + __len, __flags); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object from a + * string containing a regular expression pattern. + * + * @param __s A string containing a regular expression pattern. + * @param __flags Syntax option flags. + * + * @throws regex_error if __s does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + template + basic_regex& + assign(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s, + flag_type __flags = ECMAScript) + { + _M_compile(__s.data(), __s.data() + __s.size(), __flags); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param __first The start of a range containing a valid regular + * expression. + * @param __last The end of a range containing a valid regular + * expression. + * @param __flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, the object remains unchanged. + */ + template + basic_regex& + assign(_InputIterator __first, _InputIterator __last, + flag_type __flags = ECMAScript) + { +#if __cpp_if_constexpr >= 201606L + using _ValT = typename iterator_traits<_InputIterator>::value_type; + if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value + && is_same_v<_ValT, value_type>) + { + __glibcxx_requires_valid_range(__first, __last); + if constexpr (is_pointer_v<_InputIterator>) + _M_compile(__first, __last, __flags); + else // __normal_iterator<_T*, C> + _M_compile(__first.base(), __last.base(), __flags); + } + else +#endif + this->assign(string_type(__first, __last), __flags); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param __l An initializer list representing a regular expression. + * @param __flags Syntax option flags. + * + * @throws regex_error if @p __l does not contain a valid + * regular expression pattern interpreted according to @p + * __flags. If regex_error is thrown, the object remains + * unchanged. + */ + basic_regex& + assign(initializer_list<_Ch_type> __l, flag_type __flags = ECMAScript) + { + _M_compile(__l.begin(), __l.end(), __flags); + return *this; + } + + // [7.8.4] const operations + /** + * @brief Gets the number of marked subexpressions within the regular + * expression. + */ + unsigned int + mark_count() const noexcept + { + if (_M_automaton) + return _M_automaton->_M_sub_count() - 1; + return 0; + } + + /** + * @brief Gets the flags used to construct the regular expression + * or in the last call to assign(). + */ + flag_type + flags() const noexcept + { return _M_flags; } + + // [7.8.5] locale + /** + * @brief Imbues the regular expression object with the given locale. + * + * @param __loc A locale. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(__loc, _M_loc); + _M_automaton.reset(); + return __loc; + } + + /** + * @brief Gets the locale currently imbued in the regular expression + * object. + */ + locale_type + getloc() const noexcept + { return _M_loc; } + + // [7.8.6] swap + /** + * @brief Swaps the contents of two regular expression objects. + * + * @param __rhs Another regular expression object. + */ + void + swap(basic_regex& __rhs) noexcept + { + std::swap(_M_flags, __rhs._M_flags); + std::swap(_M_loc, __rhs._M_loc); + std::swap(_M_automaton, __rhs._M_automaton); + } + +#ifdef _GLIBCXX_DEBUG + void + _M_dot(std::ostream& __ostr) + { _M_automaton->_M_dot(__ostr); } +#endif + + private: + typedef std::shared_ptr> _AutomatonPtr; + + void + _M_compile(const _Ch_type* __first, const _Ch_type* __last, + flag_type __f) + { + __detail::_Compiler<_Rx_traits> __c(__first, __last, _M_loc, __f); + _M_automaton = __c._M_get_nfa(); + _M_flags = __f; + } + + template + friend bool + __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, + const basic_regex<_Cp, _Rp>&, + regex_constants::match_flag_type, + __detail::_RegexExecutorPolicy, bool); + + template + friend class __detail::_Executor; + + flag_type _M_flags; + locale_type _M_loc; + _AutomatonPtr _M_automaton; + }; + +#if ! __cpp_inline_variables + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::icase; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::nosubs; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::optimize; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::collate; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::ECMAScript; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::basic; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::extended; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::awk; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::grep; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::egrep; +#endif // ! C++17 + +#if __cpp_deduction_guides >= 201606 + template + basic_regex(_ForwardIterator, _ForwardIterator, + regex_constants::syntax_option_type = {}) + -> basic_regex::value_type>; +#endif + + /** @brief Standard regular expressions. */ + typedef basic_regex regex; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Standard wide-character regular expressions. */ + typedef basic_regex wregex; +#endif + + + // [7.8.6] basic_regex swap + /** + * @brief Swaps the contents of two regular expression objects. + * @param __lhs First regular expression. + * @param __rhs Second regular expression. + * @relates basic_regex + */ + template + inline void + swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, + basic_regex<_Ch_type, _Rx_traits>& __rhs) noexcept + { __lhs.swap(__rhs); } + + + // C++11 28.9 [re.submatch] Class template sub_match + /** + * A sequence of characters matched by a particular marked sub-expression. + * + * An object of this class is essentially a pair of iterators marking a + * matched subexpression within a regular expression pattern match. Such + * objects can be converted to and compared with std::basic_string objects + * of a similar base character type as the pattern matched by the regular + * expression. + * + * The iterators that make up the pair are the usual half-open interval + * referencing the actual original pattern matched. + */ + template + class sub_match : public std::pair<_BiIter, _BiIter> + { + typedef iterator_traits<_BiIter> __iter_traits; + + public: + typedef typename __iter_traits::value_type value_type; + typedef typename __iter_traits::difference_type difference_type; + typedef _BiIter iterator; + typedef basic_string string_type; + + bool matched; + + constexpr sub_match() noexcept : matched() { } + + /// Gets the length of the matching sequence. + difference_type + length() const noexcept + { return this->matched ? std::distance(this->first, this->second) : 0; } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + * + * This is the implicit conversion operator. It is identical to the + * str() member function except that it will want to pop up in + * unexpected places and cause a great deal of confusion and cursing + * from the unwary. + */ + operator string_type() const + { return str(); } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + */ + string_type + str() const + { + return this->matched + ? string_type(this->first, this->second) + : string_type(); + } + + /** + * @brief Compares this and another matched sequence. + * + * @param __s Another matched sequence to compare to this one. + * + * @retval negative This matched sequence will collate before `__s`. + * @retval zero This matched sequence is equivalent to `__s`. + * @retval positive This matched sequence will collate after `__s`. + */ + int + compare(const sub_match& __s) const + { return this->_M_str().compare(__s._M_str()); } + + /** + * @{ + * @brief Compares this `sub_match` to a string. + * + * @param __s A string to compare to this `sub_match`. + * + * @retval negative This matched sequence will collate before `__s`. + * @retval zero This matched sequence is equivalent to `__s`. + * @retval positive This matched sequence will collate after `__s`. + */ + int + compare(const string_type& __s) const + { return this->_M_str().compare(__s); } + + int + compare(const value_type* __s) const + { return this->_M_str().compare(__s); } + /// @} + + /// @cond undocumented + // Non-standard, used by comparison operators + int + _M_compare(const value_type* __s, size_t __n) const + { return this->_M_str().compare({__s, __n}); } + /// @endcond + + private: + // Simplified basic_string_view for C++11 + struct __string_view + { + using traits_type = typename string_type::traits_type; + + __string_view() = default; + + __string_view(const value_type* __s, size_t __n) noexcept + : _M_data(__s), _M_len(__n) { } + + __string_view(const value_type* __s) noexcept + : _M_data(__s), _M_len(traits_type::length(__s)) { } + + __string_view(const string_type& __s) noexcept + : _M_data(__s.data()), _M_len(__s.length()) { } + + int + compare(__string_view __s) const noexcept + { + if (const size_t __n = std::min(_M_len, __s._M_len)) + if (int __ret = traits_type::compare(_M_data, __s._M_data, __n)) + return __ret; + using __limits = __gnu_cxx::__int_traits; + const difference_type __diff = _M_len - __s._M_len; + if (__diff > __limits::__max) + return __limits::__max; + if (__diff < __limits::__min) + return __limits::__min; + return static_cast(__diff); + } + + private: + const value_type* _M_data = nullptr; + size_t _M_len = 0; + }; + + // Create a __string_view over the iterator range. + template + __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value, + __string_view> + _M_str() const noexcept + { + if (this->matched) + if (size_t __len = this->second - this->first) + return { std::__addressof(*this->first), __len }; + return {}; + } + + // Create a temporary string that can be converted to __string_view. + template + __enable_if_t::value, + string_type> + _M_str() const + { return str(); } + }; + + + /** @brief Standard regex submatch over a C-style null-terminated string. */ + typedef sub_match csub_match; + + /** @brief Standard regex submatch over a standard string. */ + typedef sub_match ssub_match; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Regex submatch over a C-style null-terminated wide string. */ + typedef sub_match wcsub_match; + + /** @brief Regex submatch over a standard wide string. */ + typedef sub_match wssub_match; +#endif + + // [7.9.2] sub_match non-member operators + + /// @relates sub_match @{ + + /** + * @brief Tests the equivalence of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + noexcept(__detail::__is_contiguous_iter<_BiIter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs)); + } +#else + /** + * @brief Tests the inequivalence of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) != 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) > 0; } +#endif // three-way comparison + + /// @cond undocumented + + // Alias for a basic_string that can be compared to a sub_match. + template + using __sub_match_string = basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>; + /// @endcond + +#if ! __cpp_lib_three_way_comparison + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Alloc>& __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + return __detail::__char_traits_cmp_cat<_Ch_traits>( + __lhs._M_compare(__rhs.data(), __rhs.size())); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__rhs < __lhs); } + + /** + * @brief Tests the equivalence of a C string and a regular expression + * submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs.compare(__lhs) == 0; } + + /** + * @brief Tests the inequivalence of a C string and a regular + * expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs.compare(__lhs) > 0; } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a C + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a C + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs)); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__rhs < __lhs); } + + /** + * @brief Tests the equivalence of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(std::__addressof(__lhs), 1) == 0; } + + /** + * @brief Tests the inequivalence of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(std::__addressof(__lhs), 1) > 0; } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs._M_compare(std::__addressof(__rhs), 1) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>( + __lhs._M_compare(std::__addressof(__rhs), 1)); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs._M_compare(std::__addressof(__rhs), 1) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Inserts a matched string into an output stream. + * + * @param __os The output stream. + * @param __m A submatch string. + * + * @returns the output stream with the submatch string inserted. + */ + template + inline + basic_ostream<_Ch_type, _Ch_traits>& + operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, + const sub_match<_Bi_iter>& __m) + { return __os << __m.str(); } + + /// @} relates sub_match + + // [7.10] Class template match_results + + /** + * @brief The results of a match or search operation. + * + * A collection of character sequences representing the result of a regular + * expression match. Storage for the collection is allocated and freed as + * necessary by the member functions of class template match_results. + * + * This class satisfies the Sequence requirements, with the exception that + * only the operations defined for a const-qualified Sequence are supported. + * + * The sub_match object stored at index 0 represents sub-expression 0, i.e. + * the whole match. In this case the %sub_match member matched is always true. + * The sub_match object stored at index n denotes what matched the marked + * sub-expression n within the matched expression. If the sub-expression n + * participated in a regular expression match then the %sub_match member + * matched evaluates to true, and members first and second denote the range + * of characters [first, second) which formed that match. Otherwise matched + * is false, and members first and second point to the end of the sequence + * that was searched. + */ + template > > + class match_results + : private std::vector, _Alloc> + { + private: + /* + * The vector base is empty if this does not represent a match (!ready()); + * Otherwise if it's a match failure, it contains 3 elements: + * [0] unmatched + * [1] prefix + * [2] suffix + * Otherwise it contains n+4 elements where n is the number of marked + * sub-expressions: + * [0] entire match + * [1] 1st marked subexpression + * ... + * [n] nth marked subexpression + * [n+1] unmatched + * [n+2] prefix + * [n+3] suffix + */ + typedef std::vector, _Alloc> _Base_type; + // In debug mode _Base_type is the debug vector, this is the unsafe one: + typedef _GLIBCXX_STD_C::vector, _Alloc> _Unchecked; + typedef std::iterator_traits<_Bi_iter> __iter_traits; + typedef regex_constants::match_flag_type match_flag_type; + + public: + /** + * @name 28.10 Public Types + */ + ///@{ + typedef sub_match<_Bi_iter> value_type; + typedef const value_type& const_reference; + typedef value_type& reference; + typedef typename _Base_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename __iter_traits::difference_type difference_type; + typedef typename allocator_traits<_Alloc>::size_type size_type; + typedef _Alloc allocator_type; + typedef typename __iter_traits::value_type char_type; + typedef std::basic_string string_type; + ///@} + + public: + /** + * @name 28.10.1 Construction, Copying, and Destruction + */ + ///@{ + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + match_results() : match_results(_Alloc()) { } + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + explicit + match_results(const _Alloc& __a) noexcept + : _Base_type(__a) + { } + + /** + * @brief Copy constructs a %match_results. + */ + match_results(const match_results&) = default; + + /** + * @brief Move constructs a %match_results. + */ + match_results(match_results&&) noexcept = default; + + /** + * @brief Assigns rhs to *this. + */ + match_results& + operator=(const match_results&) = default; + + /** + * @brief Move-assigns rhs to *this. + */ + match_results& + operator=(match_results&&) = default; + + /** + * @brief Destroys a %match_results object. + */ + ~match_results() = default; + + ///@} + + // 28.10.2, state: + /** + * @brief Indicates if the %match_results is ready. + * @retval true The object has a fully-established result state. + * @retval false The object is not ready. + */ + bool ready() const noexcept { return !_Unchecked::empty(); } + + /** + * @name 28.10.2 Size + */ + ///@{ + + /** + * @brief Gets the number of matches and submatches. + * + * The number of matches for a given regular expression will be either 0 + * if there was no match or mark_count() + 1 if a match was successful. + * Some matches may be empty. + * + * @returns the number of matches found. + */ + size_type + size() const noexcept + { return _Unchecked::empty() ? 0 : _Unchecked::size() - 3; } + + size_type + max_size() const noexcept + { return _Unchecked::max_size() - 3; } + + /** + * @brief Indicates if the %match_results contains no results. + * @retval true The %match_results object is empty. + * @retval false The %match_results object is not empty. + */ + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _Unchecked::size() <= 3; } + + ///@} + + /** + * @name 28.10.4 Element Access + */ + ///@{ + + /** + * @brief Gets the length of the indicated submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function returns the length of the indicated submatch, or the + * length of the entire match if @p __sub is zero (the default). + */ + difference_type + length(size_type __sub = 0) const + { return (*this)[__sub].length(); } + + /** + * @brief Gets the offset of the beginning of the indicated submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function returns the offset from the beginning of the target + * sequence to the beginning of the submatch, unless the value of @p __sub + * is zero (the default), in which case this function returns the offset + * from the beginning of the target sequence to the beginning of the + * match. + */ + difference_type + position(size_type __sub = 0) const + { return std::distance(_M_begin, (*this)[__sub].first); } + + /** + * @brief Gets the match or submatch converted to a string type. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function gets the submatch (or match, if @p __sub is + * zero) extracted from the target range and converted to the + * associated string type. + */ + string_type + str(size_type __sub = 0) const + { return string_type((*this)[__sub]); } + + /** + * @brief Gets a %sub_match reference for the match or submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function gets a reference to the indicated submatch, or + * the entire match if @p __sub is zero. + * + * If @p __sub >= size() then this function returns a %sub_match with a + * special value indicating no submatch. + */ + const_reference + operator[](size_type __sub) const + { + __glibcxx_assert( ready() ); + return __sub < size() + ? _Unchecked::operator[](__sub) + : _M_unmatched_sub(); + } + + /** + * @brief Gets a %sub_match representing the match prefix. + * @pre ready() == true + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the start of the target range and the + * start of the match. + */ + const_reference + prefix() const + { + __glibcxx_assert( ready() ); + return !empty() ? _M_prefix() : _M_unmatched_sub(); + } + + /** + * @brief Gets a %sub_match representing the match suffix. + * @pre ready() == true + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the end of the match and the end of + * the target range. + */ + const_reference + suffix() const + { + __glibcxx_assert( ready() ); + return !empty() ? _M_suffix() : _M_unmatched_sub(); + } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + begin() const noexcept + { return _Base_type::begin(); } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + cbegin() const noexcept + { return this->begin(); } + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + end() const noexcept + { return _Base_type::end() - (_Base_type::empty() ? 0 : 3); } + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + cend() const noexcept + { return this->end(); } + + ///@} + + /** + * @name 28.10.5 Formatting + * + * These functions perform formatted substitution of the matched + * character sequences into their target. The format specifiers and + * escape sequences accepted by these functions are determined by + * their @p flags parameter as documented above. + */ + ///@{ + + /** + * @pre ready() == true + */ + template + _Out_iter + format(_Out_iter __out, const char_type* __fmt_first, + const char_type* __fmt_last, + match_flag_type __flags = regex_constants::format_default) const; + + /** + * @pre ready() == true + */ + template + _Out_iter + format(_Out_iter __out, const basic_string& __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), + __flags); + } + + /** + * @pre ready() == true + */ + template + basic_string + format(const basic_string& __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + basic_string __result; + format(std::back_inserter(__result), __fmt, __flags); + return __result; + } + + /** + * @pre ready() == true + */ + string_type + format(const char_type* __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + string_type __result; + format(std::back_inserter(__result), + __fmt, + __fmt + char_traits::length(__fmt), + __flags); + return __result; + } + + ///@} + + /** + * @name 28.10.6 Allocator + */ + ///@{ + + /** + * @brief Gets a copy of the allocator. + */ + allocator_type + get_allocator() const noexcept + { return _Base_type::get_allocator(); } + + ///@} + + /** + * @name 28.10.7 Swap + */ + ///@{ + + /** + * @brief Swaps the contents of two match_results. + */ + void + swap(match_results& __that) noexcept + { + using std::swap; + _Base_type::swap(__that); + swap(_M_begin, __that._M_begin); + } + ///@} + + private: + template + friend class regex_iterator; + + /// @cond undocumented + + template + friend class __detail::_Executor; + + template + friend bool + __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, + const basic_regex<_Cp, _Rp>&, + regex_constants::match_flag_type, + __detail::_RegexExecutorPolicy, bool); + + // Reset contents to __size unmatched sub_match objects + // (plus additional objects for prefix, suffix and unmatched sub). + void + _M_resize(unsigned int __size) + { _Unchecked::assign(__size + 3, sub_match<_Bi_iter>{}); } + + // Set state to a failed match for the given past-the-end iterator. + void + _M_establish_failed_match(_Bi_iter __end) + { + sub_match<_Bi_iter> __sm; + __sm.first = __sm.second = __end; + _Unchecked::assign(3, __sm); + } + + const_reference + _M_unmatched_sub() const + { return _Unchecked::operator[](_Unchecked::size() - 3); } + + sub_match<_Bi_iter>& + _M_unmatched_sub() + { return _Unchecked::operator[](_Unchecked::size() - 3); } + + const_reference + _M_prefix() const + { return _Unchecked::operator[](_Unchecked::size() - 2); } + + sub_match<_Bi_iter>& + _M_prefix() + { return _Unchecked::operator[](_Unchecked::size() - 2); } + + const_reference + _M_suffix() const + { return _Unchecked::operator[](_Unchecked::size() - 1); } + + sub_match<_Bi_iter>& + _M_suffix() + { return _Unchecked::operator[](_Unchecked::size() - 1); } + + _Bi_iter _M_begin {}; + /// @endcond + }; + + typedef match_results cmatch; + typedef match_results smatch; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef match_results wcmatch; + typedef match_results wsmatch; +#endif + + // match_results comparisons + + /** + * @brief Compares two match_results for equality. + * @returns true if the two objects refer to the same match, + * false otherwise. + */ + template + inline bool + operator==(const match_results<_Bi_iter, _Alloc>& __m1, + const match_results<_Bi_iter, _Alloc>& __m2) + { + if (__m1.ready() != __m2.ready()) + return false; + if (!__m1.ready()) // both are not ready + return true; + if (__m1.empty() != __m2.empty()) + return false; + if (__m1.empty()) // both are empty + return true; + return __m1.prefix() == __m2.prefix() + && __m1.size() == __m2.size() + && std::equal(__m1.begin(), __m1.end(), __m2.begin()) + && __m1.suffix() == __m2.suffix(); + } + +#if ! __cpp_lib_three_way_comparison + /** + * @brief Compares two match_results for inequality. + * @returns true if the two objects do not refer to the same match, + * false otherwise. + */ + template + inline bool + operator!=(const match_results<_Bi_iter, _Alloc>& __m1, + const match_results<_Bi_iter, _Alloc>& __m2) + { return !(__m1 == __m2); } +#endif + + // [7.10.6] match_results swap + /** + * @brief Swaps two match results. + * @param __lhs A match result. + * @param __rhs A match result. + * + * The contents of the two match_results objects are swapped. + */ + template + inline void + swap(match_results<_Bi_iter, _Alloc>& __lhs, + match_results<_Bi_iter, _Alloc>& __rhs) noexcept + { __lhs.swap(__rhs); } + +_GLIBCXX_END_NAMESPACE_CXX11 + + // [28.11.2] Function template regex_match + /** + * @name Matching, Searching, and Replacing + */ + ///@{ + + /** + * @brief Determines if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param __s Start of the character sequence to match. + * @param __e One-past-the-end of the character sequence to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(_Bi_iter __s, + _Bi_iter __e, + match_results<_Bi_iter, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags, + __detail::_RegexExecutorPolicy::_S_auto, true); + } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param __first Beginning of the character sequence to match. + * @param __last One-past-the-end of the character sequence to match. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_match(__first, __last, __what, __re, __flags); + } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param __s The C-style null-terminated string to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a string. + * + * @param __s The string to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2329. regex_match() with match_results should forbid temporary strings + /// Prevent unsafe attempts to get match_results from a temporary string. + template + bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, + match_results::const_iterator, _Alloc>&, + const basic_regex<_Ch_type, _Rx_traits>&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param __s The C-style null-terminated string to match. + * @param __re The regular expression. + * @param __f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a string. + * + * @param __s [IN] The string to match. + * @param __re [IN] The regular expression. + * @param __flags [IN] Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __re, __flags); } + + // [7.11.3] Function template regex_search + /** + * Searches for a regular expression within a range. + * @param __s [IN] The start of the string to search. + * @param __e [IN] One-past-the-end of the string to search. + * @param __m [OUT] The match results. + * @param __re [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(_Bi_iter __s, _Bi_iter __e, + match_results<_Bi_iter, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return __detail::__regex_algo_impl(__s, __e, __m, __re, __flags, + __detail::_RegexExecutorPolicy::_S_auto, false); + } + + /** + * Searches for a regular expression within a range. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __re [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_search(__first, __last, __what, __re, __flags); + } + + /** + * @brief Searches for a regular expression within a C-string. + * @param __s [IN] A C-string to search for the regex. + * @param __m [OUT] The set of regex matches. + * @param __e [IN] The regex to search for in @p s. + * @param __f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } + + /** + * @brief Searches for a regular expression within a C-string. + * @param __s [IN] The C-string to search. + * @param __e [IN] The regular expression to search for. + * @param __f [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } + + /** + * @brief Searches for a regular expression within a string. + * @param __s [IN] The string to search. + * @param __e [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, + _String_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __e, __flags); } + + /** + * @brief Searches for a regular expression within a string. + * @param __s [IN] A C++ string to search for the regex. + * @param __m [OUT] The set of regex matches. + * @param __e [IN] The regex to search for in @p s. + * @param __f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2329. regex_search() with match_results should forbid temporary strings + /// Prevent unsafe attempts to get match_results from a temporary string. + template + bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, + match_results::const_iterator, _Alloc>&, + const basic_regex<_Ch_type, _Rx_traits>&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + // std [28.11.4] Function template regex_replace + + template + _Out_iter + __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, size_t __len, + regex_constants::match_flag_type __flags); + + /** + * @brief Search for a regular expression within a range for multiple times, + and replace the matched parts through filling a format string. + * @param __out [OUT] The output iterator. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns __out + * @throws an exception of type regex_error. + */ + template + inline _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _St, _Sa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return std::__regex_replace(__out, __first, __last, __e, __fmt.c_str(), + __fmt.length(), __flags); + } + + /** + * @brief Search for a regular expression within a range for multiple times, + and replace the matched parts through filling a format C-string. + * @param __out [OUT] The output iterator. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns __out + * @throws an exception of type regex_error. + */ + template + _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return std::__regex_replace(__out, __first, __last, __e, __fmt, + char_traits<_Ch_type>::length(__fmt), + __flags); + } + + + /** + * @brief Search for a regular expression within a string for multiple times, + and replace the matched parts through filling a format string. + * @param __s [IN] The string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type, _St, _Sa> + regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _Fst, _Fsa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type, _St, _Sa> __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a string for multiple times, + and replace the matched parts through filling a format C-string. + * @param __s [IN] The string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type, _St, _Sa> + regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type, _St, _Sa> __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a C-string for multiple + times, and replace the matched parts through filling a format string. + * @param __s [IN] The C-string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type> + regex_replace(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _St, _Sa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type> __result; + regex_replace(std::back_inserter(__result), __s, + __s + char_traits<_Ch_type>::length(__s), + __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a C-string for multiple + times, and replace the matched parts through filling a format C-string. + * @param __s [IN] The C-string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type> + regex_replace(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type> __result; + regex_replace(std::back_inserter(__result), __s, + __s + char_traits<_Ch_type>::length(__s), + __e, __fmt, __flags); + return __result; + } + + ///@} + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + // std [28.12] Class template regex_iterator + /** + * An iterator adaptor that will provide repeated calls of regex_search over + * a range until no more matches remain. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef match_results<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + /** + * @brief Provides a singular iterator, useful for indicating + * one-past-the-end of a range. + */ + regex_iterator() = default; + + /** + * Constructs a %regex_iterator... + * @param __a [IN] The start of a text range to search. + * @param __b [IN] One-past-the-end of the text range to search. + * @param __re [IN] The regular expression to match. + * @param __m [IN] Policy flags for match rules. + */ + regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_begin(__a), _M_end(__b), _M_pregex(&__re), _M_flags(__m), _M_match() + { + if (!regex_search(_M_begin, _M_end, _M_match, *_M_pregex, _M_flags)) + *this = regex_iterator(); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2332. regex_iterator should forbid temporary regexes + regex_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + /// Copy constructs a %regex_iterator. + regex_iterator(const regex_iterator&) = default; + + /// Copy assigns one %regex_iterator to another. + regex_iterator& + operator=(const regex_iterator&) = default; + + ~regex_iterator() = default; + + /** + * @brief Tests the equivalence of two regex iterators. + */ + bool + operator==(const regex_iterator&) const noexcept; + + /** + * @brief Tests the inequivalence of two regex iterators. + */ + bool + operator!=(const regex_iterator& __rhs) const noexcept + { return !(*this == __rhs); } + + /** + * @brief Dereferences a %regex_iterator. + */ + const value_type& + operator*() const noexcept + { return _M_match; } + + /** + * @brief Selects a %regex_iterator member. + */ + const value_type* + operator->() const noexcept + { return &_M_match; } + + /** + * @brief Increments a %regex_iterator. + */ + regex_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_iterator. + */ + regex_iterator + operator++(int) + { + auto __tmp = *this; + ++(*this); + return __tmp; + } + + private: + _Bi_iter _M_begin {}; + _Bi_iter _M_end {}; + const regex_type* _M_pregex = nullptr; + regex_constants::match_flag_type _M_flags {}; + match_results<_Bi_iter> _M_match; + }; + + typedef regex_iterator cregex_iterator; + typedef regex_iterator sregex_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef regex_iterator wcregex_iterator; + typedef regex_iterator wsregex_iterator; +#endif + + // [7.12.2] Class template regex_token_iterator + /** + * Iterates over submatches in a range (or @a splits a text string). + * + * The purpose of this iterator is to enumerate all, or all specified, + * matches of a regular expression within a text range. The dereferenced + * value of an iterator of this class is a std::sub_match object. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_token_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef sub_match<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Default constructs a %regex_token_iterator. + * + * A default-constructed %regex_token_iterator is a singular iterator + * that will compare equal to the one-past-the-end value for any + * iterator of the same type. + */ + regex_token_iterator() + : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr), + _M_has_m1(false) + { } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatch [IN] Which submatch to return. There are some + * special values for this parameter: + * - -1 each enumerated subexpression does NOT + * match the regular expression (aka field + * splitting) + * - 0 the entire string matching the + * subexpression is returned for each match + * within the text. + * - >0 enumerates only the indicated + * subexpression from a match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + int __submatch = 0, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(1, __submatch), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const std::vector& __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + initializer_list __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + template + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const int (&__submatches)[_Nm], + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), + _M_subs(__submatches, __submatches + _Nm), _M_n(0) + { _M_init(__a, __b); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2332. regex_token_iterator should forbid temporary regexes + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, int = 0, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + const std::vector&, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + initializer_list, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + template + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + const int (&)[_Nm], + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + + /** + * @brief Copy constructs a %regex_token_iterator. + * @param __rhs [IN] A %regex_token_iterator to copy. + */ + regex_token_iterator(const regex_token_iterator& __rhs) + : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs), + _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1) + { _M_normalize_result(); } + + /** + * @brief Assigns a %regex_token_iterator to another. + * @param __rhs [IN] A %regex_token_iterator to copy. + */ + regex_token_iterator& + operator=(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for equality. + */ + bool + operator==(const regex_token_iterator& __rhs) const; + + /** + * @brief Compares a %regex_token_iterator to another for inequality. + */ + bool + operator!=(const regex_token_iterator& __rhs) const + { return !(*this == __rhs); } + + /** + * @brief Dereferences a %regex_token_iterator. + */ + const value_type& + operator*() const + { return *_M_result; } + + /** + * @brief Selects a %regex_token_iterator member. + */ + const value_type* + operator->() const + { return _M_result; } + + /** + * @brief Increments a %regex_token_iterator. + */ + regex_token_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_token_iterator. + */ + regex_token_iterator + operator++(int) + { + auto __tmp = *this; + ++(*this); + return __tmp; + } + + private: + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _Position; + + void + _M_init(_Bi_iter __a, _Bi_iter __b); + + const value_type& + _M_current_match() const + { + if (_M_subs[_M_n] == -1) + return (*_M_position).prefix(); + else + return (*_M_position)[_M_subs[_M_n]]; + } + + constexpr bool + _M_end_of_seq() const + { return _M_result == nullptr; } + + // [28.12.2.2.4] + void + _M_normalize_result() + { + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1) + _M_result = &_M_suffix; + else + _M_result = nullptr; + } + + _Position _M_position; + std::vector _M_subs; + value_type _M_suffix; + std::size_t _M_n; + const value_type* _M_result; + + // Show whether _M_subs contains -1 + bool _M_has_m1; + }; + + /** @brief Token iterator for C-style NULL-terminated strings. */ + typedef regex_token_iterator cregex_token_iterator; + + /** @brief Token iterator for standard strings. */ + typedef regex_token_iterator sregex_token_iterator; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Token iterator for C-style NULL-terminated wide strings. */ + typedef regex_token_iterator wcregex_token_iterator; + + /** @brief Token iterator for standard wide-character strings. */ + typedef regex_token_iterator wsregex_token_iterator; +#endif + + ///@} // group regex + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..81a13ab2c3c283caef86552fb908d0518c103639 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc new file mode 100644 index 0000000000000000000000000000000000000000..2b90b04c560a5fc04602d70e62312d1cbb49b363 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc @@ -0,0 +1,671 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /// @cond undocumented + + // Result of merging regex_match and regex_search. + // + // __policy now can be _S_auto (auto dispatch) and _S_alternate (use + // the other one if possible, for test purpose). + // + // That __match_mode is true means regex_match, else regex_search. + template + bool + __regex_algo_impl(_BiIter __s, + _BiIter __e, + match_results<_BiIter, _Alloc>& __m, + const basic_regex<_CharT, _TraitsT>& __re, + regex_constants::match_flag_type __flags, + _RegexExecutorPolicy __policy, + bool __match_mode) + { + if (__re._M_automaton == nullptr) + return false; + + typename match_results<_BiIter, _Alloc>::_Unchecked& __res = __m; + __m._M_begin = __s; + __m._M_resize(__re._M_automaton->_M_sub_count()); + + bool __ret; + if ((__re.flags() & regex_constants::__polynomial) + || (__policy == _RegexExecutorPolicy::_S_alternate + && !__re._M_automaton->_M_has_backref)) + { + _Executor<_BiIter, _Alloc, _TraitsT, false> + __executor(__s, __e, __res, __re, __flags); + if (__match_mode) + __ret = __executor._M_match(); + else + __ret = __executor._M_search(); + } + else + { + _Executor<_BiIter, _Alloc, _TraitsT, true> + __executor(__s, __e, __res, __re, __flags); + if (__match_mode) + __ret = __executor._M_match(); + else + __ret = __executor._M_search(); + } + if (__ret) + { + for (auto& __it : __res) + if (!__it.matched) + __it.first = __it.second = __e; + auto& __pre = __m._M_prefix(); + auto& __suf = __m._M_suffix(); + if (__match_mode) + { + __pre.matched = false; + __pre.first = __s; + __pre.second = __s; + __suf.matched = false; + __suf.first = __e; + __suf.second = __e; + } + else + { + __pre.first = __s; + __pre.second = __res[0].first; + __pre.matched = (__pre.first != __pre.second); + __suf.first = __res[0].second; + __suf.second = __e; + __suf.matched = (__suf.first != __suf.second); + } + } + else + { + __m._M_establish_failed_match(__e); + } + return __ret; + } + /// @endcond +} // namespace __detail + + /// @cond + + template + template + typename regex_traits<_Ch_type>::string_type + regex_traits<_Ch_type>:: + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + static const char* __collatenames[] = + { + "NUL", + "SOH", + "STX", + "ETX", + "EOT", + "ENQ", + "ACK", + "alert", + "backspace", + "tab", + "newline", + "vertical-tab", + "form-feed", + "carriage-return", + "SO", + "SI", + "DLE", + "DC1", + "DC2", + "DC3", + "DC4", + "NAK", + "SYN", + "ETB", + "CAN", + "EM", + "SUB", + "ESC", + "IS4", + "IS3", + "IS2", + "IS1", + "space", + "exclamation-mark", + "quotation-mark", + "number-sign", + "dollar-sign", + "percent-sign", + "ampersand", + "apostrophe", + "left-parenthesis", + "right-parenthesis", + "asterisk", + "plus-sign", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less-than-sign", + "equals-sign", + "greater-than-sign", + "question-mark", + "commercial-at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "left-square-bracket", + "backslash", + "right-square-bracket", + "circumflex", + "underscore", + "grave-accent", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "left-curly-bracket", + "vertical-line", + "right-curly-bracket", + "tilde", + "DEL", + }; + + string __s; + for (; __first != __last; ++__first) + __s += __fctyp.narrow(*__first, 0); + + for (const auto& __it : __collatenames) + if (__s == __it) + return string_type(1, __fctyp.widen( + static_cast(&__it - __collatenames))); + + // TODO Add digraph support: + // http://boost.sourceforge.net/libs/regex/doc/collating_names.html + + return string_type(); + } + + template + template + typename regex_traits<_Ch_type>::char_class_type + regex_traits<_Ch_type>:: + lookup_classname(_Fwd_iter __first, _Fwd_iter __last, bool __icase) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + // Mappings from class name to class mask. + static const pair __classnames[] = + { + {"d", ctype_base::digit}, + {"w", {ctype_base::alnum, _RegexMask::_S_under}}, + {"s", ctype_base::space}, + {"alnum", ctype_base::alnum}, + {"alpha", ctype_base::alpha}, + {"blank", ctype_base::blank}, + {"cntrl", ctype_base::cntrl}, + {"digit", ctype_base::digit}, + {"graph", ctype_base::graph}, + {"lower", ctype_base::lower}, + {"print", ctype_base::print}, + {"punct", ctype_base::punct}, + {"space", ctype_base::space}, + {"upper", ctype_base::upper}, + {"xdigit", ctype_base::xdigit}, + }; + + string __s; + for (; __first != __last; ++__first) + __s += __fctyp.narrow(__fctyp.tolower(*__first), 0); + + for (const auto& __it : __classnames) + if (__s == __it.first) + { + if (__icase + && ((__it.second + & (ctype_base::lower | ctype_base::upper)) != 0)) + return ctype_base::alpha; + return __it.second; + } + return 0; + } + + template + bool + regex_traits<_Ch_type>:: + isctype(_Ch_type __c, char_class_type __f) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + return __fctyp.is(__f._M_base, __c) + // [[:w:]] + || ((__f._M_extended & _RegexMask::_S_under) + && __c == __fctyp.widen('_')); + } + + template + int + regex_traits<_Ch_type>:: + value(_Ch_type __ch, int __radix) const + { + std::basic_istringstream __is(string_type(1, __ch)); + long __v; + if (__radix == 8) + __is >> std::oct; + else if (__radix == 16) + __is >> std::hex; + __is >> __v; + return __is.fail() ? -1 : __v; + } + + template + template + _Out_iter + match_results<_Bi_iter, _Alloc>:: + format(_Out_iter __out, + const match_results<_Bi_iter, _Alloc>::char_type* __fmt_first, + const match_results<_Bi_iter, _Alloc>::char_type* __fmt_last, + match_flag_type __flags) const + { + __glibcxx_assert( ready() ); + regex_traits __traits; + typedef std::ctype __ctype_type; + const __ctype_type& + __fctyp(use_facet<__ctype_type>(__traits.getloc())); + + auto __output = [&](size_t __idx) + { + auto& __sub = (*this)[__idx]; + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + }; + + if (__flags & regex_constants::format_sed) + { + bool __escaping = false; + for (; __fmt_first != __fmt_last; __fmt_first++) + { + if (__escaping) + { + __escaping = false; + if (__fctyp.is(__ctype_type::digit, *__fmt_first)) + __output(__traits.value(*__fmt_first, 10)); + else + *__out++ = *__fmt_first; + continue; + } + if (*__fmt_first == '\\') + { + __escaping = true; + continue; + } + if (*__fmt_first == '&') + { + __output(0); + continue; + } + *__out++ = *__fmt_first; + } + if (__escaping) + *__out++ = '\\'; + } + else + { + while (1) + { + auto __next = std::find(__fmt_first, __fmt_last, '$'); + if (__next == __fmt_last) + break; + + __out = std::copy(__fmt_first, __next, __out); + + auto __eat = [&](char __ch) -> bool + { + if (*__next == __ch) + { + ++__next; + return true; + } + return false; + }; + + if (++__next == __fmt_last) + *__out++ = '$'; + else if (__eat('$')) + *__out++ = '$'; + else if (__eat('&')) + __output(0); + else if (__eat('`')) + { + auto& __sub = _M_prefix(); + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + } + else if (__eat('\'')) + { + auto& __sub = _M_suffix(); + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + } + else if (__fctyp.is(__ctype_type::digit, *__next)) + { + long __num = __traits.value(*__next, 10); + if (++__next != __fmt_last + && __fctyp.is(__ctype_type::digit, *__next)) + { + __num *= 10; + __num += __traits.value(*__next++, 10); + } + if (0 <= __num && __num < this->size()) + __output(__num); + } + else + *__out++ = '$'; + __fmt_first = __next; + } + __out = std::copy(__fmt_first, __fmt_last, __out); + } + return __out; + } + + template + _Out_iter + __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, size_t __len, + regex_constants::match_flag_type __flags) + { + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _IterT; + _IterT __i(__first, __last, __e, __flags); + _IterT __end; + if (__i == __end) + { + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__first, __last, __out); + } + else + { + sub_match<_Bi_iter> __last; + for (; __i != __end; ++__i) + { + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__i->prefix().first, __i->prefix().second, + __out); + __out = __i->format(__out, __fmt, __fmt + __len, __flags); + __last = __i->suffix(); + if (__flags & regex_constants::format_first_only) + break; + } + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__last.first, __last.second, __out); + } + return __out; + } + + template + bool + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator==(const regex_iterator& __rhs) const noexcept + { + if (_M_pregex == nullptr && __rhs._M_pregex == nullptr) + return true; + return _M_pregex == __rhs._M_pregex + && _M_begin == __rhs._M_begin + && _M_end == __rhs._M_end + && _M_flags == __rhs._M_flags + && _M_match[0] == __rhs._M_match[0]; + } + + template + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator++() + { + // In all cases in which the call to regex_search returns true, + // match.prefix().first shall be equal to the previous value of + // match[0].second, and for each index i in the half-open range + // [0, match.size()) for which match[i].matched is true, + // match[i].position() shall return distance(begin, match[i].first). + // [28.12.1.4.5] + if (_M_match[0].matched) + { + auto __start = _M_match[0].second; + auto __prefix_first = _M_match[0].second; + if (_M_match[0].first == _M_match[0].second) + { + if (__start == _M_end) + { + _M_pregex = nullptr; + return *this; + } + else + { + if (regex_search(__start, _M_end, _M_match, *_M_pregex, + _M_flags + | regex_constants::match_not_null + | regex_constants::match_continuous)) + { + __glibcxx_assert(_M_match[0].matched); + auto& __prefix = _M_match._M_prefix(); + __prefix.first = __prefix_first; + __prefix.matched = __prefix.first != __prefix.second; + // [28.12.1.4.5] + _M_match._M_begin = _M_begin; + return *this; + } + else + ++__start; + } + } + _M_flags |= regex_constants::match_prev_avail; + if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags)) + { + __glibcxx_assert(_M_match[0].matched); + auto& __prefix = _M_match._M_prefix(); + __prefix.first = __prefix_first; + __prefix.matched = __prefix.first != __prefix.second; + // [28.12.1.4.5] + _M_match._M_begin = _M_begin; + } + else + _M_pregex = nullptr; + } + return *this; + } + + template + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator=(const regex_token_iterator& __rhs) + { + _M_position = __rhs._M_position; + _M_subs = __rhs._M_subs; + _M_n = __rhs._M_n; + _M_suffix = __rhs._M_suffix; + _M_has_m1 = __rhs._M_has_m1; + _M_normalize_result(); + return *this; + } + + template + bool + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator==(const regex_token_iterator& __rhs) const + { + if (_M_end_of_seq() && __rhs._M_end_of_seq()) + return true; + if (_M_suffix.matched && __rhs._M_suffix.matched + && _M_suffix == __rhs._M_suffix) + return true; + if (_M_end_of_seq() || _M_suffix.matched + || __rhs._M_end_of_seq() || __rhs._M_suffix.matched) + return false; + return _M_position == __rhs._M_position + && _M_n == __rhs._M_n + && _M_subs == __rhs._M_subs; + } + + template + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator++() + { + _Position __prev = _M_position; + if (_M_suffix.matched) + *this = regex_token_iterator(); + else if (_M_n + 1 < _M_subs.size()) + { + _M_n++; + _M_result = &_M_current_match(); + } + else + { + _M_n = 0; + ++_M_position; + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1 && __prev->suffix().length() != 0) + { + _M_suffix.matched = true; + _M_suffix.first = __prev->suffix().first; + _M_suffix.second = __prev->suffix().second; + _M_result = &_M_suffix; + } + else + *this = regex_token_iterator(); + } + return *this; + } + + template + void + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + _M_init(_Bi_iter __a, _Bi_iter __b) + { + _M_has_m1 = false; + for (auto __it : _M_subs) + if (__it == -1) + { + _M_has_m1 = true; + break; + } + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1) + { + _M_suffix.matched = true; + _M_suffix.first = __a; + _M_suffix.second = __b; + _M_result = &_M_suffix; + } + else + _M_result = nullptr; + } + + /// @endcond + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..c9bf0f3dd4e933df473687d8d5546489938ac619 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h new file mode 100644 index 0000000000000000000000000000000000000000..f95eb7dad6d8b0a7c2c0ac056bb03c6d955ba750 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h @@ -0,0 +1,400 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_automaton.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// This macro defines the maximal state number a NFA can have. +#ifndef _GLIBCXX_REGEX_STATE_LIMIT +#define _GLIBCXX_REGEX_STATE_LIMIT 100000 +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @defgroup regex-detail Base and Implementation Classes + * @ingroup regex + * @{ + */ + + typedef long _StateIdT; + static const _StateIdT _S_invalid_state_id = -1; + + template + using _Matcher = std::function; + + /// Operation codes that define the type of transitions within the base NFA + /// that represents the regular expression. + enum _Opcode : int + { + _S_opcode_unknown, + _S_opcode_alternative, + _S_opcode_repeat, + _S_opcode_backref, + _S_opcode_line_begin_assertion, + _S_opcode_line_end_assertion, + _S_opcode_word_boundary, + _S_opcode_subexpr_lookahead, + _S_opcode_subexpr_begin, + _S_opcode_subexpr_end, + _S_opcode_dummy, + _S_opcode_match, + _S_opcode_accept, + }; + + struct _State_base + { + protected: + _Opcode _M_opcode; // type of outgoing transition + + public: + _StateIdT _M_next; // outgoing transition + union // Since they are mutually exclusive. + { + size_t _M_subexpr; // for _S_opcode_subexpr_* + size_t _M_backref_index; // for _S_opcode_backref + struct + { + // for _S_opcode_alternative, _S_opcode_repeat and + // _S_opcode_subexpr_lookahead + _StateIdT _M_alt; + // for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or + // quantifiers (ungreedy if set true) + bool _M_neg; + }; + // For _S_opcode_match + __gnu_cxx::__aligned_membuf<_Matcher> _M_matcher_storage; + }; + + protected: + explicit _State_base(_Opcode __opcode) noexcept + : _M_opcode(__opcode), _M_next(_S_invalid_state_id) + { } + + public: + bool + _M_has_alt() const noexcept + { + return _M_opcode == _S_opcode_alternative + || _M_opcode == _S_opcode_repeat + || _M_opcode == _S_opcode_subexpr_lookahead; + } + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_print(std::ostream& ostr) const; + + // Prints graphviz dot commands for state. + std::ostream& + _M_dot(std::ostream& __ostr, _StateIdT __id) const; +#endif + }; + + template + struct _State : _State_base + { + typedef _Matcher<_Char_type> _MatcherT; + static_assert(sizeof(_MatcherT) == sizeof(_Matcher), + "std::function has the same size as " + "std::function"); + static_assert(alignof(_MatcherT) == alignof(_Matcher), + "std::function has the same alignment as " + "std::function"); + + explicit + _State(_Opcode __opcode) noexcept : _State_base(__opcode) + { + if (_M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) _MatcherT(); + } + + _State(const _State& __rhs) : _State_base(__rhs) + { + if (__rhs._M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) + _MatcherT(__rhs._M_get_matcher()); + } + + _State(_State&& __rhs) noexcept : _State_base(__rhs) + { + if (__rhs._M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) + _MatcherT(std::move(__rhs._M_get_matcher())); + } + + _State& + operator=(const _State&) = delete; + + ~_State() + { + if (_M_opcode() == _S_opcode_match) + _M_get_matcher().~_MatcherT(); + } + + // Since correct ctor and dtor rely on _M_opcode, it's better not to + // change it over time. + _Opcode + _M_opcode() const noexcept + { return _State_base::_M_opcode; } + + bool + _M_matches(_Char_type __char) const + { return _M_get_matcher()(__char); } + + _MatcherT& + _M_get_matcher() noexcept + { return *static_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); } + + const _MatcherT& + _M_get_matcher() const noexcept + { + return *static_cast( + this->_M_matcher_storage._M_addr()); + } + }; + + struct _NFA_base + { + typedef regex_constants::syntax_option_type _FlagT; + + explicit + _NFA_base(_FlagT __f) noexcept + : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0), + _M_has_backref(false) + { } + + _NFA_base(_NFA_base&&) = default; + + protected: + ~_NFA_base() = default; + + public: + _FlagT + _M_options() const noexcept + { return _M_flags; } + + _StateIdT + _M_start() const noexcept + { return _M_start_state; } + + size_t + _M_sub_count() const noexcept + { return _M_subexpr_count; } + + _GLIBCXX_STD_C::vector _M_paren_stack; + _FlagT _M_flags; + _StateIdT _M_start_state; + size_t _M_subexpr_count; + bool _M_has_backref; + }; + + template + struct _NFA + : _NFA_base, _GLIBCXX_STD_C::vector<_State> + { + typedef typename _TraitsT::char_type _Char_type; + typedef _State<_Char_type> _StateT; + typedef _Matcher<_Char_type> _MatcherT; + + _NFA(const typename _TraitsT::locale_type& __loc, _FlagT __flags) + : _NFA_base(__flags) + { _M_traits.imbue(__loc); } + + // for performance reasons _NFA objects should only be moved not copied + _NFA(const _NFA&) = delete; + _NFA(_NFA&&) = default; + + _StateIdT + _M_insert_accept() + { + auto __ret = _M_insert_state(_StateT(_S_opcode_accept)); + return __ret; + } + + _StateIdT + _M_insert_alt(_StateIdT __next, _StateIdT __alt, + bool __neg __attribute__((__unused__))) + { + _StateT __tmp(_S_opcode_alternative); + // It labels every quantifier to make greedy comparison easier in BFS + // approach. + __tmp._M_next = __next; + __tmp._M_alt = __alt; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_repeat(_StateIdT __next, _StateIdT __alt, bool __neg) + { + _StateT __tmp(_S_opcode_repeat); + // It labels every quantifier to make greedy comparison easier in BFS + // approach. + __tmp._M_next = __next; + __tmp._M_alt = __alt; + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_matcher(_MatcherT __m) + { + _StateT __tmp(_S_opcode_match); + __tmp._M_get_matcher() = std::move(__m); + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_subexpr_begin() + { + auto __id = this->_M_subexpr_count++; + this->_M_paren_stack.push_back(__id); + _StateT __tmp(_S_opcode_subexpr_begin); + __tmp._M_subexpr = __id; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_subexpr_end() + { + _StateT __tmp(_S_opcode_subexpr_end); + __tmp._M_subexpr = this->_M_paren_stack.back(); + this->_M_paren_stack.pop_back(); + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_backref(size_t __index); + + _StateIdT + _M_insert_line_begin() + { return _M_insert_state(_StateT(_S_opcode_line_begin_assertion)); } + + _StateIdT + _M_insert_line_end() + { return _M_insert_state(_StateT(_S_opcode_line_end_assertion)); } + + _StateIdT + _M_insert_word_bound(bool __neg) + { + _StateT __tmp(_S_opcode_word_boundary); + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_lookahead(_StateIdT __alt, bool __neg) + { + _StateT __tmp(_S_opcode_subexpr_lookahead); + __tmp._M_alt = __alt; + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_dummy() + { return _M_insert_state(_StateT(_S_opcode_dummy)); } + + _StateIdT + _M_insert_state(_StateT __s) + { + this->push_back(std::move(__s)); + if (this->size() > _GLIBCXX_REGEX_STATE_LIMIT) + __throw_regex_error( + regex_constants::error_space, + "Number of NFA states exceeds limit. Please use shorter regex " + "string, or use smaller brace expression, or make " + "_GLIBCXX_REGEX_STATE_LIMIT larger."); + return this->size() - 1; + } + + // Eliminate dummy node in this NFA to make it compact. + void + _M_eliminate_dummy(); + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_dot(std::ostream& __ostr) const; +#endif + public: + _TraitsT _M_traits; + }; + + /// Describes a sequence of one or more %_State, its current start + /// and end(s). This structure contains fragments of an NFA during + /// construction. + template + class _StateSeq + { + public: + typedef _NFA<_TraitsT> _RegexT; + + public: + _StateSeq(_RegexT& __nfa, _StateIdT __s) + : _M_nfa(__nfa), _M_start(__s), _M_end(__s) + { } + + _StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end) + : _M_nfa(__nfa), _M_start(__s), _M_end(__end) + { } + + // Append a state on *this and change *this to the new sequence. + void + _M_append(_StateIdT __id) + { + _M_nfa[_M_end]._M_next = __id; + _M_end = __id; + } + + // Append a sequence on *this and change *this to the new sequence. + void + _M_append(const _StateSeq& __s) + { + _M_nfa[_M_end]._M_next = __s._M_start; + _M_end = __s._M_end; + } + + // Clones an entire sequence. + _StateSeq + _M_clone(); + + public: + _RegexT& _M_nfa; + _StateIdT _M_start; + _StateIdT _M_end; + }; + + ///@} regex-detail +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..185a7977b93d04d14a959339d099f8876adb9361 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc new file mode 100644 index 0000000000000000000000000000000000000000..caaf3c40774592f02951ed16f63397e4d0209e06 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc @@ -0,0 +1,232 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_automaton.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ +#ifdef _GLIBCXX_DEBUG + inline std::ostream& + _State_base::_M_print(std::ostream& ostr) const + { + switch (_M_opcode) + { + case _S_opcode_alternative: + case _S_opcode_repeat: + ostr << "alt next=" << _M_next << " alt=" << _M_alt; + break; + case _S_opcode_subexpr_begin: + ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_subexpr_end: + ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_backref: + ostr << "backref next=" << _M_next << " index=" << _M_backref_index; + break; + case _S_opcode_match: + ostr << "match next=" << _M_next; + break; + case _S_opcode_accept: + ostr << "accept next=" << _M_next; + break; + default: + ostr << "unknown next=" << _M_next; + break; + } + return ostr; + } + + // Prints graphviz dot commands for state. + inline std::ostream& + _State_base::_M_dot(std::ostream& __ostr, _StateIdT __id) const + { + switch (_M_opcode) + { + case _S_opcode_alternative: + case _S_opcode_repeat: + __ostr << __id << " [label=\"" << __id << "\\nALT\"];\n" + << __id << " -> " << _M_next + << " [label=\"next\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"alt\", tailport=\"n\"];\n"; + break; + case _S_opcode_backref: + __ostr << __id << " [label=\"" << __id << "\\nBACKREF " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_line_begin_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_BEGIN \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_line_end_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_END \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_word_boundary: + __ostr << __id << " [label=\"" << __id << "\\nWORD_BOUNDRY " + << _M_neg << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_lookahead: + __ostr << __id << " [label=\"" << __id << "\\nLOOK_AHEAD\"];\n" + << __id << " -> " << _M_next + << " [label=\"epsilon\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"\", tailport=\"n\"];\n"; + break; + case _S_opcode_subexpr_begin: + __ostr << __id << " [label=\"" << __id << "\\nSBEGIN " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_end: + __ostr << __id << " [label=\"" << __id << "\\nSEND " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_dummy: + break; + case _S_opcode_match: + __ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_accept: + __ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ; + break; + default: + _GLIBCXX_DEBUG_ASSERT(false); + break; + } + return __ostr; + } + + template + std::ostream& + _NFA<_TraitsT>::_M_dot(std::ostream& __ostr) const + { + __ostr << "digraph _Nfa {\n" + " rankdir=LR;\n"; + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i]._M_dot(__ostr, __i); + __ostr << "}\n"; + return __ostr; + } +#endif + + template + _StateIdT + _NFA<_TraitsT>::_M_insert_backref(size_t __index) + { + if (this->_M_flags & regex_constants::__polynomial) + __throw_regex_error(regex_constants::error_complexity, + "Unexpected back-reference in polynomial mode."); + // To figure out whether a backref is valid, a stack is used to store + // unfinished sub-expressions. For example, when parsing + // "(a(b)(c\\1(d)))" at '\\1', _M_subexpr_count is 3, indicating that 3 + // sub expressions are parsed or partially parsed(in the stack), aka, + // "(a..", "(b)" and "(c.."). + // _M_paren_stack is {1, 3}, for incomplete "(a.." and "(c..". At this + // time, "\\2" is valid, but "\\1" and "\\3" are not. + if (__index >= _M_subexpr_count) + __throw_regex_error( + regex_constants::error_backref, + "Back-reference index exceeds current sub-expression count."); + for (auto __it : this->_M_paren_stack) + if (__index == __it) + __throw_regex_error( + regex_constants::error_backref, + "Back-reference referred to an opened sub-expression."); + this->_M_has_backref = true; + _StateT __tmp(_S_opcode_backref); + __tmp._M_backref_index = __index; + return _M_insert_state(std::move(__tmp)); + } + + template + void + _NFA<_TraitsT>::_M_eliminate_dummy() + { + for (auto& __it : *this) + { + while (__it._M_next >= 0 && (*this)[__it._M_next]._M_opcode() + == _S_opcode_dummy) + __it._M_next = (*this)[__it._M_next]._M_next; + if (__it._M_has_alt()) + while (__it._M_alt >= 0 && (*this)[__it._M_alt]._M_opcode() + == _S_opcode_dummy) + __it._M_alt = (*this)[__it._M_alt]._M_next; + } + } + + // Just apply DFS on the sequence and re-link their links. + template + _StateSeq<_TraitsT> + _StateSeq<_TraitsT>::_M_clone() + { + _GLIBCXX_STD_C::map<_StateIdT, _StateIdT> __m; + std::stack<_StateIdT, _GLIBCXX_STD_C::deque<_StateIdT>> __stack; + __stack.push(_M_start); + while (!__stack.empty()) + { + auto __u = __stack.top(); + __stack.pop(); + auto __dup = _M_nfa[__u]; + // _M_insert_state() never return -1 + auto __id = _M_nfa._M_insert_state(std::move(__dup)); + __m[__u] = __id; + if (__dup._M_has_alt()) + if (__dup._M_alt != _S_invalid_state_id + && __m.count(__dup._M_alt) == 0) + __stack.push(__dup._M_alt); + if (__u == _M_end) + continue; + if (__dup._M_next != _S_invalid_state_id + && __m.count(__dup._M_next) == 0) + __stack.push(__dup._M_next); + } + for (auto __it : __m) + { + auto __v = __it.second; + auto& __ref = _M_nfa[__v]; + if (__ref._M_next != _S_invalid_state_id) + __ref._M_next = __m.find(__ref._M_next)->second; + if (__ref._M_has_alt() && __ref._M_alt != _S_invalid_state_id) + __ref._M_alt = __m.find(__ref._M_alt)->second; + } + return _StateSeq(_M_nfa, __m[_M_start], __m[_M_end]); + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..3ba5b031f65e96ffa45b56aae8882716b43e7b8e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_automaton.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h new file mode 100644 index 0000000000000000000000000000000000000000..348c170c81a950dedd1672f5ec4003fa254718c1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h @@ -0,0 +1,571 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_compiler.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + template + class regex_traits; + +_GLIBCXX_END_NAMESPACE_CXX11 + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + template + struct _BracketMatcher; + + /** + * @brief Builds an NFA from an input iterator range. + * + * The %_TraitsT type should fulfill requirements [28.3]. + */ + template + class _Compiler + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef _NFA<_TraitsT> _RegexT; + typedef regex_constants::syntax_option_type _FlagT; + + _Compiler(const _CharT* __b, const _CharT* __e, + const typename _TraitsT::locale_type& __traits, _FlagT __flags); + + shared_ptr + _M_get_nfa() noexcept + { return std::move(_M_nfa); } + + private: + typedef _Scanner<_CharT> _ScannerT; + typedef typename _TraitsT::string_type _StringT; + typedef typename _ScannerT::_TokenT _TokenT; + typedef _StateSeq<_TraitsT> _StateSeqT; + typedef std::stack<_StateSeqT> _StackT; + typedef std::ctype<_CharT> _CtypeT; + + // accepts a specific token or returns false. + bool + _M_match_token(_TokenT __token); + + void + _M_disjunction(); + + void + _M_alternative(); + + bool + _M_term(); + + bool + _M_assertion(); + + bool + _M_quantifier(); + + bool + _M_atom(); + + bool + _M_bracket_expression(); + + template + void + _M_insert_any_matcher_ecma(); + + template + void + _M_insert_any_matcher_posix(); + + template + void + _M_insert_char_matcher(); + + template + void + _M_insert_character_class_matcher(); + + template + void + _M_insert_bracket_matcher(bool __neg); + + // Cache of the last atom seen in a bracketed range expression. + struct _BracketState + { + enum class _Type : char { _None, _Char, _Class } _M_type = _Type::_None; + _CharT _M_char = _CharT(); + + void + set(_CharT __c) noexcept { _M_type = _Type::_Char; _M_char = __c; } + + _GLIBCXX_NODISCARD _CharT + get() const noexcept { return _M_char; } + + void + reset(_Type __t = _Type::_None) noexcept { _M_type = __t; } + + explicit operator bool() const noexcept + { return _M_type != _Type::_None; } + + // Previous token was a single character. + _GLIBCXX_NODISCARD bool + _M_is_char() const noexcept { return _M_type == _Type::_Char; } + + // Previous token was a character class, equivalent class, + // collating symbol etc. + _GLIBCXX_NODISCARD bool + _M_is_class() const noexcept { return _M_type == _Type::_Class; } + }; + + template + using _BracketMatcher + = std::__detail::_BracketMatcher<_TraitsT, __icase, __collate>; + + // Returns true if successfully parsed one term and should continue + // compiling a bracket expression. + // Returns false if the compiler should move on. + template + bool + _M_expression_term(_BracketState& __last_char, + _BracketMatcher<__icase, __collate>& __matcher); + + int + _M_cur_int_value(int __radix); + + bool + _M_try_char(); + + _StateSeqT + _M_pop() + { + auto ret = _M_stack.top(); + _M_stack.pop(); + return ret; + } + + static _FlagT + _S_validate(_FlagT __f) + { + using namespace regex_constants; + switch (__f & (ECMAScript|basic|extended|awk|grep|egrep)) + { + case ECMAScript: + case basic: + case extended: + case awk: + case grep: + case egrep: + return __f; + case _FlagT(0): + return __f | ECMAScript; + default: + std::__throw_regex_error(_S_grammar, "conflicting grammar options"); + } + } + + _FlagT _M_flags; + _ScannerT _M_scanner; + shared_ptr<_RegexT> _M_nfa; + _StringT _M_value; + _StackT _M_stack; + const _TraitsT& _M_traits; + const _CtypeT& _M_ctype; + }; + + // [28.13.14] + template + class _RegexTranslatorBase + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef typename _TraitsT::string_type _StringT; + typedef _StringT _StrTransT; + + explicit + _RegexTranslatorBase(const _TraitsT& __traits) + : _M_traits(__traits) + { } + + _CharT + _M_translate(_CharT __ch) const + { + if _GLIBCXX17_CONSTEXPR (__icase) + return _M_traits.translate_nocase(__ch); + else if _GLIBCXX17_CONSTEXPR (__collate) + return _M_traits.translate(__ch); + else + return __ch; + } + + _StrTransT + _M_transform(_CharT __ch) const + { + _StrTransT __str(1, __ch); + return _M_traits.transform(__str.begin(), __str.end()); + } + + // See LWG 523. It's not efficiently implementable when _TraitsT is not + // std::regex_traits<>, and __collate is true. See specializations for + // implementations of other cases. + bool + _M_match_range(const _StrTransT& __first, const _StrTransT& __last, + const _StrTransT& __s) const + { return __first <= __s && __s <= __last; } + + protected: + bool _M_in_range_icase(_CharT __first, _CharT __last, _CharT __ch) const + { + typedef std::ctype<_CharT> __ctype_type; + const auto& __fctyp = use_facet<__ctype_type>(this->_M_traits.getloc()); + auto __lower = __fctyp.tolower(__ch); + auto __upper = __fctyp.toupper(__ch); + return (__first <= __lower && __lower <= __last) + || (__first <= __upper && __upper <= __last); + } + + const _TraitsT& _M_traits; + }; + + template + class _RegexTranslator + : public _RegexTranslatorBase<_TraitsT, __icase, __collate> + { + public: + typedef _RegexTranslatorBase<_TraitsT, __icase, __collate> _Base; + using _Base::_Base; + }; + + template + class _RegexTranslator<_TraitsT, __icase, false> + : public _RegexTranslatorBase<_TraitsT, __icase, false> + { + public: + typedef _RegexTranslatorBase<_TraitsT, __icase, false> _Base; + typedef typename _Base::_CharT _CharT; + typedef _CharT _StrTransT; + + using _Base::_Base; + + _StrTransT + _M_transform(_CharT __ch) const + { return __ch; } + + bool + _M_match_range(_CharT __first, _CharT __last, _CharT __ch) const + { + if _GLIBCXX17_CONSTEXPR (!__icase) + return __first <= __ch && __ch <= __last; + else + return this->_M_in_range_icase(__first, __last, __ch); + } + }; + + template + class _RegexTranslator, true, true> + : public _RegexTranslatorBase, true, true> + { + public: + typedef _RegexTranslatorBase, true, true> + _Base; + typedef typename _Base::_CharT _CharT; + typedef typename _Base::_StrTransT _StrTransT; + + using _Base::_Base; + + bool + _M_match_range(const _StrTransT& __first, const _StrTransT& __last, + const _StrTransT& __str) const + { + __glibcxx_assert(__first.size() == 1); + __glibcxx_assert(__last.size() == 1); + __glibcxx_assert(__str.size() == 1); + return this->_M_in_range_icase(__first[0], __last[0], __str[0]); + } + }; + + template + class _RegexTranslator<_TraitsT, false, false> + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef _CharT _StrTransT; + + explicit + _RegexTranslator(const _TraitsT&) + { } + + _CharT + _M_translate(_CharT __ch) const + { return __ch; } + + _StrTransT + _M_transform(_CharT __ch) const + { return __ch; } + + bool + _M_match_range(_CharT __first, _CharT __last, _CharT __ch) const + { return __first <= __ch && __ch <= __last; } + }; + + template + struct _AnyMatcher; + + template + struct _AnyMatcher<_TraitsT, false, __icase, __collate> + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + explicit + _AnyMatcher(const _TraitsT& __traits) + : _M_translator(__traits) + { } + + bool + operator()(_CharT __ch) const + { + static auto __nul = _M_translator._M_translate('\0'); + return _M_translator._M_translate(__ch) != __nul; + } + + _TransT _M_translator; + }; + + template + struct _AnyMatcher<_TraitsT, true, __icase, __collate> + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + explicit + _AnyMatcher(const _TraitsT& __traits) + : _M_translator(__traits) + { } + + bool + operator()(_CharT __ch) const + { return _M_apply(__ch, typename is_same<_CharT, char>::type()); } + + bool + _M_apply(_CharT __ch, true_type) const + { + auto __c = _M_translator._M_translate(__ch); + auto __n = _M_translator._M_translate('\n'); + auto __r = _M_translator._M_translate('\r'); + return __c != __n && __c != __r; + } + + bool + _M_apply(_CharT __ch, false_type) const + { + auto __c = _M_translator._M_translate(__ch); + auto __n = _M_translator._M_translate('\n'); + auto __r = _M_translator._M_translate('\r'); + auto __u2028 = _M_translator._M_translate(u'\u2028'); + auto __u2029 = _M_translator._M_translate(u'\u2029'); + return __c != __n && __c != __r && __c != __u2028 && __c != __u2029; + } + + _TransT _M_translator; + }; + + template + struct _CharMatcher + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + _CharMatcher(_CharT __ch, const _TraitsT& __traits) + : _M_translator(__traits), _M_ch(_M_translator._M_translate(__ch)) + { } + + bool + operator()(_CharT __ch) const + { return _M_ch == _M_translator._M_translate(__ch); } + + _TransT _M_translator; + _CharT _M_ch; + }; + + /// Matches a character range (bracket expression) + template + struct _BracketMatcher + { + public: + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + typedef typename _TransT::_StrTransT _StrTransT; + typedef typename _TraitsT::string_type _StringT; + typedef typename _TraitsT::char_class_type _CharClassT; + + public: + _BracketMatcher(bool __is_non_matching, + const _TraitsT& __traits) + : _M_class_set(0), _M_translator(__traits), _M_traits(__traits), + _M_is_non_matching(__is_non_matching) + { } + + bool + operator()(_CharT __ch) const + { + _GLIBCXX_DEBUG_ASSERT(_M_is_ready); + return _M_apply(__ch, _UseCache()); + } + + void + _M_add_char(_CharT __c) + { + _M_char_set.push_back(_M_translator._M_translate(__c)); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + _StringT + _M_add_collate_element(const _StringT& __s) + { + auto __st = _M_traits.lookup_collatename(__s.data(), + __s.data() + __s.size()); + if (__st.empty()) + __throw_regex_error(regex_constants::error_collate, + "Invalid collate element."); + _M_char_set.push_back(_M_translator._M_translate(__st[0])); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + return __st; + } + + void + _M_add_equivalence_class(const _StringT& __s) + { + auto __st = _M_traits.lookup_collatename(__s.data(), + __s.data() + __s.size()); + if (__st.empty()) + __throw_regex_error(regex_constants::error_collate, + "Invalid equivalence class."); + __st = _M_traits.transform_primary(__st.data(), + __st.data() + __st.size()); + _M_equiv_set.push_back(__st); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + // __neg should be true for \D, \S and \W only. + void + _M_add_character_class(const _StringT& __s, bool __neg) + { + auto __mask = _M_traits.lookup_classname(__s.data(), + __s.data() + __s.size(), + __icase); + if (__mask == 0) + __throw_regex_error(regex_constants::error_collate, + "Invalid character class."); + if (!__neg) + _M_class_set |= __mask; + else + _M_neg_class_set.push_back(__mask); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + void + _M_make_range(_CharT __l, _CharT __r) + { + if (__l > __r) + __throw_regex_error(regex_constants::error_range, + "Invalid range in bracket expression."); + _M_range_set.push_back(make_pair(_M_translator._M_transform(__l), + _M_translator._M_transform(__r))); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + void + _M_ready() + { + std::sort(_M_char_set.begin(), _M_char_set.end()); + auto __end = std::unique(_M_char_set.begin(), _M_char_set.end()); + _M_char_set.erase(__end, _M_char_set.end()); + _M_make_cache(_UseCache()); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = true); + } + + private: + // Currently we only use the cache for char + using _UseCache = typename std::is_same<_CharT, char>::type; + + static constexpr size_t + _S_cache_size = + 1ul << (sizeof(_CharT) * __CHAR_BIT__ * int(_UseCache::value)); + + struct _Dummy { }; + using _CacheT = std::__conditional_t<_UseCache::value, + std::bitset<_S_cache_size>, + _Dummy>; + using _UnsignedCharT = typename std::make_unsigned<_CharT>::type; + + bool + _M_apply(_CharT __ch, false_type) const; + + bool + _M_apply(_CharT __ch, true_type) const + { return _M_cache[static_cast<_UnsignedCharT>(__ch)]; } + + void + _M_make_cache(true_type) + { + for (unsigned __i = 0; __i < _M_cache.size(); __i++) + _M_cache[__i] = _M_apply(static_cast<_CharT>(__i), false_type()); + } + + void + _M_make_cache(false_type) + { } + + private: + _GLIBCXX_STD_C::vector<_CharT> _M_char_set; + _GLIBCXX_STD_C::vector<_StringT> _M_equiv_set; + _GLIBCXX_STD_C::vector> _M_range_set; + _GLIBCXX_STD_C::vector<_CharClassT> _M_neg_class_set; + _CharClassT _M_class_set; + _TransT _M_translator; + const _TraitsT& _M_traits; + bool _M_is_non_matching; + _CacheT _M_cache; +#ifdef _GLIBCXX_DEBUG + bool _M_is_ready = false; +#endif + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..abf1ec51b10687690446955210aa58fe2738399d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc new file mode 100644 index 0000000000000000000000000000000000000000..c12f750253830959a20f9e195780b9617c3669a0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc @@ -0,0 +1,622 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_compiler.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME make comments doxygen format. + +/* +// This compiler refers to "Regular Expression Matching Can Be Simple And Fast" +// (http://swtch.com/~rsc/regexp/regexp1.html), +// but doesn't strictly follow it. +// +// When compiling, states are *chained* instead of tree- or graph-constructed. +// It's more like structured programs: there's if statement and loop statement. +// +// For alternative structure (say "a|b"), aka "if statement", two branches +// should be constructed. However, these two shall merge to an "end_tag" at +// the end of this operator: +// +// branch1 +// / \ +// => begin_tag end_tag => +// \ / +// branch2 +// +// This is the difference between this implementation and that in Russ's +// article. +// +// That's why we introduced dummy node here ------ "end_tag" is a dummy node. +// All dummy nodes will be eliminated at the end of compilation. +*/ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + _Compiler<_TraitsT>:: + _Compiler(const _CharT* __b, const _CharT* __e, + const typename _TraitsT::locale_type& __loc, _FlagT __flags) + : _M_flags(_S_validate(__flags)), + _M_scanner(__b, __e, _M_flags, __loc), + _M_nfa(make_shared<_RegexT>(__loc, _M_flags)), + _M_traits(_M_nfa->_M_traits), + _M_ctype(std::use_facet<_CtypeT>(__loc)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_start()); + __r._M_append(_M_nfa->_M_insert_subexpr_begin()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_eof)) + __throw_regex_error(regex_constants::error_paren); + __r._M_append(_M_pop()); + __glibcxx_assert(_M_stack.empty()); + __r._M_append(_M_nfa->_M_insert_subexpr_end()); + __r._M_append(_M_nfa->_M_insert_accept()); + _M_nfa->_M_eliminate_dummy(); + } + + template + void + _Compiler<_TraitsT>:: + _M_disjunction() + { + this->_M_alternative(); + while (_M_match_token(_ScannerT::_S_token_or)) + { + _StateSeqT __alt1 = _M_pop(); + this->_M_alternative(); + _StateSeqT __alt2 = _M_pop(); + auto __end = _M_nfa->_M_insert_dummy(); + __alt1._M_append(__end); + __alt2._M_append(__end); + // __alt2 is state._M_next, __alt1 is state._M_alt. The executor + // executes _M_alt before _M_next, as well as executing left + // alternative before right one. + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_alt( + __alt2._M_start, __alt1._M_start, false), + __end)); + } + } + + template + void + _Compiler<_TraitsT>:: + _M_alternative() + { + if (this->_M_term()) + { + _StateSeqT __re = _M_pop(); + this->_M_alternative(); + __re._M_append(_M_pop()); + _M_stack.push(__re); + } + else + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_dummy())); + } + + template + bool + _Compiler<_TraitsT>:: + _M_term() + { + if (this->_M_assertion()) + return true; + if (this->_M_atom()) + { + while (this->_M_quantifier()) + ; + return true; + } + return false; + } + + template + bool + _Compiler<_TraitsT>:: + _M_assertion() + { + if (_M_match_token(_ScannerT::_S_token_line_begin)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_begin())); + else if (_M_match_token(_ScannerT::_S_token_line_end)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_end())); + else if (_M_match_token(_ScannerT::_S_token_word_bound)) + // _M_value[0] == 'n' means it's negative, say "not word boundary". + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> + _M_insert_word_bound(_M_value[0] == 'n'))); + else if (_M_match_token(_ScannerT::_S_token_subexpr_lookahead_begin)) + { + auto __neg = _M_value[0] == 'n'; + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren); + auto __tmp = _M_pop(); + __tmp._M_append(_M_nfa->_M_insert_accept()); + _M_stack.push( + _StateSeqT( + *_M_nfa, + _M_nfa->_M_insert_lookahead(__tmp._M_start, __neg))); + } + else + return false; + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_quantifier() + { + bool __neg = (_M_flags & regex_constants::ECMAScript); + auto __init = [this, &__neg]() + { + if (_M_stack.empty()) + __throw_regex_error(regex_constants::error_badrepeat); + __neg = __neg && _M_match_token(_ScannerT::_S_token_opt); + }; + if (_M_match_token(_ScannerT::_S_token_closure0)) + { + __init(); + auto __e = _M_pop(); + _StateSeqT __r(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + __e._M_append(__r); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_closure1)) + { + __init(); + auto __e = _M_pop(); + __e._M_append(_M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + _M_stack.push(__e); + } + else if (_M_match_token(_ScannerT::_S_token_opt)) + { + __init(); + auto __e = _M_pop(); + auto __end = _M_nfa->_M_insert_dummy(); + _StateSeqT __r(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + __e._M_append(__end); + __r._M_append(__end); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_interval_begin)) + { + if (_M_stack.empty()) + __throw_regex_error(regex_constants::error_badrepeat); + if (!_M_match_token(_ScannerT::_S_token_dup_count)) + __throw_regex_error(regex_constants::error_badbrace); + _StateSeqT __r(_M_pop()); + _StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy()); + long __min_rep = _M_cur_int_value(10); + bool __infi = false; + long __n = 0; + + // {3 + if (_M_match_token(_ScannerT::_S_token_comma)) + { + if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7} + __n = _M_cur_int_value(10) - __min_rep; + else + __infi = true; + } + if (!_M_match_token(_ScannerT::_S_token_interval_end)) + __throw_regex_error(regex_constants::error_brace); + + __neg = __neg && _M_match_token(_ScannerT::_S_token_opt); + + for (long __i = 0; __i < __min_rep; ++__i) + __e._M_append(__r._M_clone()); + + if (__infi) + { + auto __tmp = __r._M_clone(); + _StateSeqT __s(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __tmp._M_start, __neg)); + __tmp._M_append(__s); + __e._M_append(__s); + } + else + { + if (__n < 0) + __throw_regex_error(regex_constants::error_badbrace); + auto __end = _M_nfa->_M_insert_dummy(); + // _M_alt is the "match more" branch, and _M_next is the + // "match less" one. Switch _M_alt and _M_next of all created + // nodes. This is a hack but IMO works well. + std::stack<_StateIdT> __stack; + for (long __i = 0; __i < __n; ++__i) + { + auto __tmp = __r._M_clone(); + auto __alt = _M_nfa->_M_insert_repeat(__tmp._M_start, + __end, __neg); + __stack.push(__alt); + __e._M_append(_StateSeqT(*_M_nfa, __alt, __tmp._M_end)); + } + __e._M_append(__end); + while (!__stack.empty()) + { + auto& __tmp = (*_M_nfa)[__stack.top()]; + __stack.pop(); + std::swap(__tmp._M_next, __tmp._M_alt); + } + } + _M_stack.push(__e); + } + else + return false; + return true; + } + +#define __INSERT_REGEX_MATCHER(__func, ...)\ + do {\ + if (!(_M_flags & regex_constants::icase))\ + if (!(_M_flags & regex_constants::collate))\ + __func(__VA_ARGS__);\ + else\ + __func(__VA_ARGS__);\ + else\ + if (!(_M_flags & regex_constants::collate))\ + __func(__VA_ARGS__);\ + else\ + __func(__VA_ARGS__);\ + } while (false) + + template + bool + _Compiler<_TraitsT>:: + _M_atom() + { + if (_M_match_token(_ScannerT::_S_token_anychar)) + { + if (!(_M_flags & regex_constants::ECMAScript)) + __INSERT_REGEX_MATCHER(_M_insert_any_matcher_posix); + else + __INSERT_REGEX_MATCHER(_M_insert_any_matcher_ecma); + } + else if (_M_try_char()) + __INSERT_REGEX_MATCHER(_M_insert_char_matcher); + else if (_M_match_token(_ScannerT::_S_token_backref)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> + _M_insert_backref(_M_cur_int_value(10)))); + else if (_M_match_token(_ScannerT::_S_token_quoted_class)) + __INSERT_REGEX_MATCHER(_M_insert_character_class_matcher); + else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_dummy()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren); + __r._M_append(_M_pop()); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_subexpr_begin)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_subexpr_begin()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren); + __r._M_append(_M_pop()); + __r._M_append(_M_nfa->_M_insert_subexpr_end()); + _M_stack.push(__r); + } + else if (!_M_bracket_expression()) + return false; + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_bracket_expression() + { + bool __neg = + _M_match_token(_ScannerT::_S_token_bracket_neg_begin); + if (!(__neg || _M_match_token(_ScannerT::_S_token_bracket_begin))) + return false; + __INSERT_REGEX_MATCHER(_M_insert_bracket_matcher, __neg); + return true; + } +#undef __INSERT_REGEX_MATCHER + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_any_matcher_ecma() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_AnyMatcher<_TraitsT, true, __icase, __collate> + (_M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_any_matcher_posix() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_AnyMatcher<_TraitsT, false, __icase, __collate> + (_M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_char_matcher() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_CharMatcher<_TraitsT, __icase, __collate> + (_M_value[0], _M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_character_class_matcher() + { + __glibcxx_assert(_M_value.size() == 1); + _BracketMatcher<__icase, __collate> __matcher + (_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits); + __matcher._M_add_character_class(_M_value, false); + __matcher._M_ready(); + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher(std::move(__matcher)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_bracket_matcher(bool __neg) + { + _BracketMatcher<__icase, __collate> __matcher(__neg, _M_traits); + _BracketState __last_char; + if (_M_try_char()) + __last_char.set(_M_value[0]); + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + // Dash as first character is a normal character. + __last_char.set('-'); + while (_M_expression_term(__last_char, __matcher)) + ; + if (__last_char._M_is_char()) + __matcher._M_add_char(__last_char.get()); + __matcher._M_ready(); + _M_stack.push(_StateSeqT( + *_M_nfa, + _M_nfa->_M_insert_matcher(std::move(__matcher)))); + } + + template + template + bool + _Compiler<_TraitsT>:: + _M_expression_term(_BracketState& __last_char, + _BracketMatcher<__icase, __collate>& __matcher) + { + if (_M_match_token(_ScannerT::_S_token_bracket_end)) + return false; + + // Add any previously cached char into the matcher and update cache. + const auto __push_char = [&](_CharT __ch) + { + if (__last_char._M_is_char()) + __matcher._M_add_char(__last_char.get()); + __last_char.set(__ch); + }; + // Add any previously cached char into the matcher and update cache. + const auto __push_class = [&] + { + if (__last_char._M_is_char()) + __matcher._M_add_char(__last_char.get()); + // We don't cache anything here, just record that the last thing + // processed was a character class (or similar). + __last_char.reset(_BracketState::_Type::_Class); + }; + + if (_M_match_token(_ScannerT::_S_token_collsymbol)) + { + auto __symbol = __matcher._M_add_collate_element(_M_value); + if (__symbol.size() == 1) + __push_char(__symbol[0]); + else + __push_class(); + } + else if (_M_match_token(_ScannerT::_S_token_equiv_class_name)) + { + __push_class(); + __matcher._M_add_equivalence_class(_M_value); + } + else if (_M_match_token(_ScannerT::_S_token_char_class_name)) + { + __push_class(); + __matcher._M_add_character_class(_M_value, false); + } + else if (_M_try_char()) + __push_char(_M_value[0]); + // POSIX doesn't allow '-' as a start-range char (say [a-z--0]), + // except when the '-' is the first or last character in the bracket + // expression ([--0]). ECMAScript treats all '-' after a range as a + // normal character. Also see above, where _M_expression_term gets called. + // + // As a result, POSIX rejects [-----], but ECMAScript doesn't. + // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax. + // Clang (3.5) always uses ECMAScript style even in its POSIX syntax. + // + // It turns out that no one reads BNFs ;) + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + { + if (_M_match_token(_ScannerT::_S_token_bracket_end)) + { + // For "-]" the dash is a literal character. + __push_char('-'); + return false; + } + else if (__last_char._M_is_class()) + { + // "\\w-" is invalid, start of range must be a single char. + __throw_regex_error(regex_constants::error_range, + "Invalid start of '[x-x]' range in " + "regular expression"); + } + else if (__last_char._M_is_char()) + { + if (_M_try_char()) + { + // "x-y" + __matcher._M_make_range(__last_char.get(), _M_value[0]); + __last_char.reset(); + } + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + { + // "x--" + __matcher._M_make_range(__last_char.get(), '-'); + __last_char.reset(); + } + else + __throw_regex_error(regex_constants::error_range, + "Invalid end of '[x-x]' range in " + "regular expression"); + } + else if (_M_flags & regex_constants::ECMAScript) + { + // A dash that is not part of an existing range. Might be the + // start of a new range, or might just be a literal '-' char. + // Only ECMAScript allows that in the middle of a bracket expr. + __push_char('-'); + } + else + __throw_regex_error(regex_constants::error_range, + "Invalid location of '-' within '[...]' in " + "POSIX regular expression"); + } + else if (_M_match_token(_ScannerT::_S_token_quoted_class)) + { + __push_class(); + __matcher._M_add_character_class(_M_value, + _M_ctype.is(_CtypeT::upper, + _M_value[0])); + } + else + __throw_regex_error(regex_constants::error_brack, + "Unexpected character within '[...]' in " + "regular expression"); + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_try_char() + { + bool __is_char = false; + if (_M_match_token(_ScannerT::_S_token_oct_num)) + { + __is_char = true; + _M_value.assign(1, _M_cur_int_value(8)); + } + else if (_M_match_token(_ScannerT::_S_token_hex_num)) + { + __is_char = true; + _M_value.assign(1, _M_cur_int_value(16)); + } + else if (_M_match_token(_ScannerT::_S_token_ord_char)) + __is_char = true; + return __is_char; + } + + template + bool + _Compiler<_TraitsT>:: + _M_match_token(_TokenT __token) + { + if (__token == _M_scanner._M_get_token()) + { + _M_value = _M_scanner._M_get_value(); + _M_scanner._M_advance(); + return true; + } + return false; + } + + template + int + _Compiler<_TraitsT>:: + _M_cur_int_value(int __radix) + { + long __v = 0; + for (typename _StringT::size_type __i = 0; + __i < _M_value.length(); ++__i) + __v =__v * __radix + _M_traits.value(_M_value[__i], __radix); + return __v; + } + + template + bool + _BracketMatcher<_TraitsT, __icase, __collate>:: + _M_apply(_CharT __ch, false_type) const + { + return [this, __ch] + { + if (std::binary_search(_M_char_set.begin(), _M_char_set.end(), + _M_translator._M_translate(__ch))) + return true; + auto __s = _M_translator._M_transform(__ch); + for (auto& __it : _M_range_set) + if (_M_translator._M_match_range(__it.first, __it.second, __s)) + return true; + if (_M_traits.isctype(__ch, _M_class_set)) + return true; + if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(), + _M_traits.transform_primary(&__ch, &__ch+1)) + != _M_equiv_set.end()) + return true; + for (auto& __it : _M_neg_class_set) + if (!_M_traits.isctype(__ch, __it)) + return true; + return false; + }() ^ _M_is_non_matching; + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..9f7272eff9cc69bcb674eda34c1d785bfdc0403f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_compiler.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h new file mode 100644 index 0000000000000000000000000000000000000000..35a8956b447fe447f9cede9e29b6222a78de6797 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h @@ -0,0 +1,413 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_constants.h + * @brief Constant definitions for the std regex library. + * + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @defgroup regex Regular Expressions + * + * A facility for performing regular expression pattern matching. + * @{ + */ + +/** + * @namespace std::regex_constants + * @brief ISO C++ 2011 namespace for options and flags used with std::regex + */ +namespace regex_constants +{ + /** + * @name 5.1 Regular Expression Syntax Options + */ + ///@{ + + /** + * @brief This is a bitmask type indicating how to interpret the regex. + * + * The @c syntax_option_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + * + * A valid value of type syntax_option_type shall have exactly one of the + * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep + * %set. + */ + enum syntax_option_type : unsigned int + { + _S_icase = 1 << 0, + _S_nosubs = 1 << 1, + _S_optimize = 1 << 2, + _S_collate = 1 << 3, + _S_ECMAScript = 1 << 4, + _S_basic = 1 << 5, + _S_extended = 1 << 6, + _S_awk = 1 << 7, + _S_grep = 1 << 8, + _S_egrep = 1 << 9, + _S_polynomial = 1 << 10, + _S_multiline = 1 << 11 + }; + + /** + * Specifies that the matching of regular expressions against a character + * sequence shall be performed without regard to case. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type icase = _S_icase; + + /** + * Specifies that when a regular expression is matched against a character + * container sequence, no sub-expression matches are to be stored in the + * supplied match_results structure. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type nosubs = _S_nosubs; + + /** + * Specifies that the regular expression engine should pay more attention to + * the speed with which regular expressions are matched, and less to the + * speed with which regular expression objects are constructed. Otherwise + * it has no detectable effect on the program output. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type optimize = _S_optimize; + + /** + * Specifies that character ranges of the form [a-b] should be locale + * sensitive. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type collate = _S_collate; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript + * Language Specification, Standard Ecma-262, third edition, 1999], as + * modified in section [28.13]. This grammar is similar to that defined + * in the PERL scripting language but extended with elements found in the + * POSIX regular expression grammar. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type ECMAScript = _S_ECMAScript; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- + * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type basic = _S_basic; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type extended = _S_extended; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type extended, except that C-style escape + * sequences are supported. These sequences are: + * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,, + * and \\ddd (where ddd is one, two, or three octal digits). + */ + _GLIBCXX17_INLINE constexpr syntax_option_type awk = _S_awk; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type basic, except that newlines are treated + * as whitespace. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type grep = _S_grep; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep when given the -E option in + * IEEE Std 1003.1-2001. This option is identical to syntax_option_type + * extended, except that newlines are treated as whitespace. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type egrep = _S_egrep; + +#if __cplusplus >= 201703L || !defined __STRICT_ANSI__ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2503. multiline option should be added to syntax_option_type + /** + * Specifies that the `^` anchor matches at the beginning of a line, + * and the `$` anchor matches at the end of a line, not only at the + * beginning/end of the input. + * Valid for the ECMAScript syntax, ignored otherwise. + * @since C++17 + */ + _GLIBCXX17_INLINE constexpr syntax_option_type multiline = _S_multiline; +#endif + + /// Extension: Equivalent to regex_constants::multiline for C++11 and C++14. + _GLIBCXX17_INLINE constexpr syntax_option_type __multiline = _S_multiline; + + /** + * Extension: Ensure both space complexity of compiled regex and + * time complexity execution are not exponential. + * If specified in a regex with back-references, the exception + * regex_constants::error_complexity will be thrown. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type __polynomial = _S_polynomial; + + constexpr inline syntax_option_type + operator&(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + & static_cast(__b)); + } + + constexpr inline syntax_option_type + operator|(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + | static_cast(__b)); + } + + constexpr inline syntax_option_type + operator^(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + ^ static_cast(__b)); + } + + constexpr inline syntax_option_type + operator~(syntax_option_type __a) + { return (syntax_option_type)(~static_cast(__a)); } + + _GLIBCXX14_CONSTEXPR + inline syntax_option_type& + operator&=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a & __b; } + + _GLIBCXX14_CONSTEXPR + inline syntax_option_type& + operator|=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a | __b; } + + _GLIBCXX14_CONSTEXPR + inline syntax_option_type& + operator^=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a ^ __b; } + + ///@} + + /** + * @name 5.2 Matching Rules + * + * Matching a regular expression against a sequence of characters [first, + * last) proceeds according to the rules of the grammar specified for the + * regular expression object, modified according to the effects listed + * below for any bitmask elements set. + * + */ + ///@{ + + /** + * @brief This is a bitmask type indicating regex matching rules. + * + * The @c match_flag_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + */ + enum match_flag_type : unsigned int + { + _S_default, + _S_not_bol = 1 << 0, + _S_not_eol = 1 << 1, + _S_not_bow = 1 << 2, + _S_not_eow = 1 << 3, + _S_any = 1 << 4, + _S_not_null = 1 << 5, + _S_continuous = 1 << 6, + _S_prev_avail = 1 << 7, + _S_sed = 1 << 8, + _S_no_copy = 1 << 9, + _S_first_only = 1 << 10, + _S_match_flag_last = 1 << 11 + }; + + /** + * The default matching rules. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_default = _S_default; + + /** + * The first character in the sequence [first, last) is treated as though it + * is not at the beginning of a line, so the character (^) in the regular + * expression shall not match [first, first). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bol = _S_not_bol; + + /** + * The last character in the sequence [first, last) is treated as though it + * is not at the end of a line, so the character ($) in the regular + * expression shall not match [last, last). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eol = _S_not_eol; + + /** + * The expression \\b is not matched against the sub-sequence + * [first,first). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bow = _S_not_bow; + + /** + * The expression \\b should not be matched against the sub-sequence + * [last,last). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eow = _S_not_eow; + + /** + * If more than one match is possible then any match is an acceptable + * result. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_any = _S_any; + + /** + * The expression does not match an empty sequence. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_null = _S_not_null; + + /** + * The expression only matches a sub-sequence that begins at first . + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_continuous = _S_continuous; + + /** + * `--first` is a valid iterator position. When this flag is set then the + * flags `match_not_bol` and `match_not_bow` are ignored by the algorithms + * `regex_match`, `regex_search`, and `regex_replace`, and by the iterators + * `regex_iterator` and `regex_token_iterator`. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_prev_avail = _S_prev_avail; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the ECMAScript replace + * function in ECMA- 262 [Ecma International, ECMAScript Language + * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 + * String.prototype.replace. In addition, during search and replace + * operations all non-overlapping occurrences of the regular expression + * are located and replaced, and sections of the input that did not match + * the expression are copied unchanged to the output string. + * + * Format strings (from ECMA-262 [15.5.4.11]): + * @li $$ The dollar-sign itself ($) + * @li $& The matched substring. + * @li $` The portion of @a string that precedes the matched substring. + * This would be match_results::prefix(). + * @li $' The portion of @a string that follows the matched substring. + * This would be match_results::suffix(). + * @li $n The nth capture, where n is in [1,9] and $n is not followed by a + * decimal digit. If n <= match_results::size() and the nth capture + * is undefined, use the empty string instead. If n > + * match_results::size(), the result is implementation-defined. + * @li $nn The nnth capture, where nn is a two-digit decimal number on + * [01, 99]. If nn <= match_results::size() and the nth capture is + * undefined, use the empty string instead. If + * nn > match_results::size(), the result is implementation-defined. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_default = _S_default; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the POSIX sed utility + * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable + * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_sed = _S_sed; + + /** + * During a search and replace operation, sections of the character + * container sequence being searched that do not match the regular + * expression shall not be copied to the output string. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_no_copy = _S_no_copy; + + /** + * When specified during a search and replace operation, only the first + * occurrence of the regular expression shall be replaced. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_first_only = _S_first_only; + + constexpr inline match_flag_type + operator&(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + & static_cast(__b)); + } + + constexpr inline match_flag_type + operator|(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + | static_cast(__b)); + } + + constexpr inline match_flag_type + operator^(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + ^ static_cast(__b)); + } + + constexpr inline match_flag_type + operator~(match_flag_type __a) + { return (match_flag_type)(~static_cast(__a)); } + + _GLIBCXX14_CONSTEXPR + inline match_flag_type& + operator&=(match_flag_type& __a, match_flag_type __b) + { return __a = __a & __b; } + + _GLIBCXX14_CONSTEXPR + inline match_flag_type& + operator|=(match_flag_type& __a, match_flag_type __b) + { return __a = __a | __b; } + + _GLIBCXX14_CONSTEXPR + inline match_flag_type& + operator^=(match_flag_type& __a, match_flag_type __b) + { return __a = __a ^ __b; } + + ///@} +} // namespace regex_constants +/// @} group regex + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0b0d4b66ed8ef5675edde39291979a9f4f354bbe Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_constants.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h new file mode 100644 index 0000000000000000000000000000000000000000..77d4925921bd8e6e96e96930be3c9a207c86a6bd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h @@ -0,0 +1,187 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_error.h + * @brief Error and exception objects for the std regex library. + * + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @addtogroup regex + * @{ + */ + +namespace regex_constants +{ + /** + * @name 5.3 Error Types + */ + ///@{ + + enum error_type + { + _S_error_collate, // XXX should have been a non-zero value + _S_error_ctype, + _S_error_escape, + _S_error_backref, + _S_error_brack, + _S_error_paren, + _S_error_brace, + _S_error_badbrace, + _S_error_range, + _S_error_space, + _S_error_badrepeat, + _S_error_complexity, + _S_error_stack, + _S_null, + _S_grammar + }; + + /** The expression contained an invalid collating element name. */ + constexpr error_type error_collate(_S_error_collate); + + /** The expression contained an invalid character class name. */ + constexpr error_type error_ctype(_S_error_ctype); + + /** + * The expression contained an invalid escaped character, or a trailing + * escape. + */ + constexpr error_type error_escape(_S_error_escape); + + /** The expression contained an invalid back reference. */ + constexpr error_type error_backref(_S_error_backref); + + /** The expression contained mismatched [ and ]. */ + constexpr error_type error_brack(_S_error_brack); + + /** The expression contained mismatched ( and ). */ + constexpr error_type error_paren(_S_error_paren); + + /** The expression contained mismatched { and } */ + constexpr error_type error_brace(_S_error_brace); + + /** The expression contained an invalid range in a {} expression. */ + constexpr error_type error_badbrace(_S_error_badbrace); + + /** + * The expression contained an invalid character range, + * such as [b-a] in most encodings. + */ + constexpr error_type error_range(_S_error_range); + + /** + * There was insufficient memory to convert the expression into a + * finite state machine. + */ + constexpr error_type error_space(_S_error_space); + + /** + * One of *?+{ was not preceded by a valid regular expression. + */ + constexpr error_type error_badrepeat(_S_error_badrepeat); + + /** + * The complexity of an attempted match against a regular expression + * exceeded a pre-set level. + */ + constexpr error_type error_complexity(_S_error_complexity); + + /** + * There was insufficient memory to determine whether the + * regular expression could match the specified character sequence. + */ + constexpr error_type error_stack(_S_error_stack); + + ///@} +} // namespace regex_constants + + // [7.8] Class regex_error + /** + * @brief A regular expression exception class. + * @ingroup exceptions + * + * The regular expression library throws objects of this class on error. + */ + class regex_error : public std::runtime_error + { + using error_type = regex_constants::error_type; + + error_type _M_code; + + public: + /** + * @brief Constructs a regex_error object. + * + * @param __ecode the regex error code. + */ + explicit + regex_error(error_type __ecode); + + virtual ~regex_error() throw(); + + /** + * @brief Gets the regex error code. + * + * @returns the regex error code. + */ + regex_constants::error_type + code() const noexcept + { return _M_code; } + + private: + regex_error(error_type __ecode, const char* __what) + : std::runtime_error(__what), _M_code(__ecode) + { } + + [[__noreturn__]] + friend void + __throw_regex_error(error_type __ecode __attribute__((__unused__)), + const char* __what __attribute__((__unused__))) + { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); } + }; + + /// @cond undocumented + + [[__noreturn__]] + void + __throw_regex_error(regex_constants::error_type __ecode); + + [[__noreturn__]] + inline void + __throw_regex_error(regex_constants::error_type __ecode, const char* __what); + + /// @endcond + + ///@} // group regex + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b1f48f057ef22dceecf893a0d6c3dc67b2937324 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_error.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h new file mode 100644 index 0000000000000000000000000000000000000000..dc0878ce678703d37a8a5ca233372a908d50098c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h @@ -0,0 +1,311 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_executor.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME convert comments to doxygen format. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + /** + * @brief Takes a regex and an input string and does the matching. + * + * The %_Executor class has two modes: DFS mode and BFS mode, controlled + * by the template parameter %__dfs_mode. + */ + template + class _Executor + { + using __search_mode = integral_constant; + using __dfs = true_type; + using __bfs = false_type; + + enum class _Match_mode : unsigned char { _Exact, _Prefix }; + + public: + typedef typename iterator_traits<_BiIter>::value_type _CharT; + typedef basic_regex<_CharT, _TraitsT> _RegexT; + typedef _GLIBCXX_STD_C::vector, _Alloc> _ResultsVec; + typedef regex_constants::match_flag_type _FlagT; + typedef typename _TraitsT::char_class_type _ClassT; + typedef _NFA<_TraitsT> _NFAT; + + public: + _Executor(_BiIter __begin, + _BiIter __end, + _ResultsVec& __results, + const _RegexT& __re, + _FlagT __flags) + : _M_begin(__begin), + _M_end(__end), + _M_re(__re), + _M_nfa(*__re._M_automaton), + _M_results(__results), + _M_rep_count(_M_nfa.size()), + _M_states(_M_nfa._M_start(), _M_nfa.size()), + _M_flags(__flags) + { + using namespace regex_constants; + if (__flags & match_prev_avail) // ignore not_bol and not_bow + _M_flags &= ~(match_not_bol | match_not_bow); + } + + // Set matched when string exactly matches the pattern. + bool + _M_match() + { + _M_current = _M_begin; + return _M_main(_Match_mode::_Exact); + } + + // Set matched when some prefix of the string matches the pattern. + bool + _M_search_from_first() + { + _M_current = _M_begin; + return _M_main(_Match_mode::_Prefix); + } + + bool + _M_search(); + + private: + void + _M_rep_once_more(_Match_mode __match_mode, _StateIdT); + + void + _M_handle_repeat(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_begin(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_end(_Match_mode, _StateIdT); + + void + _M_handle_line_begin_assertion(_Match_mode, _StateIdT); + + void + _M_handle_line_end_assertion(_Match_mode, _StateIdT); + + void + _M_handle_word_boundary(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_lookahead(_Match_mode, _StateIdT); + + void + _M_handle_match(_Match_mode, _StateIdT); + + void + _M_handle_backref(_Match_mode, _StateIdT); + + void + _M_handle_accept(_Match_mode, _StateIdT); + + void + _M_handle_alternative(_Match_mode, _StateIdT); + + void + _M_dfs(_Match_mode __match_mode, _StateIdT __start); + + bool + _M_main(_Match_mode __match_mode) + { return _M_main_dispatch(__match_mode, __search_mode{}); } + + bool + _M_main_dispatch(_Match_mode __match_mode, __dfs); + + bool + _M_main_dispatch(_Match_mode __match_mode, __bfs); + + bool + _M_is_word(_CharT __ch) const + { + static const _CharT __s[2] = { 'w' }; + return _M_re._M_automaton->_M_traits.isctype + (__ch, _M_re._M_automaton->_M_traits.lookup_classname(__s, __s+1)); + } + + bool + _M_at_begin() const + { + if (_M_current == _M_begin) + { + // match_not_bol means ^ does not match [_M_begin,_M_begin) + if (_M_flags & regex_constants::match_not_bol) + return false; + // match_prev_avail means _M_begin is not the start of the input. + if (_M_flags & regex_constants::match_prev_avail) + { + // For ECMAScript multiline matches, check if the previous + // character is a line terminator. + if (_M_match_multiline()) + return _M_is_line_terminator(*std::prev(_M_current)); + else + return false; + } + else // ^ matches at _M_begin + return true; + } + else if (_M_match_multiline()) + return _M_is_line_terminator(*std::prev(_M_current)); + else + return false; + } + + bool + _M_at_end() const + { + if (_M_current == _M_end) + return !(_M_flags & regex_constants::match_not_eol); + else if (_M_match_multiline()) + return _M_is_line_terminator(*_M_current); + else + return false; + } + + bool + _M_word_boundary() const; + + bool + _M_lookahead(_StateIdT __next); + + bool + _M_is_line_terminator(_CharT __c) const + { + const auto& __traits = _M_re._M_automaton->_M_traits; + const auto& __ct = use_facet>(__traits.getloc()); + const char __n{ __ct.narrow(__c, ' ') }; + if (__n == '\n') + return true; + if (_M_re._M_automaton->_M_options() & regex_constants::ECMAScript) + { + if (__n == '\r') + return true; + // FIXME: U+2028 (line separator) and U+2029 (paragraph separator) + } + return false; + } + + bool + _M_match_multiline() const noexcept + { + constexpr auto __m + = regex_constants::ECMAScript | regex_constants::__multiline; + return (_M_re._M_automaton->_M_options() & __m) == __m; + } + + // Holds additional information used in BFS-mode. + template + struct _State_info; + + template + struct _State_info<__bfs, _ResultsVec> + { + explicit + _State_info(_StateIdT __start, size_t __n) + : _M_visited_states(new bool[__n]()), _M_start(__start) + { } + + ~_State_info() { delete[] _M_visited_states; } + + _State_info(const _State_info&) = delete; + _State_info& operator=(const _State_info&) = delete; + + bool _M_visited(_StateIdT __i) + { + if (_M_visited_states[__i]) + return true; + _M_visited_states[__i] = true; + return false; + } + + void _M_queue(_StateIdT __i, const _ResultsVec& __res) + { _M_match_queue.emplace_back(__i, __res); } + + // Dummy implementations for BFS mode. + _BiIter* _M_get_sol_pos() { return nullptr; } + + // Saves states that need to be considered for the next character. + _GLIBCXX_STD_C::vector> _M_match_queue; + // Indicates which states are already visited. + bool* _M_visited_states; + // To record current solution. + _StateIdT _M_start; + }; + + template + struct _State_info<__dfs, _ResultsVec> + { + explicit + _State_info(_StateIdT __start, size_t) : _M_start(__start) + { } + + // Dummy implementations for DFS mode. + bool _M_visited(_StateIdT) const { return false; } + void _M_queue(_StateIdT, const _ResultsVec&) { } + + _BiIter* _M_get_sol_pos() { return &_M_sol_pos; } + + // To record current solution. + _StateIdT _M_start; + _BiIter _M_sol_pos; + }; + + public: + _ResultsVec _M_cur_results; + _BiIter _M_current; + _BiIter _M_begin; + const _BiIter _M_end; + const _RegexT& _M_re; + const _NFAT& _M_nfa; + _ResultsVec& _M_results; + _GLIBCXX_STD_C::vector> _M_rep_count; + _State_info<__search_mode, _ResultsVec> _M_states; + _FlagT _M_flags; + // Do we have a solution so far? + bool _M_has_sol; + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..90c3e563c7aa1db9f7de0a15b2142f75f13bf849 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc new file mode 100644 index 0000000000000000000000000000000000000000..b93e958075e3d3266ae01b8dd1ffca8f41d67d4e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc @@ -0,0 +1,568 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_executor.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_search() + { + if (_M_search_from_first()) + return true; + if (_M_flags & regex_constants::match_continuous) + return false; + _M_flags |= regex_constants::match_prev_avail; + while (_M_begin != _M_end) + { + ++_M_begin; + if (_M_search_from_first()) + return true; + } + return false; + } + + // The _M_main function operates in different modes, DFS mode or BFS mode, + // indicated by template parameter __dfs_mode, and dispatches to one of the + // _M_main_dispatch overloads. + // + // ------------------------------------------------------------ + // + // DFS mode: + // + // It applies a Depth-First-Search (aka backtracking) on given NFA and input + // string. + // At the very beginning the executor stands in the start state, then it + // tries every possible state transition in current state recursively. Some + // state transitions consume input string, say, a single-char-matcher or a + // back-reference matcher; some don't, like assertion or other anchor nodes. + // When the input is exhausted and/or the current state is an accepting + // state, the whole executor returns true. + // + // TODO: This approach is exponentially slow for certain input. + // Try to compile the NFA to a DFA. + // + // Time complexity: \Omega(match_length), O(2^(_M_nfa.size())) + // Space complexity: \theta(match_results.size() + match_length) + // + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_main_dispatch(_Match_mode __match_mode, __dfs) + { + _M_has_sol = false; + *_M_states._M_get_sol_pos() = _BiIter(); + _M_cur_results = _M_results; + _M_dfs(__match_mode, _M_states._M_start); + return _M_has_sol; + } + + // ------------------------------------------------------------ + // + // BFS mode: + // + // Russ Cox's article (http://swtch.com/~rsc/regexp/regexp1.html) + // explained this algorithm clearly. + // + // It first computes epsilon closure (states that can be achieved without + // consuming characters) for every state that's still matching, + // using the same DFS algorithm, but doesn't re-enter states (using + // _M_states._M_visited to check), nor follow _S_opcode_match. + // + // Then apply DFS using every _S_opcode_match (in _M_states._M_match_queue) + // as the start state. + // + // It significantly reduces potential duplicate states, so has a better + // upper bound; but it requires more overhead. + // + // Time complexity: \Omega(match_length * match_results.size()) + // O(match_length * _M_nfa.size() * match_results.size()) + // Space complexity: \Omega(_M_nfa.size() + match_results.size()) + // O(_M_nfa.size() * match_results.size()) + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_main_dispatch(_Match_mode __match_mode, __bfs) + { + _M_states._M_queue(_M_states._M_start, _M_results); + bool __ret = false; + while (1) + { + _M_has_sol = false; + if (_M_states._M_match_queue.empty()) + break; + std::fill_n(_M_states._M_visited_states, _M_nfa.size(), false); + auto __old_queue = std::move(_M_states._M_match_queue); + for (auto& __task : __old_queue) + { + _M_cur_results = std::move(__task.second); + _M_dfs(__match_mode, __task.first); + } + if (__match_mode == _Match_mode::_Prefix) + __ret |= _M_has_sol; + if (_M_current == _M_end) + break; + ++_M_current; + } + if (__match_mode == _Match_mode::_Exact) + __ret = _M_has_sol; + _M_states._M_match_queue.clear(); + return __ret; + } + + // Return whether now match the given sub-NFA. + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_lookahead(_StateIdT __next) + { + // Backreferences may refer to captured content. + // We may want to make this faster by not copying, + // but let's not be clever prematurely. + _ResultsVec __what(_M_cur_results); + _Executor __sub(_M_current, _M_end, __what, _M_re, _M_flags); + __sub._M_states._M_start = __next; + if (__sub._M_search_from_first()) + { + for (size_t __i = 0; __i < __what.size(); __i++) + if (__what[__i].matched) + _M_cur_results[__i] = __what[__i]; + return true; + } + return false; + } + + // __rep_count records how many times (__rep_count.second) + // this node is visited under certain input iterator + // (__rep_count.first). This prevent the executor from entering + // infinite loop by refusing to continue when it's already been + // visited more than twice. It's `twice` instead of `once` because + // we need to spare one more time for potential group capture. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_rep_once_more(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + auto& __rep_count = _M_rep_count[__i]; + if (__rep_count.second == 0 || __rep_count.first != _M_current) + { + auto __back = __rep_count; + __rep_count.first = _M_current; + __rep_count.second = 1; + _M_dfs(__match_mode, __state._M_alt); + __rep_count = __back; + } + else + { + if (__rep_count.second < 2) + { + __rep_count.second++; + _M_dfs(__match_mode, __state._M_alt); + __rep_count.second--; + } + } + } + + // _M_alt branch is "match once more", while _M_next is "get me out + // of this quantifier". Executing _M_next first or _M_alt first don't + // mean the same thing, and we need to choose the correct order under + // given greedy mode. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_repeat(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + // Greedy. + if (!__state._M_neg) + { + _M_rep_once_more(__match_mode, __i); + // If it's DFS executor and already accepted, we're done. + if (!__dfs_mode || !_M_has_sol) + _M_dfs(__match_mode, __state._M_next); + } + else // Non-greedy mode + { + if (__dfs_mode) + { + // vice-versa. + _M_dfs(__match_mode, __state._M_next); + if (!_M_has_sol) + _M_rep_once_more(__match_mode, __i); + } + else + { + // DON'T attempt anything, because there's already another + // state with higher priority accepted. This state cannot + // be better by attempting its next node. + if (!_M_has_sol) + { + _M_dfs(__match_mode, __state._M_next); + // DON'T attempt anything if it's already accepted. An + // accepted state *must* be better than a solution that + // matches a non-greedy quantifier one more time. + if (!_M_has_sol) + _M_rep_once_more(__match_mode, __i); + } + } + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_begin(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + auto& __res = _M_cur_results[__state._M_subexpr]; + auto __back = __res.first; + __res.first = _M_current; + _M_dfs(__match_mode, __state._M_next); + __res.first = __back; + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_end(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + auto& __res = _M_cur_results[__state._M_subexpr]; + auto __back = __res; + __res.second = _M_current; + __res.matched = true; + _M_dfs(__match_mode, __state._M_next); + __res = __back; + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_line_begin_assertion(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_at_begin()) + _M_dfs(__match_mode, __state._M_next); + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_line_end_assertion(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_at_end()) + _M_dfs(__match_mode, __state._M_next); + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_word_boundary(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_word_boundary() == !__state._M_neg) + _M_dfs(__match_mode, __state._M_next); + } + + // Here __state._M_alt offers a single start node for a sub-NFA. + // We recursively invoke our algorithm to match the sub-NFA. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_lookahead(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_lookahead(__state._M_alt) == !__state._M_neg) + _M_dfs(__match_mode, __state._M_next); + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_match(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + if (_M_current == _M_end) + return; + if (__dfs_mode) + { + if (__state._M_matches(*_M_current)) + { + ++_M_current; + _M_dfs(__match_mode, __state._M_next); + --_M_current; + } + } + else + if (__state._M_matches(*_M_current)) + _M_states._M_queue(__state._M_next, _M_cur_results); + } + + template + struct _Backref_matcher + { + _Backref_matcher(bool __icase, const _TraitsT& __traits) + : _M_traits(__traits) { } + + bool + _M_apply(_BiIter __expected_begin, + _BiIter __expected_end, _BiIter __actual_begin, + _BiIter __actual_end) + { + return _M_traits.transform(__expected_begin, __expected_end) + == _M_traits.transform(__actual_begin, __actual_end); + } + + const _TraitsT& _M_traits; + }; + + template + struct _Backref_matcher<_BiIter, std::regex_traits<_CharT>> + { + using _TraitsT = std::regex_traits<_CharT>; + _Backref_matcher(bool __icase, const _TraitsT& __traits) + : _M_icase(__icase), _M_traits(__traits) { } + + bool + _M_apply(_BiIter __expected_begin, + _BiIter __expected_end, _BiIter __actual_begin, + _BiIter __actual_end) + { + if (!_M_icase) + return _GLIBCXX_STD_A::__equal4(__expected_begin, __expected_end, + __actual_begin, __actual_end); + typedef std::ctype<_CharT> __ctype_type; + const auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc()); + return _GLIBCXX_STD_A::__equal4(__expected_begin, __expected_end, + __actual_begin, __actual_end, + [this, &__fctyp](_CharT __lhs, _CharT __rhs) + { + return __fctyp.tolower(__lhs) + == __fctyp.tolower(__rhs); + }); + } + + bool _M_icase; + const _TraitsT& _M_traits; + }; + + // First fetch the matched result from _M_cur_results as __submatch; + // then compare it with + // (_M_current, _M_current + (__submatch.second - __submatch.first)). + // If matched, keep going; else just return and try another state. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_backref(_Match_mode __match_mode, _StateIdT __i) + { + __glibcxx_assert(__dfs_mode); + + const auto& __state = _M_nfa[__i]; + auto& __submatch = _M_cur_results[__state._M_backref_index]; + if (!__submatch.matched) + return; + auto __last = _M_current; + for (auto __tmp = __submatch.first; + __last != _M_end && __tmp != __submatch.second; + ++__tmp) + ++__last; + if (_Backref_matcher<_BiIter, _TraitsT>( + _M_re.flags() & regex_constants::icase, + _M_re._M_automaton->_M_traits)._M_apply( + __submatch.first, __submatch.second, _M_current, __last)) + { + if (__last != _M_current) + { + auto __backup = _M_current; + _M_current = __last; + _M_dfs(__match_mode, __state._M_next); + _M_current = __backup; + } + else + _M_dfs(__match_mode, __state._M_next); + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_accept(_Match_mode __match_mode, _StateIdT) + { + if _GLIBCXX17_CONSTEXPR (__dfs_mode) + { + __glibcxx_assert(!_M_has_sol); + if (__match_mode == _Match_mode::_Exact) + _M_has_sol = _M_current == _M_end; + else + _M_has_sol = true; + if (_M_current == _M_begin + && (_M_flags & regex_constants::match_not_null)) + _M_has_sol = false; + if (_M_has_sol) + { + if (_M_nfa._M_flags & regex_constants::ECMAScript) + _M_results = _M_cur_results; + else // POSIX + { + __glibcxx_assert(_M_states._M_get_sol_pos()); + // Here's POSIX's logic: match the longest one. However + // we never know which one (lhs or rhs of "|") is longer + // unless we try both of them and compare the results. + // The member variable _M_sol_pos records the end + // position of the last successful match. It's better + // to be larger, because POSIX regex is always greedy. + // TODO: This could be slow. + if (*_M_states._M_get_sol_pos() == _BiIter() + || std::distance(_M_begin, + *_M_states._M_get_sol_pos()) + < std::distance(_M_begin, _M_current)) + { + *_M_states._M_get_sol_pos() = _M_current; + _M_results = _M_cur_results; + } + } + } + } + else + { + if (_M_current == _M_begin + && (_M_flags & regex_constants::match_not_null)) + return; + if (__match_mode == _Match_mode::_Prefix || _M_current == _M_end) + if (!_M_has_sol) + { + _M_has_sol = true; + _M_results = _M_cur_results; + } + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_alternative(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + if (_M_nfa._M_flags & regex_constants::ECMAScript) + { + // TODO: Fix BFS support. It is wrong. + _M_dfs(__match_mode, __state._M_alt); + // Pick lhs if it matches. Only try rhs if it doesn't. + if (!_M_has_sol) + _M_dfs(__match_mode, __state._M_next); + } + else + { + // Try both and compare the result. + // See "case _S_opcode_accept:" handling above. + _M_dfs(__match_mode, __state._M_alt); + auto __has_sol = _M_has_sol; + _M_has_sol = false; + _M_dfs(__match_mode, __state._M_next); + _M_has_sol |= __has_sol; + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_dfs(_Match_mode __match_mode, _StateIdT __i) + { + if (_M_states._M_visited(__i)) + return; + + switch (_M_nfa[__i]._M_opcode()) + { + case _S_opcode_repeat: + _M_handle_repeat(__match_mode, __i); break; + case _S_opcode_subexpr_begin: + _M_handle_subexpr_begin(__match_mode, __i); break; + case _S_opcode_subexpr_end: + _M_handle_subexpr_end(__match_mode, __i); break; + case _S_opcode_line_begin_assertion: + _M_handle_line_begin_assertion(__match_mode, __i); break; + case _S_opcode_line_end_assertion: + _M_handle_line_end_assertion(__match_mode, __i); break; + case _S_opcode_word_boundary: + _M_handle_word_boundary(__match_mode, __i); break; + case _S_opcode_subexpr_lookahead: + _M_handle_subexpr_lookahead(__match_mode, __i); break; + case _S_opcode_match: + _M_handle_match(__match_mode, __i); break; + case _S_opcode_backref: + _M_handle_backref(__match_mode, __i); break; + case _S_opcode_accept: + _M_handle_accept(__match_mode, __i); break; + case _S_opcode_alternative: + _M_handle_alternative(__match_mode, __i); break; + default: + __glibcxx_assert(false); + } + } + + // Return whether now is at some word boundary. + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_word_boundary() const + { + if (_M_current == _M_begin && (_M_flags & regex_constants::match_not_bow)) + return false; + if (_M_current == _M_end && (_M_flags & regex_constants::match_not_eow)) + return false; + + bool __left_is_word = false; + if (_M_current != _M_begin + || (_M_flags & regex_constants::match_prev_avail)) + { + auto __prev = _M_current; + if (_M_is_word(*std::prev(__prev))) + __left_is_word = true; + } + bool __right_is_word = + _M_current != _M_end && _M_is_word(*_M_current); + + return __left_is_word != __right_is_word; + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..393c8c80b43f8799a88a2166f7f13f492115aa18 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_executor.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h new file mode 100644 index 0000000000000000000000000000000000000000..bc54ceabc21cef47f8895d77b622126034233bd0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h @@ -0,0 +1,271 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_scanner.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + struct _ScannerBase + { + public: + /// Token types returned from the scanner. + enum _TokenT : unsigned + { + _S_token_anychar, + _S_token_ord_char, + _S_token_oct_num, + _S_token_hex_num, + _S_token_backref, + _S_token_subexpr_begin, + _S_token_subexpr_no_group_begin, + _S_token_subexpr_lookahead_begin, // neg if _M_value[0] == 'n' + _S_token_subexpr_end, + _S_token_bracket_begin, + _S_token_bracket_neg_begin, + _S_token_bracket_end, + _S_token_interval_begin, + _S_token_interval_end, + _S_token_quoted_class, + _S_token_char_class_name, + _S_token_collsymbol, + _S_token_equiv_class_name, + _S_token_opt, + _S_token_or, + _S_token_closure0, + _S_token_closure1, + _S_token_line_begin, + _S_token_line_end, + _S_token_word_bound, // neg if _M_value[0] == 'n' + _S_token_comma, + _S_token_dup_count, + _S_token_eof, + _S_token_bracket_dash, + _S_token_unknown = -1u + }; + + protected: + typedef regex_constants::syntax_option_type _FlagT; + + enum _StateT + { + _S_state_normal, + _S_state_in_brace, + _S_state_in_bracket, + }; + + protected: + _ScannerBase(_FlagT __flags) + : _M_state(_S_state_normal), + _M_flags(__flags), + _M_escape_tbl(_M_is_ecma() + ? _M_ecma_escape_tbl + : _M_awk_escape_tbl), + _M_spec_char(_M_is_ecma() + ? _M_ecma_spec_char + : _M_flags & regex_constants::basic + ? _M_basic_spec_char + : _M_flags & regex_constants::extended + ? _M_extended_spec_char + : _M_flags & regex_constants::grep + ? ".[\\*^$\n" + : _M_flags & regex_constants::egrep + ? ".[\\()*+?{|^$\n" + : _M_flags & regex_constants::awk + ? _M_extended_spec_char + : nullptr), + _M_at_bracket_start(false) + { __glibcxx_assert(_M_spec_char); } + + protected: + const char* + _M_find_escape(char __c) + { + auto __it = _M_escape_tbl; + for (; __it->first != '\0'; ++__it) + if (__it->first == __c) + return &__it->second; + return nullptr; + } + + bool + _M_is_ecma() const + { return _M_flags & regex_constants::ECMAScript; } + + bool + _M_is_basic() const + { return _M_flags & (regex_constants::basic | regex_constants::grep); } + + bool + _M_is_extended() const + { + return _M_flags & (regex_constants::extended + | regex_constants::egrep + | regex_constants::awk); + } + + bool + _M_is_grep() const + { return _M_flags & (regex_constants::grep | regex_constants::egrep); } + + bool + _M_is_awk() const + { return _M_flags & regex_constants::awk; } + + protected: + // TODO: Make them static in the next abi change. + const std::pair _M_token_tbl[9] = + { + {'^', _S_token_line_begin}, + {'$', _S_token_line_end}, + {'.', _S_token_anychar}, + {'*', _S_token_closure0}, + {'+', _S_token_closure1}, + {'?', _S_token_opt}, + {'|', _S_token_or}, + {'\n', _S_token_or}, // grep and egrep + {'\0', _S_token_or}, + }; + const std::pair _M_ecma_escape_tbl[8] = + { + {'0', '\0'}, + {'b', '\b'}, + {'f', '\f'}, + {'n', '\n'}, + {'r', '\r'}, + {'t', '\t'}, + {'v', '\v'}, + {'\0', '\0'}, + }; + const std::pair _M_awk_escape_tbl[11] = + { + {'"', '"'}, + {'/', '/'}, + {'\\', '\\'}, + {'a', '\a'}, + {'b', '\b'}, + {'f', '\f'}, + {'n', '\n'}, + {'r', '\r'}, + {'t', '\t'}, + {'v', '\v'}, + {'\0', '\0'}, + }; + const char* _M_ecma_spec_char = "^$\\.*+?()[]{}|"; + const char* _M_basic_spec_char = ".[\\*^$"; + const char* _M_extended_spec_char = ".[\\()*+?{|^$"; + + _StateT _M_state; + _FlagT _M_flags; + _TokenT _M_token; + const std::pair* _M_escape_tbl; + const char* _M_spec_char; + bool _M_at_bracket_start; + }; + + /** + * @brief Scans an input range for regex tokens. + * + * The %_Scanner class interprets the regular expression pattern in + * the input range passed to its constructor as a sequence of parse + * tokens passed to the regular expression compiler. The sequence + * of tokens provided depends on the flag settings passed to the + * constructor: different regular expression grammars will interpret + * the same input pattern in syntactically different ways. + */ + template + class _Scanner + : public _ScannerBase + { + public: + typedef std::basic_string<_CharT> _StringT; + typedef regex_constants::syntax_option_type _FlagT; + typedef const std::ctype<_CharT> _CtypeT; + + _Scanner(const _CharT* __begin, const _CharT* __end, + _FlagT __flags, std::locale __loc); + + void + _M_advance(); + + _TokenT + _M_get_token() const noexcept + { return _M_token; } + + const _StringT& + _M_get_value() const noexcept + { return _M_value; } + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_print(std::ostream&); +#endif + + private: + void + _M_scan_normal(); + + void + _M_scan_in_bracket(); + + void + _M_scan_in_brace(); + + void + _M_eat_escape_ecma(); + + void + _M_eat_escape_posix(); + + void + _M_eat_escape_awk(); + + void + _M_eat_class(char); + + const _CharT* _M_current; + const _CharT* _M_end; + _CtypeT& _M_ctype; + _StringT _M_value; + void (_Scanner::* _M_eat_escape)(); + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ef926e5d8f32ed2f2d6227aac40824153788ff1c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc new file mode 100644 index 0000000000000000000000000000000000000000..2a1745b42f68a0f1c299fd33886e750f57dafc14 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc @@ -0,0 +1,584 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_scanner.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME make comments doxygen format. + +// N3376 specified 6 regex styles: ECMAScript, basic, extended, grep, egrep +// and awk +// 1) grep is basic except '\n' is treated as '|' +// 2) egrep is extended except '\n' is treated as '|' +// 3) awk is extended except special escaping rules, and there's no +// back-reference. +// +// References: +// +// ECMAScript: ECMA-262 15.10 +// +// basic, extended: +// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html +// +// awk: http://pubs.opengroup.org/onlinepubs/000095399/utilities/awk.html + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + _Scanner<_CharT>:: + _Scanner(const _CharT* __begin, const _CharT* __end, + _FlagT __flags, std::locale __loc) + : _ScannerBase(__flags), + _M_current(__begin), _M_end(__end), + _M_ctype(std::use_facet<_CtypeT>(__loc)), + _M_eat_escape(_M_is_ecma() + ? &_Scanner::_M_eat_escape_ecma + : &_Scanner::_M_eat_escape_posix) + { _M_advance(); } + + template + void + _Scanner<_CharT>:: + _M_advance() + { + if (_M_current == _M_end) + { + _M_token = _S_token_eof; + return; + } + + if (_M_state == _S_state_normal) + _M_scan_normal(); + else if (_M_state == _S_state_in_bracket) + _M_scan_in_bracket(); + else if (_M_state == _S_state_in_brace) + _M_scan_in_brace(); + else + { + __glibcxx_assert(!"unexpected state while processing regex"); + } + } + + // Differences between styles: + // 1) "\(", "\)", "\{" in basic. It's not escaping. + // 2) "(?:", "(?=", "(?!" in ECMAScript. + template + void + _Scanner<_CharT>:: + _M_scan_normal() + { + auto __c = *_M_current++; + + if (__builtin_strchr(_M_spec_char, _M_ctype.narrow(__c, ' ')) == nullptr) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + return; + } + if (__c == '\\') + { + if (_M_current == _M_end) + __throw_regex_error( + regex_constants::error_escape, + "Invalid escape at end of regular expression"); + + if (!_M_is_basic() + || (*_M_current != '(' + && *_M_current != ')' + && *_M_current != '{')) + { + (this->*_M_eat_escape)(); + return; + } + __c = *_M_current++; + } + if (__c == '(') + { + if (_M_is_ecma() && *_M_current == '?') + { + if (++_M_current == _M_end) + __throw_regex_error(regex_constants::error_paren); + + if (*_M_current == ':') + { + ++_M_current; + _M_token = _S_token_subexpr_no_group_begin; + } + else if (*_M_current == '=') + { + ++_M_current; + _M_token = _S_token_subexpr_lookahead_begin; + _M_value.assign(1, 'p'); + } + else if (*_M_current == '!') + { + ++_M_current; + _M_token = _S_token_subexpr_lookahead_begin; + _M_value.assign(1, 'n'); + } + else + __throw_regex_error(regex_constants::error_paren, + "Invalid '(?...)' zero-width assertion " + "in regular expression"); + } + else if (_M_flags & regex_constants::nosubs) + _M_token = _S_token_subexpr_no_group_begin; + else + _M_token = _S_token_subexpr_begin; + } + else if (__c == ')') + _M_token = _S_token_subexpr_end; + else if (__c == '[') + { + _M_state = _S_state_in_bracket; + _M_at_bracket_start = true; + if (_M_current != _M_end && *_M_current == '^') + { + _M_token = _S_token_bracket_neg_begin; + ++_M_current; + } + else + _M_token = _S_token_bracket_begin; + } + else if (__c == '{') + { + _M_state = _S_state_in_brace; + _M_token = _S_token_interval_begin; + } + else if (__builtin_expect(__c == _CharT(0), false)) + { + if (!_M_is_ecma()) + __throw_regex_error(regex_constants::_S_null); + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + else if (__c != ']' && __c != '}') + { + auto __it = _M_token_tbl; + auto __narrowc = _M_ctype.narrow(__c, '\0'); + for (; __it->first != '\0'; ++__it) + if (__it->first == __narrowc) + { + _M_token = __it->second; + return; + } + __glibcxx_assert(!"unexpected special character in regex"); + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + + // Differences between styles: + // 1) different semantics of "[]" and "[^]". + // 2) Escaping in bracket expr. + template + void + _Scanner<_CharT>:: + _M_scan_in_bracket() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_brack); + + auto __c = *_M_current++; + + if (__c == '-') + _M_token = _S_token_bracket_dash; + else if (__c == '[') + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_brack, + "Incomplete '[[' character class in " + "regular expression"); + + if (*_M_current == '.') + { + _M_token = _S_token_collsymbol; + _M_eat_class(*_M_current++); + } + else if (*_M_current == ':') + { + _M_token = _S_token_char_class_name; + _M_eat_class(*_M_current++); + } + else if (*_M_current == '=') + { + _M_token = _S_token_equiv_class_name; + _M_eat_class(*_M_current++); + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + // In POSIX, when encountering "[]" or "[^]", the ']' is interpreted + // literally. So "[]]" and "[^]]" are valid regexes. See the testcases + // `.../empty_range.cc`. + else if (__c == ']' && (_M_is_ecma() || !_M_at_bracket_start)) + { + _M_token = _S_token_bracket_end; + _M_state = _S_state_normal; + } + // ECMAScript and awk permits escaping in bracket. + else if (__c == '\\' && (_M_is_ecma() || _M_is_awk())) + (this->*_M_eat_escape)(); + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + _M_at_bracket_start = false; + } + + // Differences between styles: + // 1) "\}" in basic style. + template + void + _Scanner<_CharT>:: + _M_scan_in_brace() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_brace); + + auto __c = *_M_current++; + + if (_M_ctype.is(_CtypeT::digit, __c)) + { + _M_token = _S_token_dup_count; + _M_value.assign(1, __c); + while (_M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current)) + _M_value += *_M_current++; + } + else if (__c == ',') + _M_token = _S_token_comma; + // basic use \}. + else if (_M_is_basic()) + { + if (__c == '\\' && _M_current != _M_end && *_M_current == '}') + { + _M_state = _S_state_normal; + _M_token = _S_token_interval_end; + ++_M_current; + } + else + __throw_regex_error(regex_constants::error_badbrace); + } + else if (__c == '}') + { + _M_state = _S_state_normal; + _M_token = _S_token_interval_end; + } + else + __throw_regex_error(regex_constants::error_badbrace); + } + + template + void + _Scanner<_CharT>:: + _M_eat_escape_ecma() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_escape); + + auto __c = *_M_current++; + auto __pos = _M_find_escape(_M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr && (__c != 'b' || _M_state == _S_state_in_bracket)) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, *__pos); + } + else if (__c == 'b') + { + _M_token = _S_token_word_bound; + _M_value.assign(1, 'p'); + } + else if (__c == 'B') + { + _M_token = _S_token_word_bound; + _M_value.assign(1, 'n'); + } + // N3376 28.13 + else if (__c == 'd' + || __c == 'D' + || __c == 's' + || __c == 'S' + || __c == 'w' + || __c == 'W') + { + _M_token = _S_token_quoted_class; + _M_value.assign(1, __c); + } + else if (__c == 'c') + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_escape, + "invalid '\\cX' control character in " + "regular expression"); + _M_token = _S_token_ord_char; + _M_value.assign(1, *_M_current++); + } + else if (__c == 'x' || __c == 'u') + { + _M_value.clear(); + const int __n = __c == 'x' ? 2 : 4; + for (int __i = 0; __i < __n; __i++) + { + if (_M_current == _M_end + || !_M_ctype.is(_CtypeT::xdigit, *_M_current)) + __throw_regex_error(regex_constants::error_escape, + __n == 2 + ? "Invalid '\\xNN' control character in " + "regular expression" + : "Invalid '\\uNNNN' control character in " + "regular expression"); + _M_value += *_M_current++; + } + _M_token = _S_token_hex_num; + } + // ECMAScript recognizes multi-digit back-references. + else if (_M_ctype.is(_CtypeT::digit, __c)) + { + _M_value.assign(1, __c); + while (_M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current)) + _M_value += *_M_current++; + _M_token = _S_token_backref; + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + + // Differences between styles: + // 1) Extended doesn't support backref, but basic does. + template + void + _Scanner<_CharT>:: + _M_eat_escape_posix() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_escape); + + auto __c = *_M_current; + auto __pos = __builtin_strchr(_M_spec_char, _M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr && *__pos != '\0') + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + // We MUST judge awk before handling backrefs. There's no backref in awk. + else if (_M_is_awk()) + { + _M_eat_escape_awk(); + return; + } + else if (_M_is_basic() && _M_ctype.is(_CtypeT::digit, __c) && __c != '0') + { + _M_token = _S_token_backref; + _M_value.assign(1, __c); + } + else + { +#ifdef __STRICT_ANSI__ + // POSIX says it is undefined to escape ordinary characters + __throw_regex_error(regex_constants::error_escape); +#else + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); +#endif + } + ++_M_current; + } + + template + void + _Scanner<_CharT>:: + _M_eat_escape_awk() + { + auto __c = *_M_current++; + auto __pos = _M_find_escape(_M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, *__pos); + } + // \ddd for oct representation + else if (_M_ctype.is(_CtypeT::digit, __c) + && __c != '8' + && __c != '9') + { + _M_value.assign(1, __c); + for (int __i = 0; + __i < 2 + && _M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current) + && *_M_current != '8' + && *_M_current != '9'; + __i++) + _M_value += *_M_current++; + _M_token = _S_token_oct_num; + return; + } + else + __throw_regex_error(regex_constants::error_escape); + } + + // Eats a character class or throws an exception. + // __ch could be ':', '.' or '=', _M_current is the char after ']' when + // returning. + template + void + _Scanner<_CharT>:: + _M_eat_class(char __ch) + { + for (_M_value.clear(); _M_current != _M_end && *_M_current != __ch;) + _M_value += *_M_current++; + if (_M_current == _M_end + || *_M_current++ != __ch + || _M_current == _M_end // skip __ch + || *_M_current++ != ']') // skip ']' + { + __throw_regex_error(__ch == ':' ? regex_constants::error_ctype + : regex_constants::error_collate); + } + } + +#ifdef _GLIBCXX_DEBUG + template + std::ostream& + _Scanner<_CharT>:: + _M_print(std::ostream& ostr) + { + switch (_M_token) + { + case _S_token_anychar: + ostr << "any-character\n"; + break; + case _S_token_backref: + ostr << "backref\n"; + break; + case _S_token_bracket_begin: + ostr << "bracket-begin\n"; + break; + case _S_token_bracket_neg_begin: + ostr << "bracket-neg-begin\n"; + break; + case _S_token_bracket_end: + ostr << "bracket-end\n"; + break; + case _S_token_char_class_name: + ostr << "char-class-name \"" << _M_value << "\"\n"; + break; + case _S_token_closure0: + ostr << "closure0\n"; + break; + case _S_token_closure1: + ostr << "closure1\n"; + break; + case _S_token_collsymbol: + ostr << "collsymbol \"" << _M_value << "\"\n"; + break; + case _S_token_comma: + ostr << "comma\n"; + break; + case _S_token_dup_count: + ostr << "dup count: " << _M_value << "\n"; + break; + case _S_token_eof: + ostr << "EOF\n"; + break; + case _S_token_equiv_class_name: + ostr << "equiv-class-name \"" << _M_value << "\"\n"; + break; + case _S_token_interval_begin: + ostr << "interval begin\n"; + break; + case _S_token_interval_end: + ostr << "interval end\n"; + break; + case _S_token_line_begin: + ostr << "line begin\n"; + break; + case _S_token_line_end: + ostr << "line end\n"; + break; + case _S_token_opt: + ostr << "opt\n"; + break; + case _S_token_or: + ostr << "or\n"; + break; + case _S_token_ord_char: + ostr << "ordinary character: \"" << _M_value << "\"\n"; + break; + case _S_token_subexpr_begin: + ostr << "subexpr begin\n"; + break; + case _S_token_subexpr_no_group_begin: + ostr << "no grouping subexpr begin\n"; + break; + case _S_token_subexpr_lookahead_begin: + ostr << "lookahead subexpr begin\n"; + break; + case _S_token_subexpr_end: + ostr << "subexpr end\n"; + break; + case _S_token_unknown: + ostr << "-- unknown token --\n"; + break; + case _S_token_oct_num: + ostr << "oct number " << _M_value << "\n"; + break; + case _S_token_hex_num: + ostr << "hex number " << _M_value << "\n"; + break; + case _S_token_quoted_class: + ostr << "quoted class " << "\\" << _M_value << "\n"; + break; + default: + _GLIBCXX_DEBUG_ASSERT(false); + } + return ostr; + } +#endif + +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..1dd4ded6bd7248d8754d244463a241445b3ea2cd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@regex_scanner.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h new file mode 100644 index 0000000000000000000000000000000000000000..eb828dc35a8b0685aa04fcde33468a4e16b98a2e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h @@ -0,0 +1,1190 @@ +// shared_ptr and weak_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// GCC Note: Based on files from version 1.32.0 of the Boost library. + +// shared_count.hpp +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. + +// shared_ptr.hpp +// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// weak_ptr.hpp +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// enable_shared_from_this.hpp +// Copyright (C) 2002 Peter Dimov + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** @file + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_H +#define _SHARED_PTR_H 1 + +#include // std::basic_ostream +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + + // 20.7.2.2.11 shared_ptr I/O + + /// Write the stored pointer to an ostream. + /// @relates shared_ptr + template + inline std::basic_ostream<_Ch, _Tr>& + operator<<(std::basic_ostream<_Ch, _Tr>& __os, + const __shared_ptr<_Tp, _Lp>& __p) + { + __os << __p.get(); + return __os; + } + + template + inline _Del* + get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept + { +#if __cpp_rtti + return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); +#else + return 0; +#endif + } + + /// 20.7.2.2.10 shared_ptr get_deleter + + /// If `__p` has a deleter of type `_Del`, return a pointer to it. + /// @relates shared_ptr + template + inline _Del* + get_deleter(const shared_ptr<_Tp>& __p) noexcept + { +#if __cpp_rtti + return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); +#else + return 0; +#endif + } + + /// @cond undocumented + + // Constraint for overloads taking non-array types. +#if __cpp_concepts && __cpp_lib_type_trait_variable_templates + template + requires (!is_array_v<_Tp>) + using _NonArray = _Tp; +#else + template + using _NonArray = __enable_if_t::value, _Tp>; +#endif + +#if __cpp_lib_shared_ptr_arrays >= 201707L + // Constraint for overloads taking array types with unknown bound, U[]. +#if __cpp_concepts + template + requires is_array_v<_Tp> && (extent_v<_Tp> == 0) + using _UnboundedArray = _Tp; +#else + template + using _UnboundedArray + = __enable_if_t<__is_array_unknown_bounds<_Tp>::value, _Tp>; +#endif + + // Constraint for overloads taking array types with known bound, U[N]. +#if __cpp_concepts + template + requires (extent_v<_Tp> != 0) + using _BoundedArray = _Tp; +#else + template + using _BoundedArray + = __enable_if_t<__is_array_known_bounds<_Tp>::value, _Tp>; +#endif + +#if __cpp_lib_smart_ptr_for_overwrite + // Constraint for overloads taking either non-array or bounded array, U[N]. +#if __cpp_concepts + template + requires (!is_array_v<_Tp>) || (extent_v<_Tp> != 0) + using _NotUnboundedArray = _Tp; +#else + template + using _NotUnboundedArray + = __enable_if_t::value, _Tp>; +#endif +#endif // smart_ptr_for_overwrite +#endif // shared_ptr_arrays + + /// @endcond + + /** + * @brief A smart pointer with reference-counted copy semantics. + * @headerfile memory + * @since C++11 + * + * A `shared_ptr` object is either empty or _owns_ a pointer passed + * to the constructor. Copies of a `shared_ptr` share ownership of + * the same pointer. When the last `shared_ptr` that owns the pointer + * is destroyed or reset, the owned pointer is freed (either by `delete` + * or by invoking a custom deleter that was passed to the constructor). + * + * A `shared_ptr` also stores another pointer, which is usually + * (but not always) the same pointer as it owns. The stored pointer + * can be retrieved by calling the `get()` member function. + * + * The equality and relational operators for `shared_ptr` only compare + * the stored pointer returned by `get()`, not the owned pointer. + * To test whether two `shared_ptr` objects share ownership of the same + * pointer see `std::shared_ptr::owner_before` and `std::owner_less`. + */ + template + class shared_ptr : public __shared_ptr<_Tp> + { + template + using _Constructible = typename enable_if< + is_constructible<__shared_ptr<_Tp>, _Args...>::value + >::type; + + template + using _Assignable = typename enable_if< + is_assignable<__shared_ptr<_Tp>&, _Arg>::value, shared_ptr& + >::type; + + public: + + /// The type pointed to by the stored pointer, remove_extent_t<_Tp> + using element_type = typename __shared_ptr<_Tp>::element_type; + +#if __cplusplus >= 201703L +# define __cpp_lib_shared_ptr_weak_type 201606L + /// The corresponding weak_ptr type for this shared_ptr + /// @since C++17 + using weak_type = weak_ptr<_Tp>; +#endif + /** + * @brief Construct an empty %shared_ptr. + * @post use_count()==0 && get()==0 + */ + constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } + + shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p. + * @param __p A pointer that is convertible to element_type*. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @c delete @a __p is called. + */ + template> + explicit + shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p + * and the deleter @a __d. + * @param __p A pointer. + * @param __d A deleter. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw + * + * __shared_ptr will release __p by calling __d(__p) + */ + template> + shared_ptr(_Yp* __p, _Deleter __d) + : __shared_ptr<_Tp>(__p, std::move(__d)) { } + + /** + * @brief Construct a %shared_ptr that owns a null pointer + * and the deleter @a __d. + * @param __p A null pointer constant. + * @param __d A deleter. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw + * + * The last owner will call __d(__p) + */ + template + shared_ptr(nullptr_t __p, _Deleter __d) + : __shared_ptr<_Tp>(__p, std::move(__d)) { } + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p + * and the deleter @a __d. + * @param __p A pointer. + * @param __d A deleter. + * @param __a An allocator. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw _Alloc's copy constructor and destructor must not + * throw. + * + * __shared_ptr will release __p by calling __d(__p) + */ + template> + shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) + : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } + + /** + * @brief Construct a %shared_ptr that owns a null pointer + * and the deleter @a __d. + * @param __p A null pointer constant. + * @param __d A deleter. + * @param __a An allocator. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw _Alloc's copy constructor and destructor must not + * throw. + * + * The last owner will call __d(__p) + */ + template + shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) + : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } + + // Aliasing constructor + + /** + * @brief Constructs a `shared_ptr` instance that stores `__p` + * and shares ownership with `__r`. + * @param __r A `shared_ptr`. + * @param __p A pointer that will remain valid while `*__r` is valid. + * @post `get() == __p && use_count() == __r.use_count()` + * + * This can be used to construct a `shared_ptr` to a sub-object + * of an object managed by an existing `shared_ptr`. The complete + * object will remain valid while any `shared_ptr` owns it, even + * if they don't store a pointer to the complete object. + * + * @code + * shared_ptr> pii(new pair()); + * shared_ptr pi(pii, &pii->first); + * assert(pii.use_count() == 2); + * @endcode + */ + template + shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept + : __shared_ptr<_Tp>(__r, __p) { } + +#if __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2996. Missing rvalue overloads for shared_ptr operations + /** + * @brief Constructs a `shared_ptr` instance that stores `__p` + * and shares ownership with `__r`. + * @param __r A `shared_ptr`. + * @param __p A pointer that will remain valid while `*__r` is valid. + * @post `get() == __p && !__r.use_count() && !__r.get()` + * @since C++17 + * + * This can be used to construct a `shared_ptr` to a sub-object + * of an object managed by an existing `shared_ptr`. The complete + * object will remain valid while any `shared_ptr` owns it, even + * if they don't store a pointer to the complete object. + * + * @code + * shared_ptr> pii(new pair()); + * shared_ptr pi1(pii, &pii->first); + * assert(pii.use_count() == 2); + * shared_ptr pi2(std::move(pii), &pii->second); + * assert(pii.use_count() == 0); + * @endcode + */ + template + shared_ptr(shared_ptr<_Yp>&& __r, element_type* __p) noexcept + : __shared_ptr<_Tp>(std::move(__r), __p) { } +#endif + /** + * @brief If @a __r is empty, constructs an empty %shared_ptr; + * otherwise construct a %shared_ptr that shares ownership + * with @a __r. + * @param __r A %shared_ptr. + * @post get() == __r.get() && use_count() == __r.use_count() + */ + template&>> + shared_ptr(const shared_ptr<_Yp>& __r) noexcept + : __shared_ptr<_Tp>(__r) { } + + /** + * @brief Move-constructs a %shared_ptr instance from @a __r. + * @param __r A %shared_ptr rvalue. + * @post *this contains the old value of @a __r, @a __r is empty. + */ + shared_ptr(shared_ptr&& __r) noexcept + : __shared_ptr<_Tp>(std::move(__r)) { } + + /** + * @brief Move-constructs a %shared_ptr instance from @a __r. + * @param __r A %shared_ptr rvalue. + * @post *this contains the old value of @a __r, @a __r is empty. + */ + template>> + shared_ptr(shared_ptr<_Yp>&& __r) noexcept + : __shared_ptr<_Tp>(std::move(__r)) { } + + /** + * @brief Constructs a %shared_ptr that shares ownership with @a __r + * and stores a copy of the pointer stored in @a __r. + * @param __r A weak_ptr. + * @post use_count() == __r.use_count() + * @throw bad_weak_ptr when __r.expired(), + * in which case the constructor has no effect. + */ + template&>> + explicit shared_ptr(const weak_ptr<_Yp>& __r) + : __shared_ptr<_Tp>(__r) { } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template>> + shared_ptr(auto_ptr<_Yp>&& __r); +#pragma GCC diagnostic pop +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2399. shared_ptr's constructor from unique_ptr should be constrained + template>> + shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : __shared_ptr<_Tp>(std::move(__r)) { } + +#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED + // This non-standard constructor exists to support conversions that + // were possible in C++11 and C++14 but are ill-formed in C++17. + // If an exception is thrown this constructor has no effect. + template, __sp_array_delete>* = 0> + shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : __shared_ptr<_Tp>(std::move(__r), __sp_array_delete()) { } +#endif + + /** + * @brief Construct an empty %shared_ptr. + * @post use_count() == 0 && get() == nullptr + */ + constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } + + shared_ptr& operator=(const shared_ptr&) noexcept = default; + + template + _Assignable&> + operator=(const shared_ptr<_Yp>& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(__r); + return *this; + } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template + _Assignable> + operator=(auto_ptr<_Yp>&& __r) + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } +#pragma GCC diagnostic pop +#endif + + shared_ptr& + operator=(shared_ptr&& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + template + _Assignable> + operator=(shared_ptr<_Yp>&& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + template + _Assignable> + operator=(unique_ptr<_Yp, _Del>&& __r) + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + private: + // This constructor is non-standard, it is used by allocate_shared. + template + shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) + : __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...) + { } + + template + friend shared_ptr<_NonArray<_Yp>> + allocate_shared(const _Alloc&, _Args&&...); + + template + friend shared_ptr<_NonArray<_Yp>> + make_shared(_Args&&...); + +#if __cpp_lib_shared_ptr_arrays >= 201707L + // This constructor is non-standard, it is used by allocate_shared. + template*> + shared_ptr(const _Sp_counted_array_base<_Alloc>& __a, + _Init __init = nullptr) + : __shared_ptr<_Tp>(__a, __init) + { } + + template + friend shared_ptr<_UnboundedArray<_Yp>> + allocate_shared(const _Alloc&, size_t); + + template + friend shared_ptr<_UnboundedArray<_Yp>> + make_shared(size_t); + + template + friend shared_ptr<_UnboundedArray<_Yp>> + allocate_shared(const _Alloc&, size_t, const remove_extent_t<_Yp>&); + + template + friend shared_ptr<_UnboundedArray<_Yp>> + make_shared(size_t, const remove_extent_t<_Yp>&); + + template + friend shared_ptr<_BoundedArray<_Yp>> + allocate_shared(const _Alloc&); + + template + friend shared_ptr<_BoundedArray<_Yp>> + make_shared(); + + template + friend shared_ptr<_BoundedArray<_Yp>> + allocate_shared(const _Alloc&, const remove_extent_t<_Yp>&); + + template + friend shared_ptr<_BoundedArray<_Yp>> + make_shared(const remove_extent_t<_Yp>&); + +#if __cpp_lib_smart_ptr_for_overwrite + template + friend shared_ptr<_NotUnboundedArray<_Yp>> + allocate_shared_for_overwrite(const _Alloc&); + + template + friend shared_ptr<_NotUnboundedArray<_Yp>> + make_shared_for_overwrite(); + + template + friend shared_ptr<_UnboundedArray<_Yp>> + allocate_shared_for_overwrite(const _Alloc&, size_t); + + template + friend shared_ptr<_UnboundedArray<_Yp>> + make_shared_for_overwrite(size_t); +#endif +#endif + + // This constructor is non-standard, it is used by weak_ptr::lock(). + shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) noexcept + : __shared_ptr<_Tp>(__r, std::nothrow) { } + + friend class weak_ptr<_Tp>; + }; + +#if __cpp_deduction_guides >= 201606 + template + shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; + template + shared_ptr(unique_ptr<_Tp, _Del>) -> shared_ptr<_Tp>; +#endif + + // 20.7.2.2.7 shared_ptr comparisons + + /// @relates shared_ptr @{ + + /// Equality operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return __a.get() == __b.get(); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !__a; } + +#ifdef __cpp_lib_three_way_comparison + template + inline strong_ordering + operator<=>(const shared_ptr<_Tp>& __a, + const shared_ptr<_Up>& __b) noexcept + { return compare_three_way()(__a.get(), __b.get()); } + + template + inline strong_ordering + operator<=>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using pointer = typename shared_ptr<_Tp>::element_type*; + return compare_three_way()(__a.get(), static_cast(nullptr)); + } +#else + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !__a; } + + /// Inequality operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator!=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return __a.get() != __b.get(); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return (bool)__a; } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return (bool)__a; } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator<(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + using _Up_elt = typename shared_ptr<_Up>::element_type; + using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; + return less<_Vp>()(__a.get(), __b.get()); + } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + return less<_Tp_elt*>()(__a.get(), nullptr); + } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + return less<_Tp_elt*>()(nullptr, __a.get()); + } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator<=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return !(__b < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(nullptr < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(__a < nullptr); } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator>(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return (__b < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return nullptr < __a; } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return __a < nullptr; } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator>=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return !(__a < __b); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(__a < nullptr); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(nullptr < __a); } +#endif + + // 20.7.2.2.8 shared_ptr specialized algorithms. + + /// Swap overload for shared_ptr + template + inline void + swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } + + // 20.7.2.2.9 shared_ptr casts. + + /// Convert type of `shared_ptr`, via `static_cast` + template + inline shared_ptr<_Tp> + static_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, static_cast(__r.get())); + } + + /// Convert type of `shared_ptr`, via `const_cast` + template + inline shared_ptr<_Tp> + const_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, const_cast(__r.get())); + } + + /// Convert type of `shared_ptr`, via `dynamic_cast` + template + inline shared_ptr<_Tp> + dynamic_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(__r, __p); + return _Sp(); + } + +#if __cplusplus >= 201703L + /// Convert type of `shared_ptr`, via `reinterpret_cast` + /// @since C++17 + template + inline shared_ptr<_Tp> + reinterpret_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, reinterpret_cast(__r.get())); + } + +#if __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2996. Missing rvalue overloads for shared_ptr operations + + /// Convert type of `shared_ptr` rvalue, via `static_cast` + /// @since C++20 + template + inline shared_ptr<_Tp> + static_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + static_cast(__r.get())); + } + + /// Convert type of `shared_ptr` rvalue, via `const_cast` + /// @since C++20 + template + inline shared_ptr<_Tp> + const_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + const_cast(__r.get())); + } + + /// Convert type of `shared_ptr` rvalue, via `dynamic_cast` + /// @since C++20 + template + inline shared_ptr<_Tp> + dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(std::move(__r), __p); + return _Sp(); + } + + /// Convert type of `shared_ptr` rvalue, via `reinterpret_cast` + /// @since C++20 + template + inline shared_ptr<_Tp> + reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + reinterpret_cast(__r.get())); + } +#endif // C++20 +#endif // C++17 + + /// @} + + /** + * @brief A non-owning observer for a pointer owned by a shared_ptr + * @headerfile memory + * @since C++11 + * + * A weak_ptr provides a safe alternative to a raw pointer when you want + * a non-owning reference to an object that is managed by a shared_ptr. + * + * Unlike a raw pointer, a weak_ptr can be converted to a new shared_ptr + * that shares ownership with every other shared_ptr that already owns + * the pointer. In other words you can upgrade from a non-owning "weak" + * reference to an owning shared_ptr, without having access to any of + * the existing shared_ptr objects. + * + * Also unlike a raw pointer, a weak_ptr does not become "dangling" after + * the object it points to has been destroyed. Instead, a weak_ptr + * becomes _expired_ and can no longer be converted to a shared_ptr that + * owns the freed pointer, so you cannot accidentally access the pointed-to + * object after it has been destroyed. + */ + template + class weak_ptr : public __weak_ptr<_Tp> + { + template + using _Constructible = typename enable_if< + is_constructible<__weak_ptr<_Tp>, _Arg>::value + >::type; + + template + using _Assignable = typename enable_if< + is_assignable<__weak_ptr<_Tp>&, _Arg>::value, weak_ptr& + >::type; + + public: + constexpr weak_ptr() noexcept = default; + + template&>> + weak_ptr(const shared_ptr<_Yp>& __r) noexcept + : __weak_ptr<_Tp>(__r) { } + + weak_ptr(const weak_ptr&) noexcept = default; + + template&>> + weak_ptr(const weak_ptr<_Yp>& __r) noexcept + : __weak_ptr<_Tp>(__r) { } + + weak_ptr(weak_ptr&&) noexcept = default; + + template>> + weak_ptr(weak_ptr<_Yp>&& __r) noexcept + : __weak_ptr<_Tp>(std::move(__r)) { } + + weak_ptr& + operator=(const weak_ptr& __r) noexcept = default; + + template + _Assignable&> + operator=(const weak_ptr<_Yp>& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + template + _Assignable&> + operator=(const shared_ptr<_Yp>& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + weak_ptr& + operator=(weak_ptr&& __r) noexcept = default; + + template + _Assignable> + operator=(weak_ptr<_Yp>&& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + shared_ptr<_Tp> + lock() const noexcept + { return shared_ptr<_Tp>(*this, std::nothrow); } + }; + +#if __cpp_deduction_guides >= 201606 + template + weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; +#endif + + // 20.7.2.3.6 weak_ptr specialized algorithms. + /// Swap overload for weak_ptr + /// @relates weak_ptr + template + inline void + swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } + + + /// Primary template owner_less + template + struct owner_less; + + /// Void specialization of owner_less compares either shared_ptr or weak_ptr + template<> + struct owner_less : _Sp_owner_less + { }; + + /// Partial specialization of owner_less for shared_ptr. + template + struct owner_less> + : public _Sp_owner_less, weak_ptr<_Tp>> + { }; + + /// Partial specialization of owner_less for weak_ptr. + template + struct owner_less> + : public _Sp_owner_less, shared_ptr<_Tp>> + { }; + + /** + * @brief Base class allowing use of the member function `shared_from_this`. + * @headerfile memory + * @since C++11 + */ + template + class enable_shared_from_this + { + protected: + constexpr enable_shared_from_this() noexcept { } + + enable_shared_from_this(const enable_shared_from_this&) noexcept { } + + enable_shared_from_this& + operator=(const enable_shared_from_this&) noexcept + { return *this; } + + ~enable_shared_from_this() { } + + public: + shared_ptr<_Tp> + shared_from_this() + { return shared_ptr<_Tp>(this->_M_weak_this); } + + shared_ptr + shared_from_this() const + { return shared_ptr(this->_M_weak_this); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 +#define __cpp_lib_enable_shared_from_this 201603L + /** @{ + * Get a `weak_ptr` referring to the object that has `*this` as its base. + * @since C++17 + */ + weak_ptr<_Tp> + weak_from_this() noexcept + { return this->_M_weak_this; } + + weak_ptr + weak_from_this() const noexcept + { return this->_M_weak_this; } + /// @} +#endif + + private: + template + void + _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept + { _M_weak_this._M_assign(__p, __n); } + + // Found by ADL when this is an associated class. + friend const enable_shared_from_this* + __enable_shared_from_this_base(const __shared_count<>&, + const enable_shared_from_this* __p) + { return __p; } + + template + friend class __shared_ptr; + + mutable weak_ptr<_Tp> _M_weak_this; + }; + + /// @relates shared_ptr @{ + + /** + * @brief Create an object that is owned by a shared_ptr. + * @param __a An allocator. + * @param __args Arguments for the @a _Tp object's constructor. + * @return A shared_ptr that owns the newly created object. + * @throw An exception thrown from @a _Alloc::allocate or from the + * constructor of @a _Tp. + * + * A copy of @a __a will be used to allocate memory for the shared_ptr + * and the new object. + */ + template + inline shared_ptr<_NonArray<_Tp>> + allocate_shared(const _Alloc& __a, _Args&&... __args) + { + return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a}, + std::forward<_Args>(__args)...); + } + + /** + * @brief Create an object that is owned by a shared_ptr. + * @param __args Arguments for the @a _Tp object's constructor. + * @return A shared_ptr that owns the newly created object. + * @throw std::bad_alloc, or an exception thrown from the + * constructor of @a _Tp. + */ + template + inline shared_ptr<_NonArray<_Tp>> + make_shared(_Args&&... __args) + { + using _Alloc = allocator; + _Alloc __a; + return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a}, + std::forward<_Args>(__args)...); + } + +#if __cpp_lib_shared_ptr_arrays >= 201707L + /// @cond undocumented + template> + auto + __make_shared_arr_tag(size_t __n, const _Alloc& __a = _Alloc()) noexcept + { + using _Up = remove_all_extents_t<_Tp>; + using _UpAlloc = __alloc_rebind<_Alloc, _Up>; + size_t __s = sizeof(remove_extent_t<_Tp>) / sizeof(_Up); + if (__builtin_mul_overflow(__s, __n, &__n)) + std::__throw_bad_array_new_length(); + return _Sp_counted_array_base<_UpAlloc>{_UpAlloc(__a), __n}; + } + /// @endcond + + template + inline shared_ptr<_UnboundedArray<_Tp>> + allocate_shared(const _Alloc& __a, size_t __n) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n, __a)); + } + + template + inline shared_ptr<_UnboundedArray<_Tp>> + make_shared(size_t __n) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n)); + } + + template + inline shared_ptr<_UnboundedArray<_Tp>> + allocate_shared(const _Alloc& __a, size_t __n, + const remove_extent_t<_Tp>& __u) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n, __a), + std::__addressof(__u)); + } + + template + inline shared_ptr<_UnboundedArray<_Tp>> + make_shared(size_t __n, const remove_extent_t<_Tp>& __u) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n), + std::__addressof(__u)); + } + + /// @cond undocumented + template> + auto + __make_shared_arrN_tag(const _Alloc& __a = _Alloc()) noexcept + { + using _Up = remove_all_extents_t<_Tp>; + using _UpAlloc = __alloc_rebind<_Alloc, _Up>; + size_t __n = sizeof(_Tp) / sizeof(_Up); + return _Sp_counted_array_base<_UpAlloc>{_UpAlloc(__a), __n}; + } + /// @endcond + + template + inline shared_ptr<_BoundedArray<_Tp>> + allocate_shared(const _Alloc& __a) + { + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>(__a)); + } + + template + inline shared_ptr<_BoundedArray<_Tp>> + make_shared() + { + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>()); + } + + template + inline shared_ptr<_BoundedArray<_Tp>> + allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) + { + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>(__a), + std::__addressof(__u)); + } + + template + inline shared_ptr<_BoundedArray<_Tp>> + make_shared(const remove_extent_t<_Tp>& __u) + { + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>(), + std::__addressof(__u)); + } + +#if __cpp_lib_smart_ptr_for_overwrite + template + inline shared_ptr<_NotUnboundedArray<_Tp>> + allocate_shared_for_overwrite(const _Alloc& __a) + { + if constexpr (is_array_v<_Tp>) + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>(__a), + _Sp_overwrite_tag{}); + else + { + // Rebind the allocator to _Sp_overwrite_tag, so that the + // relevant _Sp_counted_ptr_inplace specialization is used. + using _Alloc2 = __alloc_rebind<_Alloc, _Sp_overwrite_tag>; + _Alloc2 __a2 = __a; + return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc2>{__a2}); + } + } + + template + inline shared_ptr<_NotUnboundedArray<_Tp>> + make_shared_for_overwrite() + { + if constexpr (is_array_v<_Tp>) + return shared_ptr<_Tp>(std::__make_shared_arrN_tag<_Tp>(), + _Sp_overwrite_tag{}); + else + { + using _Alloc = allocator<_Sp_overwrite_tag>; + return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{{}}); + } + } + + template + inline shared_ptr<_UnboundedArray<_Tp>> + allocate_shared_for_overwrite(const _Alloc& __a, size_t __n) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n, __a), + _Sp_overwrite_tag{}); + } + + template + inline shared_ptr<_UnboundedArray<_Tp>> + make_shared_for_overwrite(size_t __n) + { + return shared_ptr<_Tp>(std::__make_shared_arr_tag<_Tp>(__n), + _Sp_overwrite_tag{}); + } +#endif // smart_ptr_for_overwrite +#endif // shared_ptr_arrays + + /// std::hash specialization for shared_ptr. + template + struct hash> + : public __hash_base> + { + size_t + operator()(const shared_ptr<_Tp>& __s) const noexcept + { + return std::hash::element_type*>()(__s.get()); + } + }; + + /// @} relates shared_ptr + /// @} group pointer_abstractions + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // shared_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + + // Provide the strong exception-safety guarantee when emplacing a + // weak_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4f81c660093a0357c5dd8a4c3592482ac5aa8c7f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h new file mode 100644 index 0000000000000000000000000000000000000000..ff86432f0b40398ab450f878d9e14dd09e6d7e8e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h @@ -0,0 +1,799 @@ +// shared_ptr atomic access -*- C++ -*- + +// Copyright (C) 2014-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/shared_ptr_atomic.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_ATOMIC_H +#define _SHARED_PTR_ATOMIC_H 1 + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + /// @relates shared_ptr @{ + + /// @cond undocumented + + struct _Sp_locker + { + _Sp_locker(const _Sp_locker&) = delete; + _Sp_locker& operator=(const _Sp_locker&) = delete; + +#ifdef __GTHREADS + explicit + _Sp_locker(const void*) noexcept; + _Sp_locker(const void*, const void*) noexcept; + ~_Sp_locker(); + + private: + unsigned char _M_key1; + unsigned char _M_key2; +#else + explicit _Sp_locker(const void*, const void* = nullptr) { } +#endif + }; + + /// @endcond + + /** + * @brief Report whether shared_ptr atomic operations are lock-free. + * @param __p A non-null pointer to a shared_ptr object. + * @return True if atomic access to @c *__p is lock-free, false otherwise. + * @{ + */ + template + inline bool + atomic_is_lock_free(const __shared_ptr<_Tp, _Lp>* __p) + { +#ifdef __GTHREADS + return __gthread_active_p() == 0; +#else + return true; +#endif + } + + template + inline bool + atomic_is_lock_free(const shared_ptr<_Tp>* __p) + { return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); } + + /// @} + + /** + * @brief Atomic load for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @return @c *__p + * + * The memory order shall not be @c memory_order_release or + * @c memory_order_acq_rel. + * @{ + */ + template + inline shared_ptr<_Tp> + atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) + { + _Sp_locker __lock{__p}; + return *__p; + } + + template + inline shared_ptr<_Tp> + atomic_load(const shared_ptr<_Tp>* __p) + { return std::atomic_load_explicit(__p, memory_order_seq_cst); } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_load_explicit(const __shared_ptr<_Tp, _Lp>* __p, memory_order) + { + _Sp_locker __lock{__p}; + return *__p; + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_load(const __shared_ptr<_Tp, _Lp>* __p) + { return std::atomic_load_explicit(__p, memory_order_seq_cst); } + /// @} + + /** + * @brief Atomic store for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __r The value to store. + * + * The memory order shall not be @c memory_order_acquire or + * @c memory_order_acq_rel. + * @{ + */ + template + inline void + atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); // use swap so that **__p not destroyed while lock held + } + + template + inline void + atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) + { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } + + template + inline void + atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); // use swap so that **__p not destroyed while lock held + } + + template + inline void + atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) + { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } + /// @} + + /** + * @brief Atomic exchange for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __r New value to store in @c *__p. + * @return The original value of @c *__p + * @{ + */ + template + inline shared_ptr<_Tp> + atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); + return __r; + } + + template + inline shared_ptr<_Tp> + atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) + { + return std::atomic_exchange_explicit(__p, std::move(__r), + memory_order_seq_cst); + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); + return __r; + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) + { + return std::atomic_exchange_explicit(__p, std::move(__r), + memory_order_seq_cst); + } + /// @} + + /** + * @brief Atomic compare-and-swap for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __v A non-null pointer to a shared_ptr object. + * @param __w A non-null pointer to a shared_ptr object. + * @return True if @c *__p was equivalent to @c *__v, false otherwise. + * + * The memory order for failure shall not be @c memory_order_release or + * @c memory_order_acq_rel, or stronger than the memory order for success. + * @{ + */ + template + bool + atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, + shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w, + memory_order, + memory_order) + { + shared_ptr<_Tp> __x; // goes out of scope after __lock + _Sp_locker __lock{__p, __v}; + owner_less> __less; + if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) + { + __x = std::move(*__p); + *__p = std::move(__w); + return true; + } + __x = std::move(*__v); + *__v = *__p; + return false; + } + + template + inline bool + atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, + shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w, + memory_order __success, + memory_order __failure) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), __success, __failure); + } + + template + inline bool + atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w) + { + return std::atomic_compare_exchange_weak_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + bool + atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w, + memory_order, + memory_order) + { + __shared_ptr<_Tp, _Lp> __x; // goes out of scope after __lock + _Sp_locker __lock{__p, __v}; + owner_less<__shared_ptr<_Tp, _Lp>> __less; + if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) + { + __x = std::move(*__p); + *__p = std::move(__w); + return true; + } + __x = std::move(*__v); + *__v = *__p; + return false; + } + + template + inline bool + atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w, + memory_order __success, + memory_order __failure) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), __success, __failure); + } + + template + inline bool + atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w) + { + return std::atomic_compare_exchange_weak_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + /// @} + +#if __cplusplus >= 202002L +# define __cpp_lib_atomic_shared_ptr 201711L + template + class atomic; + + template + static constexpr bool __is_shared_ptr = false; + template + static constexpr bool __is_shared_ptr> = true; + + template + class _Sp_atomic + { + using value_type = _Tp; + + friend class atomic<_Tp>; + + // An atomic version of __shared_count<> and __weak_count<>. + // Stores a _Sp_counted_base<>* but uses the LSB as a lock. + struct _Atomic_count + { + // Either __shared_count<> or __weak_count<> + using __count_type = decltype(_Tp::_M_refcount); + + // _Sp_counted_base<>* + using pointer = decltype(__count_type::_M_pi); + + // Ensure we can use the LSB as the lock bit. + static_assert(alignof(remove_pointer_t) > 1); + + constexpr _Atomic_count() noexcept = default; + + explicit + _Atomic_count(__count_type&& __c) noexcept + : _M_val(reinterpret_cast(__c._M_pi)) + { + __c._M_pi = nullptr; + } + + ~_Atomic_count() + { + auto __val = _M_val.load(memory_order_relaxed); + __glibcxx_assert(!(__val & _S_lock_bit)); + if (auto __pi = reinterpret_cast(__val)) + { + if constexpr (__is_shared_ptr<_Tp>) + __pi->_M_release(); + else + __pi->_M_weak_release(); + } + } + + _Atomic_count(const _Atomic_count&) = delete; + _Atomic_count& operator=(const _Atomic_count&) = delete; + + // Precondition: Caller does not hold lock! + // Returns the raw pointer value without the lock bit set. + pointer + lock(memory_order __o) const noexcept + { + // To acquire the lock we flip the LSB from 0 to 1. + + auto __current = _M_val.load(memory_order_relaxed); + while (__current & _S_lock_bit) + { +#if __cpp_lib_atomic_wait + __detail::__thread_relax(); +#endif + __current = _M_val.load(memory_order_relaxed); + } + + while (!_M_val.compare_exchange_strong(__current, + __current | _S_lock_bit, + __o, + memory_order_relaxed)) + { +#if __cpp_lib_atomic_wait + __detail::__thread_relax(); +#endif + __current = __current & ~_S_lock_bit; + } + return reinterpret_cast(__current); + } + + // Precondition: caller holds lock! + void + unlock(memory_order __o) const noexcept + { + _M_val.fetch_sub(1, __o); + } + + // Swaps the values of *this and __c, and unlocks *this. + // Precondition: caller holds lock! + void + _M_swap_unlock(__count_type& __c, memory_order __o) noexcept + { + if (__o != memory_order_seq_cst) + __o = memory_order_release; + auto __x = reinterpret_cast(__c._M_pi); + __x = _M_val.exchange(__x, __o); + __c._M_pi = reinterpret_cast(__x & ~_S_lock_bit); + } + +#if __cpp_lib_atomic_wait + // Precondition: caller holds lock! + void + _M_wait_unlock(memory_order __o) const noexcept + { + auto __v = _M_val.fetch_sub(1, memory_order_relaxed); + _M_val.wait(__v & ~_S_lock_bit, __o); + } + + void + notify_one() noexcept + { + _M_val.notify_one(); + } + + void + notify_all() noexcept + { + _M_val.notify_all(); + } +#endif + + private: + mutable __atomic_base _M_val{0}; + static constexpr uintptr_t _S_lock_bit{1}; + }; + + typename _Tp::element_type* _M_ptr = nullptr; + _Atomic_count _M_refcount; + + static typename _Atomic_count::pointer + _S_add_ref(typename _Atomic_count::pointer __p) + { + if (__p) + { + if constexpr (__is_shared_ptr<_Tp>) + __p->_M_add_ref_copy(); + else + __p->_M_weak_add_ref(); + } + return __p; + } + + constexpr _Sp_atomic() noexcept = default; + + explicit + _Sp_atomic(value_type __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount)) + { } + + ~_Sp_atomic() = default; + + _Sp_atomic(const _Sp_atomic&) = delete; + void operator=(const _Sp_atomic&) = delete; + + value_type + load(memory_order __o) const noexcept + { + __glibcxx_assert(__o != memory_order_release + && __o != memory_order_acq_rel); + // Ensure that the correct value of _M_ptr is visible after locking., + // by upgrading relaxed or consume to acquire. + if (__o != memory_order_seq_cst) + __o = memory_order_acquire; + + value_type __ret; + auto __pi = _M_refcount.lock(__o); + __ret._M_ptr = _M_ptr; + __ret._M_refcount._M_pi = _S_add_ref(__pi); + _M_refcount.unlock(memory_order_relaxed); + return __ret; + } + + void + swap(value_type& __r, memory_order __o) noexcept + { + _M_refcount.lock(memory_order_acquire); + std::swap(_M_ptr, __r._M_ptr); + _M_refcount._M_swap_unlock(__r._M_refcount, __o); + } + + bool + compare_exchange_strong(value_type& __expected, value_type __desired, + memory_order __o, memory_order __o2) noexcept + { + bool __result = true; + auto __pi = _M_refcount.lock(memory_order_acquire); + if (_M_ptr == __expected._M_ptr + && __pi == __expected._M_refcount._M_pi) + { + _M_ptr = __desired._M_ptr; + _M_refcount._M_swap_unlock(__desired._M_refcount, __o); + } + else + { + _Tp __sink = std::move(__expected); + __expected._M_ptr = _M_ptr; + __expected._M_refcount._M_pi = _S_add_ref(__pi); + _M_refcount.unlock(__o2); + __result = false; + } + return __result; + } + +#if __cpp_lib_atomic_wait + void + wait(value_type __old, memory_order __o) const noexcept + { + auto __pi = _M_refcount.lock(memory_order_acquire); + if (_M_ptr == __old._M_ptr && __pi == __old._M_refcount._M_pi) + _M_refcount._M_wait_unlock(__o); + else + _M_refcount.unlock(memory_order_relaxed); + } + + void + notify_one() noexcept + { + _M_refcount.notify_one(); + } + + void + notify_all() noexcept + { + _M_refcount.notify_all(); + } +#endif + }; + + template + class atomic> + { + public: + using value_type = shared_ptr<_Tp>; + + static constexpr bool is_always_lock_free = false; + + bool + is_lock_free() const noexcept + { return false; } + + constexpr atomic() noexcept = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3661. constinit atomic> a(nullptr); should work + constexpr atomic(nullptr_t) noexcept : atomic() { } + + atomic(shared_ptr<_Tp> __r) noexcept + : _M_impl(std::move(__r)) + { } + + atomic(const atomic&) = delete; + void operator=(const atomic&) = delete; + + shared_ptr<_Tp> + load(memory_order __o = memory_order_seq_cst) const noexcept + { return _M_impl.load(__o); } + + operator shared_ptr<_Tp>() const noexcept + { return _M_impl.load(memory_order_seq_cst); } + + void + store(shared_ptr<_Tp> __desired, + memory_order __o = memory_order_seq_cst) noexcept + { _M_impl.swap(__desired, __o); } + + void + operator=(shared_ptr<_Tp> __desired) noexcept + { _M_impl.swap(__desired, memory_order_seq_cst); } + + shared_ptr<_Tp> + exchange(shared_ptr<_Tp> __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + _M_impl.swap(__desired, __o); + return __desired; + } + + bool + compare_exchange_strong(shared_ptr<_Tp>& __expected, + shared_ptr<_Tp> __desired, + memory_order __o, memory_order __o2) noexcept + { + return _M_impl.compare_exchange_strong(__expected, __desired, __o, __o2); + } + + bool + compare_exchange_strong(value_type& __expected, value_type __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + memory_order __o2; + switch (__o) + { + case memory_order_acq_rel: + __o2 = memory_order_acquire; + break; + case memory_order_release: + __o2 = memory_order_relaxed; + break; + default: + __o2 = __o; + } + return compare_exchange_strong(__expected, std::move(__desired), + __o, __o2); + } + + bool + compare_exchange_weak(value_type& __expected, value_type __desired, + memory_order __o, memory_order __o2) noexcept + { + return compare_exchange_strong(__expected, std::move(__desired), + __o, __o2); + } + + bool + compare_exchange_weak(value_type& __expected, value_type __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + return compare_exchange_strong(__expected, std::move(__desired), __o); + } + +#if __cpp_lib_atomic_wait + void + wait(value_type __old, + memory_order __o = memory_order_seq_cst) const noexcept + { + _M_impl.wait(std::move(__old), __o); + } + + void + notify_one() noexcept + { + _M_impl.notify_one(); + } + + void + notify_all() noexcept + { + _M_impl.notify_all(); + } +#endif + + private: + _Sp_atomic> _M_impl; + }; + + template + class atomic> + { + public: + using value_type = weak_ptr<_Tp>; + + static constexpr bool is_always_lock_free = false; + + bool + is_lock_free() const noexcept + { return false; } + + constexpr atomic() noexcept = default; + + atomic(weak_ptr<_Tp> __r) noexcept + : _M_impl(move(__r)) + { } + + atomic(const atomic&) = delete; + void operator=(const atomic&) = delete; + + weak_ptr<_Tp> + load(memory_order __o = memory_order_seq_cst) const noexcept + { return _M_impl.load(__o); } + + operator weak_ptr<_Tp>() const noexcept + { return _M_impl.load(memory_order_seq_cst); } + + void + store(weak_ptr<_Tp> __desired, + memory_order __o = memory_order_seq_cst) noexcept + { _M_impl.swap(__desired, __o); } + + void + operator=(weak_ptr<_Tp> __desired) noexcept + { _M_impl.swap(__desired, memory_order_seq_cst); } + + weak_ptr<_Tp> + exchange(weak_ptr<_Tp> __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + _M_impl.swap(__desired, __o); + return __desired; + } + + bool + compare_exchange_strong(weak_ptr<_Tp>& __expected, + weak_ptr<_Tp> __desired, + memory_order __o, memory_order __o2) noexcept + { + return _M_impl.compare_exchange_strong(__expected, __desired, __o, __o2); + } + + bool + compare_exchange_strong(value_type& __expected, value_type __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + memory_order __o2; + switch (__o) + { + case memory_order_acq_rel: + __o2 = memory_order_acquire; + break; + case memory_order_release: + __o2 = memory_order_relaxed; + break; + default: + __o2 = __o; + } + return compare_exchange_strong(__expected, std::move(__desired), + __o, __o2); + } + + bool + compare_exchange_weak(value_type& __expected, value_type __desired, + memory_order __o, memory_order __o2) noexcept + { + return compare_exchange_strong(__expected, std::move(__desired), + __o, __o2); + } + + bool + compare_exchange_weak(value_type& __expected, value_type __desired, + memory_order __o = memory_order_seq_cst) noexcept + { + return compare_exchange_strong(__expected, std::move(__desired), __o); + } + +#if __cpp_lib_atomic_wait + void + wait(value_type __old, + memory_order __o = memory_order_seq_cst) const noexcept + { + _M_impl.wait(std::move(__old), __o); + } + + void + notify_one() noexcept + { + _M_impl.notify_one(); + } + + void + notify_all() noexcept + { + _M_impl.notify_all(); + } +#endif + + private: + _Sp_atomic> _M_impl; + }; +#endif // C++20 + + /// @} relates shared_ptr + /// @} group pointer_abstractions + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_ATOMIC_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7a18d0c4391ac31da4a1c86c0e744d55c36e967e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_atomic.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h new file mode 100644 index 0000000000000000000000000000000000000000..d9230b7220339d69d5cacda5a9114a72cf0c30fc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h @@ -0,0 +1,2260 @@ +// shared_ptr and weak_ptr implementation details -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// GCC Note: Based on files from version 1.32.0 of the Boost library. + +// shared_count.hpp +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. + +// shared_ptr.hpp +// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// weak_ptr.hpp +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// enable_shared_from_this.hpp +// Copyright (C) 2002 Peter Dimov + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** @file bits/shared_ptr_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_BASE_H +#define _SHARED_PTR_BASE_H 1 + +#include +#include +#include +#include +#include +#include +#include // std::less +#include +#include +#include +#include +#if __cplusplus >= 202002L +# include // __bit_floor +# include +# include // std::align +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template class auto_ptr; +#pragma GCC diagnostic pop +#endif + + /** + * @brief Exception possibly thrown by @c shared_ptr. + * @ingroup exceptions + */ + class bad_weak_ptr : public std::exception + { + public: + virtual char const* what() const noexcept; + + virtual ~bad_weak_ptr() noexcept; + }; + + // Substitute for bad_weak_ptr object in the case of -fno-exceptions. + inline void + __throw_bad_weak_ptr() + { _GLIBCXX_THROW_OR_ABORT(bad_weak_ptr()); } + + using __gnu_cxx::_Lock_policy; + using __gnu_cxx::__default_lock_policy; + using __gnu_cxx::_S_single; + using __gnu_cxx::_S_mutex; + using __gnu_cxx::_S_atomic; + + // Empty helper class except when the template argument is _S_mutex. + template<_Lock_policy _Lp> + class _Mutex_base + { + protected: + // The atomic policy uses fully-fenced builtins, single doesn't care. + enum { _S_need_barriers = 0 }; + }; + + template<> + class _Mutex_base<_S_mutex> + : public __gnu_cxx::__mutex + { + protected: + // This policy is used when atomic builtins are not available. + // The replacement atomic operations might not have the necessary + // memory barriers. + enum { _S_need_barriers = 1 }; + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class _Sp_counted_base + : public _Mutex_base<_Lp> + { + public: + _Sp_counted_base() noexcept + : _M_use_count(1), _M_weak_count(1) { } + + virtual + ~_Sp_counted_base() noexcept + { } + + // Called when _M_use_count drops to zero, to release the resources + // managed by *this. + virtual void + _M_dispose() noexcept = 0; + + // Called when _M_weak_count drops to zero. + virtual void + _M_destroy() noexcept + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) noexcept = 0; + + // Increment the use count (used when the count is greater than zero). + void + _M_add_ref_copy() + { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } + + // Increment the use count if it is non-zero, throw otherwise. + void + _M_add_ref_lock() + { + if (!_M_add_ref_lock_nothrow()) + __throw_bad_weak_ptr(); + } + + // Increment the use count if it is non-zero. + bool + _M_add_ref_lock_nothrow() noexcept; + + // Decrement the use count. + void + _M_release() noexcept; + + // Called by _M_release() when the use count reaches zero. + void + _M_release_last_use() noexcept + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); + _M_dispose(); + // There must be a memory barrier between dispose() and destroy() + // to ensure that the effects of dispose() are observed in the + // thread that runs destroy(). + // See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html + if (_Mutex_base<_Lp>::_S_need_barriers) + { + __atomic_thread_fence (__ATOMIC_ACQ_REL); + } + + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, + -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + _M_destroy(); + } + } + + // As above, but 'noinline' to reduce code size on the cold path. + __attribute__((__noinline__)) + void + _M_release_last_use_cold() noexcept + { _M_release_last_use(); } + + // Increment the weak count. + void + _M_weak_add_ref() noexcept + { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } + + // Decrement the weak count. + void + _M_weak_release() noexcept + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + if (_Mutex_base<_Lp>::_S_need_barriers) + { + // See _M_release(), + // destroy() must observe results of dispose() + __atomic_thread_fence (__ATOMIC_ACQ_REL); + } + _M_destroy(); + } + } + + long + _M_get_use_count() const noexcept + { + // No memory barrier is used here so there is no synchronization + // with other threads. + return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED); + } + + private: + _Sp_counted_base(_Sp_counted_base const&) = delete; + _Sp_counted_base& operator=(_Sp_counted_base const&) = delete; + + _Atomic_word _M_use_count; // #shared + _Atomic_word _M_weak_count; // #weak + (#shared != 0) + }; + + template<> + inline bool + _Sp_counted_base<_S_single>:: + _M_add_ref_lock_nothrow() noexcept + { + if (_M_use_count == 0) + return false; + ++_M_use_count; + return true; + } + + template<> + inline bool + _Sp_counted_base<_S_mutex>:: + _M_add_ref_lock_nothrow() noexcept + { + __gnu_cxx::__scoped_lock sentry(*this); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + return false; + } + return true; + } + + template<> + inline bool + _Sp_counted_base<_S_atomic>:: + _M_add_ref_lock_nothrow() noexcept + { + // Perform lock-free add-if-not-zero operation. + _Atomic_word __count = _M_get_use_count(); + do + { + if (__count == 0) + return false; + // Replace the current counter value with the old value + 1, as + // long as it's not changed meanwhile. + } + while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, + true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED)); + return true; + } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_add_ref_copy() + { ++_M_use_count; } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_release() noexcept + { + if (--_M_use_count == 0) + { + _M_dispose(); + if (--_M_weak_count == 0) + _M_destroy(); + } + } + + template<> + inline void + _Sp_counted_base<_S_mutex>::_M_release() noexcept + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + { + _M_release_last_use(); + } + } + + template<> + inline void + _Sp_counted_base<_S_atomic>::_M_release() noexcept + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); +#if ! _GLIBCXX_TSAN + constexpr bool __lock_free + = __atomic_always_lock_free(sizeof(long long), 0) + && __atomic_always_lock_free(sizeof(_Atomic_word), 0); + constexpr bool __double_word + = sizeof(long long) == 2 * sizeof(_Atomic_word); + // The ref-count members follow the vptr, so are aligned to + // alignof(void*). + constexpr bool __aligned = __alignof(long long) <= alignof(void*); + if _GLIBCXX17_CONSTEXPR (__lock_free && __double_word && __aligned) + { + constexpr int __wordbits = __CHAR_BIT__ * sizeof(_Atomic_word); + constexpr int __shiftbits = __double_word ? __wordbits : 0; + constexpr long long __unique_ref = 1LL + (1LL << __shiftbits); + auto __both_counts = reinterpret_cast(&_M_use_count); + + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__atomic_load_n(__both_counts, __ATOMIC_ACQUIRE) == __unique_ref) + { + // Both counts are 1, so there are no weak references and + // we are releasing the last strong reference. No other + // threads can observe the effects of this _M_release() + // call (e.g. calling use_count()) without a data race. + _M_weak_count = _M_use_count = 0; + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + _M_dispose(); + _M_destroy(); + return; + } + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + [[__unlikely__]] + { + _M_release_last_use_cold(); + return; + } + } + else +#endif + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + { + _M_release_last_use(); + } + } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept + { ++_M_weak_count; } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_weak_release() noexcept + { + if (--_M_weak_count == 0) + _M_destroy(); + } + + template<> + inline long + _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept + { return _M_use_count; } + + + // Forward declarations. + template + class __shared_ptr; + + template + class __weak_ptr; + + template + class __enable_shared_from_this; + + template + class shared_ptr; + + template + class weak_ptr; + + template + struct owner_less; + + template + class enable_shared_from_this; + + template<_Lock_policy _Lp = __default_lock_policy> + class __weak_count; + + template<_Lock_policy _Lp = __default_lock_policy> + class __shared_count; + +#if __cplusplus >= 202002L + template + class _Sp_atomic; +#endif + + // Counted ptr with no deleter or allocator support + template + class _Sp_counted_ptr final : public _Sp_counted_base<_Lp> + { + public: + explicit + _Sp_counted_ptr(_Ptr __p) noexcept + : _M_ptr(__p) { } + + virtual void + _M_dispose() noexcept + { delete _M_ptr; } + + virtual void + _M_destroy() noexcept + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) noexcept + { return nullptr; } + + _Sp_counted_ptr(const _Sp_counted_ptr&) = delete; + _Sp_counted_ptr& operator=(const _Sp_counted_ptr&) = delete; + + private: + _Ptr _M_ptr; + }; + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + // FIXME: once __has_cpp_attribute(__no_unique_address__)) is true for + // all supported compilers we can greatly simplify _Sp_ebo_helper. + // N.B. unconditionally applying the attribute could change layout for + // final types, which currently cannot use EBO so have a unique address. + + template + struct _Sp_ebo_helper; + + /// Specialization using EBO. + template + struct _Sp_ebo_helper<_Nm, _Tp, true> : private _Tp + { + explicit _Sp_ebo_helper(const _Tp& __tp) : _Tp(__tp) { } + explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { } + + static _Tp& + _S_get(_Sp_ebo_helper& __eboh) { return static_cast<_Tp&>(__eboh); } + }; + + /// Specialization not using EBO. + template + struct _Sp_ebo_helper<_Nm, _Tp, false> + { + explicit _Sp_ebo_helper(const _Tp& __tp) : _M_tp(__tp) { } + explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { } + + static _Tp& + _S_get(_Sp_ebo_helper& __eboh) + { return __eboh._M_tp; } + + private: + _Tp _M_tp; + }; + + // Support for custom deleter and/or allocator + template + class _Sp_counted_deleter final : public _Sp_counted_base<_Lp> + { + class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc> + { + typedef _Sp_ebo_helper<0, _Deleter> _Del_base; + typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base; + + public: + _Impl(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept + : _Del_base(std::move(__d)), _Alloc_base(__a), _M_ptr(__p) + { } + + _Deleter& _M_del() noexcept { return _Del_base::_S_get(*this); } + _Alloc& _M_alloc() noexcept { return _Alloc_base::_S_get(*this); } + + _Ptr _M_ptr; + }; + + public: + using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>; + + // __d(__p) must not throw. + _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept + : _M_impl(__p, std::move(__d), _Alloc()) { } + + // __d(__p) must not throw. + _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept + : _M_impl(__p, std::move(__d), __a) { } + + ~_Sp_counted_deleter() noexcept { } + + virtual void + _M_dispose() noexcept + { _M_impl._M_del()(_M_impl._M_ptr); } + + virtual void + _M_destroy() noexcept + { + __allocator_type __a(_M_impl._M_alloc()); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; + this->~_Sp_counted_deleter(); + } + + virtual void* + _M_get_deleter(const type_info& __ti [[__gnu__::__unused__]]) noexcept + { +#if __cpp_rtti + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2400. shared_ptr's get_deleter() should use addressof() + return __ti == typeid(_Deleter) + ? std::__addressof(_M_impl._M_del()) + : nullptr; +#else + return nullptr; +#endif + } + + private: + _Impl _M_impl; + }; + + // helpers for make_shared / allocate_shared + + struct _Sp_make_shared_tag + { + private: + template + friend class _Sp_counted_ptr_inplace; + + static const type_info& + _S_ti() noexcept _GLIBCXX_VISIBILITY(default) + { + alignas(type_info) static constexpr char __tag[sizeof(type_info)] = { }; + return reinterpret_cast(__tag); + } + + static bool _S_eq(const type_info&) noexcept; + }; + + template + struct _Sp_alloc_shared_tag + { + const _Alloc& _M_a; + }; + + template + class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> + { + class _Impl : _Sp_ebo_helper<0, _Alloc> + { + typedef _Sp_ebo_helper<0, _Alloc> _A_base; + + public: + explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { } + + _Alloc& _M_alloc() noexcept { return _A_base::_S_get(*this); } + + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + }; + + public: + using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>; + + // Alloc parameter is not a reference so doesn't alias anything in __args + template + _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args) + : _M_impl(__a) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2070. allocate_shared should use allocator_traits::construct + allocator_traits<_Alloc>::construct(__a, _M_ptr(), + std::forward<_Args>(__args)...); // might throw + } + + ~_Sp_counted_ptr_inplace() noexcept { } + + virtual void + _M_dispose() noexcept + { + allocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr()); + } + + // Override because the allocator needs to know the dynamic type + virtual void + _M_destroy() noexcept + { + __allocator_type __a(_M_impl._M_alloc()); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; + this->~_Sp_counted_ptr_inplace(); + } + + private: + friend class __shared_count<_Lp>; // To be able to call _M_ptr(). + + // No longer used, but code compiled against old libstdc++ headers + // might still call it from __shared_ptr ctor to get the pointer out. + virtual void* + _M_get_deleter(const std::type_info& __ti) noexcept override + { + auto __ptr = const_cast::type*>(_M_ptr()); + // Check for the fake type_info first, so we don't try to access it + // as a real type_info object. Otherwise, check if it's the real + // type_info for this class. With RTTI enabled we can check directly, + // or call a library function to do it. + if (&__ti == &_Sp_make_shared_tag::_S_ti() + || +#if __cpp_rtti + __ti == typeid(_Sp_make_shared_tag) +#else + _Sp_make_shared_tag::_S_eq(__ti) +#endif + ) + return __ptr; + return nullptr; + } + + _Tp* _M_ptr() noexcept { return _M_impl._M_storage._M_ptr(); } + + _Impl _M_impl; + }; + +#if __cplusplus >= 202002L +# define __cpp_lib_smart_ptr_for_overwrite 202002L + struct _Sp_overwrite_tag { }; + + // Partial specialization used for make_shared_for_overwrite(). + // This partial specialization is used when the allocator's value type + // is the special _Sp_overwrite_tag type. +#if __cpp_concepts + template + requires is_same_v + class _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> final +#else + template class _Alloc, _Lock_policy _Lp> + class _Sp_counted_ptr_inplace<_Tp, _Alloc<_Sp_overwrite_tag>, _Lp> final +#endif + : public _Sp_counted_base<_Lp> + { + [[no_unique_address]] _Alloc _M_alloc; + + union { + _Tp _M_obj; + char _M_unused; + }; + + friend class __shared_count<_Lp>; // To be able to call _M_ptr(). + + _Tp* _M_ptr() noexcept { return std::__addressof(_M_obj); } + + public: + using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>; + + _Sp_counted_ptr_inplace(const _Alloc& __a) + : _M_alloc(__a) + { + ::new((void*)_M_ptr()) _Tp; // default-initialized, for overwrite. + } + + ~_Sp_counted_ptr_inplace() noexcept { } + + virtual void + _M_dispose() noexcept + { + _M_obj.~_Tp(); + } + + // Override because the allocator needs to know the dynamic type + virtual void + _M_destroy() noexcept + { + using pointer = typename allocator_traits<__allocator_type>::pointer; + __allocator_type __a(_M_alloc); + auto __p = pointer_traits::pointer_to(*this); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, __p }; + this->~_Sp_counted_ptr_inplace(); + } + + void* + _M_get_deleter(const std::type_info&) noexcept override + { return nullptr; } + }; +#endif // C++20 + +#if __cplusplus <= 201703L +# define __cpp_lib_shared_ptr_arrays 201611L +#else +# define __cpp_lib_shared_ptr_arrays 201707L + + struct _Sp_overwrite_tag; + + // For make_shared, make_shared, allocate_shared etc. + template + struct _Sp_counted_array_base + { + [[no_unique_address]] _Alloc _M_alloc{}; + size_t _M_n = 0; + bool _M_overwrite = false; + + typename allocator_traits<_Alloc>::pointer + _M_alloc_array(size_t __tail) + { + return allocator_traits<_Alloc>::allocate(_M_alloc, _M_n + __tail); + } + + void + _M_dealloc_array(typename allocator_traits<_Alloc>::pointer __p, + size_t __tail) + { + allocator_traits<_Alloc>::deallocate(_M_alloc, __p, _M_n + __tail); + } + + // Init the array elements + template + void + _M_init(typename allocator_traits<_Alloc>::value_type* __p, + _Init __init) + { + using _Tp = remove_pointer_t<_Init>; + using _Up = typename allocator_traits<_Alloc>::value_type; + + if constexpr (is_same_v<_Init, _Sp_overwrite_tag>) + { + std::uninitialized_default_construct_n(__p, _M_n); + _M_overwrite = true; + } + else if (__init == nullptr) + std::__uninitialized_default_n_a(__p, _M_n, _M_alloc); + else if constexpr (!is_array_v<_Tp>) + std::__uninitialized_fill_n_a(__p, _M_n, *__init, _M_alloc); + else + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" + struct _Iter + { + using value_type = _Up; + using difference_type = ptrdiff_t; + using pointer = const _Up*; + using reference = const _Up&; + using iterator_category = forward_iterator_tag; + + const _Up* _M_p; + size_t _M_len; + size_t _M_pos; + + _Iter& operator++() { ++_M_pos; return *this; } + _Iter operator++(int) { auto __i(*this); ++_M_pos; return __i; } + + reference operator*() const { return _M_p[_M_pos % _M_len]; } + pointer operator->() const { return _M_p + (_M_pos % _M_len); } + + bool operator==(const _Iter& __i) const + { return _M_pos == __i._M_pos; } + }; +#pragma GCC diagnostic pop + + _Iter __first{_S_first_elem(__init), sizeof(_Tp) / sizeof(_Up)}; + _Iter __last = __first; + __last._M_pos = _M_n; + std::__uninitialized_copy_a(__first, __last, __p, _M_alloc); + } + } + + protected: + // Destroy the array elements + void + _M_dispose_array(typename allocator_traits<_Alloc>::value_type* __p) + { + if (_M_overwrite) + std::destroy_n(__p, _M_n); + else + { + size_t __n = _M_n; + while (__n--) + allocator_traits<_Alloc>::destroy(_M_alloc, __p + __n); + } + } + + private: + template + static _Tp* + _S_first_elem(_Tp* __p) { return __p; } + + template + static auto + _S_first_elem(_Tp (*__p)[_Nm]) { return _S_first_elem(*__p); } + }; + + // Control block for make_shared, make_shared etc. that will be + // placed into unused memory at the end of the array. + template + class _Sp_counted_array final + : public _Sp_counted_base<_Lp>, _Sp_counted_array_base<_Alloc> + { + using pointer = typename allocator_traits<_Alloc>::pointer; + + pointer _M_alloc_ptr; + + auto _M_ptr() const noexcept { return std::to_address(_M_alloc_ptr); } + + friend class __shared_count<_Lp>; // To be able to call _M_ptr(). + + public: + _Sp_counted_array(const _Sp_counted_array_base<_Alloc>& __a, + pointer __p) noexcept + : _Sp_counted_array_base<_Alloc>(__a), _M_alloc_ptr(__p) + { } + + ~_Sp_counted_array() = default; + + virtual void + _M_dispose() noexcept + { + if (this->_M_n) + this->_M_dispose_array(_M_ptr()); + } + + // Override because the allocator needs to know the dynamic type + virtual void + _M_destroy() noexcept + { + _Sp_counted_array_base<_Alloc> __a = *this; + pointer __p = _M_alloc_ptr; + this->~_Sp_counted_array(); + __a._M_dealloc_array(__p, _S_tail()); + } + + // Returns the number of additional array elements that must be + // allocated in order to store a _Sp_counted_array at the end. + static constexpr size_t + _S_tail() + { + // The array elemenent type. + using _Tp = typename allocator_traits<_Alloc>::value_type; + + // The space needed to store a _Sp_counted_array object. + size_t __bytes = sizeof(_Sp_counted_array); + + // Add any padding needed for manual alignment within the buffer. + if constexpr (alignof(_Tp) < alignof(_Sp_counted_array)) + __bytes += alignof(_Sp_counted_array) - alignof(_Tp); + + return (__bytes + sizeof(_Tp) - 1) / sizeof(_Tp); + } + + void* + _M_get_deleter(const std::type_info&) noexcept override + { return nullptr; } + }; +#endif // C++20 + + // The default deleter for shared_ptr and shared_ptr. + struct __sp_array_delete + { + template + void operator()(_Yp* __p) const { delete[] __p; } + }; + + template<_Lock_policy _Lp> + class __shared_count + { + // Prevent _Sp_alloc_shared_tag from matching the shared_ptr(P, D) ctor. + template + struct __not_alloc_shared_tag { using type = void; }; + + template + struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { }; + +#if __cpp_lib_shared_ptr_arrays >= 201707L + template + struct __not_alloc_shared_tag<_Sp_counted_array_base<_Alloc>> { }; +#endif + + public: + constexpr __shared_count() noexcept : _M_pi(0) + { } + + template + explicit + __shared_count(_Ptr __p) : _M_pi(0) + { + __try + { + _M_pi = new _Sp_counted_ptr<_Ptr, _Lp>(__p); + } + __catch(...) + { + delete __p; + __throw_exception_again; + } + } + + template + __shared_count(_Ptr __p, /* is_array = */ false_type) + : __shared_count(__p) + { } + + template + __shared_count(_Ptr __p, /* is_array = */ true_type) + : __shared_count(__p, __sp_array_delete{}, allocator()) + { } + + template::type> + __shared_count(_Ptr __p, _Deleter __d) + : __shared_count(__p, std::move(__d), allocator()) + { } + + template::type> + __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0) + { + typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type; + __try + { + typename _Sp_cd_type::__allocator_type __a2(__a); + auto __guard = std::__allocate_guarded(__a2); + _Sp_cd_type* __mem = __guard.get(); + ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a)); + _M_pi = __mem; + __guard = nullptr; + } + __catch(...) + { + __d(__p); // Call _Deleter on __p. + __throw_exception_again; + } + } + + template + __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a, + _Args&&... __args) + { + typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type; + typename _Sp_cp_type::__allocator_type __a2(__a._M_a); + auto __guard = std::__allocate_guarded(__a2); + _Sp_cp_type* __mem = __guard.get(); + auto __pi = ::new (__mem) + _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...); + __guard = nullptr; + _M_pi = __pi; + __p = __pi->_M_ptr(); + } + +#if __cpp_lib_shared_ptr_arrays >= 201707L + template + __shared_count(_Tp*& __p, const _Sp_counted_array_base<_Alloc>& __a, + _Init __init) + { + using _Up = remove_all_extents_t<_Tp>; + static_assert(is_same_v<_Up, typename _Alloc::value_type>); + + using _Sp_ca_type = _Sp_counted_array<_Alloc, _Lp>; + const size_t __tail = _Sp_ca_type::_S_tail(); + + struct _Guarded_ptr : _Sp_counted_array_base<_Alloc> + { + typename allocator_traits<_Alloc>::pointer _M_ptr; + + _Guarded_ptr(_Sp_counted_array_base<_Alloc> __a) + : _Sp_counted_array_base<_Alloc>(__a), + _M_ptr(this->_M_alloc_array(_Sp_ca_type::_S_tail())) + { } + + ~_Guarded_ptr() + { + if (_M_ptr) + this->_M_dealloc_array(_M_ptr, _Sp_ca_type::_S_tail()); + } + }; + + _Guarded_ptr __guard{__a}; + _Up* const __raw = std::to_address(__guard._M_ptr); + __guard._M_init(__raw, __init); // might throw + + void* __c = __raw + __a._M_n; + if constexpr (alignof(_Up) < alignof(_Sp_ca_type)) + { + size_t __space = sizeof(_Up) * __tail; + __c = std::align(alignof(_Sp_ca_type), sizeof(_Sp_ca_type), + __c, __space); + } + auto __pi = ::new(__c) _Sp_ca_type(__guard, __guard._M_ptr); + __guard._M_ptr = nullptr; + _M_pi = __pi; + __p = reinterpret_cast<_Tp*>(__raw); + } +#endif + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // Special case for auto_ptr<_Tp> to provide the strong guarantee. + template + explicit + __shared_count(std::auto_ptr<_Tp>&& __r); +#pragma GCC diagnostic pop +#endif + + // Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee. + template + explicit + __shared_count(std::unique_ptr<_Tp, _Del>&& __r) : _M_pi(0) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2415. Inconsistency between unique_ptr and shared_ptr + if (__r.get() == nullptr) + return; + + using _Ptr = typename unique_ptr<_Tp, _Del>::pointer; + using _Del2 = __conditional_t::value, + reference_wrapper::type>, + _Del>; + using _Sp_cd_type + = _Sp_counted_deleter<_Ptr, _Del2, allocator, _Lp>; + using _Alloc = allocator<_Sp_cd_type>; + using _Alloc_traits = allocator_traits<_Alloc>; + _Alloc __a; + _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3548. shared_ptr construction from unique_ptr should move + // (not copy) the deleter + _Alloc_traits::construct(__a, __mem, __r.release(), + std::forward<_Del>(__r.get_deleter())); + _M_pi = __mem; + } + + // Throw bad_weak_ptr when __r._M_get_use_count() == 0. + explicit __shared_count(const __weak_count<_Lp>& __r); + + // Does not throw if __r._M_get_use_count() == 0, caller must check. + explicit + __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t) noexcept; + + ~__shared_count() noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_release(); + } + + __shared_count(const __shared_count& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_add_ref_copy(); + } + + __shared_count& + operator=(const __shared_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != _M_pi) + { + if (__tmp != nullptr) + __tmp->_M_add_ref_copy(); + if (_M_pi != nullptr) + _M_pi->_M_release(); + _M_pi = __tmp; + } + return *this; + } + + void + _M_swap(__shared_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const noexcept + { return _M_pi ? _M_pi->_M_get_use_count() : 0; } + + bool + _M_unique() const noexcept + { return this->_M_get_use_count() == 1; } + + void* + _M_get_deleter(const std::type_info& __ti) const noexcept + { return _M_pi ? _M_pi->_M_get_deleter(__ti) : nullptr; } + + bool + _M_less(const __shared_count& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + bool + _M_less(const __weak_count<_Lp>& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + // Friend function injected into enclosing namespace and found by ADL + friend inline bool + operator==(const __shared_count& __a, const __shared_count& __b) noexcept + { return __a._M_pi == __b._M_pi; } + + private: + friend class __weak_count<_Lp>; +#if __cplusplus >= 202002L + template friend class _Sp_atomic; +#endif + + _Sp_counted_base<_Lp>* _M_pi; + }; + + + template<_Lock_policy _Lp> + class __weak_count + { + public: + constexpr __weak_count() noexcept : _M_pi(nullptr) + { } + + __weak_count(const __shared_count<_Lp>& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_weak_add_ref(); + } + + __weak_count(const __weak_count& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_weak_add_ref(); + } + + __weak_count(__weak_count&& __r) noexcept + : _M_pi(__r._M_pi) + { __r._M_pi = nullptr; } + + ~__weak_count() noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + } + + __weak_count& + operator=(const __shared_count<_Lp>& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != nullptr) + __tmp->_M_weak_add_ref(); + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + __weak_count& + operator=(const __weak_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != nullptr) + __tmp->_M_weak_add_ref(); + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + __weak_count& + operator=(__weak_count&& __r) noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __r._M_pi; + __r._M_pi = nullptr; + return *this; + } + + void + _M_swap(__weak_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const noexcept + { return _M_pi != nullptr ? _M_pi->_M_get_use_count() : 0; } + + bool + _M_less(const __weak_count& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + bool + _M_less(const __shared_count<_Lp>& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + // Friend function injected into enclosing namespace and found by ADL + friend inline bool + operator==(const __weak_count& __a, const __weak_count& __b) noexcept + { return __a._M_pi == __b._M_pi; } + + private: + friend class __shared_count<_Lp>; +#if __cplusplus >= 202002L + template friend class _Sp_atomic; +#endif + + _Sp_counted_base<_Lp>* _M_pi; + }; + + // Now that __weak_count is defined we can define this constructor: + template<_Lock_policy _Lp> + inline + __shared_count<_Lp>::__shared_count(const __weak_count<_Lp>& __r) + : _M_pi(__r._M_pi) + { + if (_M_pi == nullptr || !_M_pi->_M_add_ref_lock_nothrow()) + __throw_bad_weak_ptr(); + } + + // Now that __weak_count is defined we can define this constructor: + template<_Lock_policy _Lp> + inline + __shared_count<_Lp>:: + __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi && !_M_pi->_M_add_ref_lock_nothrow()) + _M_pi = nullptr; + } + + // Helper traits for shared_ptr of array: + + // A pointer type Y* is said to be compatible with a pointer type T* when + // either Y* is convertible to T* or Y is U[N] and T is U cv []. + template + struct __sp_compatible_with + : false_type + { }; + + template + struct __sp_compatible_with<_Yp*, _Tp*> + : is_convertible<_Yp*, _Tp*>::type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], const _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], volatile _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], const volatile _Up(*)[]> + : true_type + { }; + + // Test conversion from Y(*)[N] to U(*)[N] without forming invalid type Y[N]. + template + struct __sp_is_constructible_arrN + : false_type + { }; + + template + struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>> + : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type + { }; + + // Test conversion from Y(*)[] to U(*)[] without forming invalid type Y[]. + template + struct __sp_is_constructible_arr + : false_type + { }; + + template + struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>> + : is_convertible<_Yp(*)[], _Up(*)[]>::type + { }; + + // Trait to check if shared_ptr can be constructed from Y*. + template + struct __sp_is_constructible; + + // When T is U[N], Y(*)[N] shall be convertible to T*; + template + struct __sp_is_constructible<_Up[_Nm], _Yp> + : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type + { }; + + // when T is U[], Y(*)[] shall be convertible to T*; + template + struct __sp_is_constructible<_Up[], _Yp> + : __sp_is_constructible_arr<_Up, _Yp>::type + { }; + + // otherwise, Y* shall be convertible to T*. + template + struct __sp_is_constructible + : is_convertible<_Yp*, _Tp*>::type + { }; + + + // Define operator* and operator-> for shared_ptr. + template::value, bool = is_void<_Tp>::value> + class __shared_ptr_access + { + public: + using element_type = _Tp; + + element_type& + operator*() const noexcept + { + __glibcxx_assert(_M_get() != nullptr); + return *_M_get(); + } + + element_type* + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr); + return _M_get(); + } + + private: + element_type* + _M_get() const noexcept + { return static_cast*>(this)->get(); } + }; + + // Define operator-> for shared_ptr. + template + class __shared_ptr_access<_Tp, _Lp, false, true> + { + public: + using element_type = _Tp; + + element_type* + operator->() const noexcept + { + auto __ptr = static_cast*>(this)->get(); + _GLIBCXX_DEBUG_PEDASSERT(__ptr != nullptr); + return __ptr; + } + }; + + // Define operator[] for shared_ptr and shared_ptr. + template + class __shared_ptr_access<_Tp, _Lp, true, false> + { + public: + using element_type = typename remove_extent<_Tp>::type; + +#if __cplusplus <= 201402L + [[__deprecated__("shared_ptr::operator* is absent from C++17")]] + element_type& + operator*() const noexcept + { + __glibcxx_assert(_M_get() != nullptr); + return *_M_get(); + } + + [[__deprecated__("shared_ptr::operator-> is absent from C++17")]] + element_type* + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr); + return _M_get(); + } +#endif + + element_type& + operator[](ptrdiff_t __i) const noexcept + { + __glibcxx_assert(_M_get() != nullptr); + __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value); + return _M_get()[__i]; + } + + private: + element_type* + _M_get() const noexcept + { return static_cast*>(this)->get(); } + }; + + template + class __shared_ptr + : public __shared_ptr_access<_Tp, _Lp> + { + public: + using element_type = typename remove_extent<_Tp>::type; + + private: + // Constraint for taking ownership of a pointer of type _Yp*: + template + using _SafeConv + = typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type; + + // Constraint for construction from shared_ptr and weak_ptr: + template + using _Compatible = typename + enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; + + // Constraint for assignment from shared_ptr and weak_ptr: + template + using _Assignable = _Compatible<_Yp, __shared_ptr&>; + + // Constraint for construction from unique_ptr: + template::pointer> + using _UniqCompatible = __enable_if_t<__and_< + __sp_compatible_with<_Yp*, _Tp*>, + is_convertible<_Ptr, element_type*>, + is_move_constructible<_Del> + >::value, _Res>; + + // Constraint for assignment from unique_ptr: + template + using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>; + + public: + +#if __cplusplus > 201402L + using weak_type = __weak_ptr<_Tp, _Lp>; +#endif + + constexpr __shared_ptr() noexcept + : _M_ptr(0), _M_refcount() + { } + + template> + explicit + __shared_ptr(_Yp* __p) + : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type()) + { + static_assert( !is_void<_Yp>::value, "incomplete type" ); + static_assert( sizeof(_Yp) > 0, "incomplete type" ); + _M_enable_shared_from_this_with(__p); + } + + template> + __shared_ptr(_Yp* __p, _Deleter __d) + : _M_ptr(__p), _M_refcount(__p, std::move(__d)) + { + static_assert(__is_invocable<_Deleter&, _Yp*&>::value, + "deleter expression d(p) is well-formed"); + _M_enable_shared_from_this_with(__p); + } + + template> + __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) + : _M_ptr(__p), _M_refcount(__p, std::move(__d), std::move(__a)) + { + static_assert(__is_invocable<_Deleter&, _Yp*&>::value, + "deleter expression d(p) is well-formed"); + _M_enable_shared_from_this_with(__p); + } + + template + __shared_ptr(nullptr_t __p, _Deleter __d) + : _M_ptr(0), _M_refcount(__p, std::move(__d)) + { } + + template + __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) + : _M_ptr(0), _M_refcount(__p, std::move(__d), std::move(__a)) + { } + + // Aliasing constructor + template + __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r, + element_type* __p) noexcept + : _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws + { } + + // Aliasing constructor + template + __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r, + element_type* __p) noexcept + : _M_ptr(__p), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + __shared_ptr(const __shared_ptr&) noexcept = default; + __shared_ptr& operator=(const __shared_ptr&) noexcept = default; + ~__shared_ptr() = default; + + template> + __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) + { } + + __shared_ptr(__shared_ptr&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + template> + __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + template> + explicit __shared_ptr(const __weak_ptr<_Yp, _Lp>& __r) + : _M_refcount(__r._M_refcount) // may throw + { + // It is now safe to copy __r._M_ptr, as + // _M_refcount(__r._M_refcount) did not throw. + _M_ptr = __r._M_ptr; + } + + // If an exception is thrown this constructor has no effect. + template> + __shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : _M_ptr(__r.get()), _M_refcount() + { + auto __raw = __to_address(__r.get()); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__raw); + } + +#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED + protected: + // If an exception is thrown this constructor has no effect. + template>, is_array<_Tp1>, + is_convertible::pointer, _Tp*> + >::value, bool>::type = true> + __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete) + : _M_ptr(__r.get()), _M_refcount() + { + auto __raw = __to_address(__r.get()); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__raw); + } + public: +#endif + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // Postcondition: use_count() == 1 and __r.get() == 0 + template> + __shared_ptr(auto_ptr<_Yp>&& __r); +#pragma GCC diagnostic pop +#endif + + constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { } + + template + _Assignable<_Yp> + operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; // __shared_count::op= doesn't throw + return *this; + } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template + _Assignable<_Yp> + operator=(auto_ptr<_Yp>&& __r) + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } +#pragma GCC diagnostic pop +#endif + + __shared_ptr& + operator=(__shared_ptr&& __r) noexcept + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + template + _Assignable<_Yp> + operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + template + _UniqAssignable<_Yp, _Del> + operator=(unique_ptr<_Yp, _Del>&& __r) + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + void + reset() noexcept + { __shared_ptr().swap(*this); } + + template + _SafeConv<_Yp> + reset(_Yp* __p) // _Yp must be complete. + { + // Catch self-reset errors. + __glibcxx_assert(__p == nullptr || __p != _M_ptr); + __shared_ptr(__p).swap(*this); + } + + template + _SafeConv<_Yp> + reset(_Yp* __p, _Deleter __d) + { __shared_ptr(__p, std::move(__d)).swap(*this); } + + template + _SafeConv<_Yp> + reset(_Yp* __p, _Deleter __d, _Alloc __a) + { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*this); } + + /// Return the stored pointer. + element_type* + get() const noexcept + { return _M_ptr; } + + /// Return true if the stored pointer is not null. + explicit operator bool() const noexcept + { return _M_ptr != nullptr; } + + /// Return true if use_count() == 1. + bool + unique() const noexcept + { return _M_refcount._M_unique(); } + + /// If *this owns a pointer, return the number of owners, otherwise zero. + long + use_count() const noexcept + { return _M_refcount._M_get_use_count(); } + + /// Exchange both the owned pointer and the stored pointer. + void + swap(__shared_ptr<_Tp, _Lp>& __other) noexcept + { + std::swap(_M_ptr, __other._M_ptr); + _M_refcount._M_swap(__other._M_refcount); + } + + /** @brief Define an ordering based on ownership. + * + * This function defines a strict weak ordering between two shared_ptr + * or weak_ptr objects, such that one object is less than the other + * unless they share ownership of the same pointer, or are both empty. + * @{ + */ + template + bool + owner_before(__shared_ptr<_Tp1, _Lp> const& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + template + bool + owner_before(__weak_ptr<_Tp1, _Lp> const& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + /// @} + + protected: + // This constructor is non-standard, it is used by allocate_shared. + template + __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) + : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...) + { _M_enable_shared_from_this_with(_M_ptr); } + + template + friend __shared_ptr<_Tp1, _Lp1> + __allocate_shared(const _Alloc& __a, _Args&&... __args); + +#if __cpp_lib_shared_ptr_arrays >= 201707L + // This constructor is non-standard, it is used by allocate_shared. + template*> + __shared_ptr(const _Sp_counted_array_base<_Alloc>& __a, + _Init __init = nullptr) + : _M_ptr(), _M_refcount(_M_ptr, __a, __init) + { } +#endif + + // This constructor is used by __weak_ptr::lock() and + // shared_ptr::shared_ptr(const weak_ptr&, std::nothrow_t). + __shared_ptr(const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t) noexcept + : _M_refcount(__r._M_refcount, std::nothrow) + { + _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr : nullptr; + } + + friend class __weak_ptr<_Tp, _Lp>; + + private: + + template + using __esft_base_t = decltype(__enable_shared_from_this_base( + std::declval&>(), + std::declval<_Yp*>())); + + // Detect an accessible and unambiguous enable_shared_from_this base. + template + struct __has_esft_base + : false_type { }; + + template + struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>> + : __not_> { }; // No enable shared_from_this for arrays + + template::type> + typename enable_if<__has_esft_base<_Yp2>::value>::type + _M_enable_shared_from_this_with(_Yp* __p) noexcept + { + if (auto __base = __enable_shared_from_this_base(_M_refcount, __p)) + __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount); + } + + template::type> + typename enable_if::value>::type + _M_enable_shared_from_this_with(_Yp*) noexcept + { } + + void* + _M_get_deleter(const std::type_info& __ti) const noexcept + { return _M_refcount._M_get_deleter(__ti); } + + template friend class __shared_ptr; + template friend class __weak_ptr; + + template + friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept; + + template + friend _Del* get_deleter(const shared_ptr<_Tp1>&) noexcept; + +#if __cplusplus >= 202002L + friend _Sp_atomic>; +#endif + + element_type* _M_ptr; // Contained pointer. + __shared_count<_Lp> _M_refcount; // Reference counter. + }; + + + // 20.7.2.2.7 shared_ptr comparisons + template + inline bool + operator==(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return __a.get() == __b.get(); } + + template + inline bool + operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !__a; } + +#ifdef __cpp_lib_three_way_comparison + template + inline strong_ordering + operator<=>(const __shared_ptr<_Tp, _Lp>& __a, + const __shared_ptr<_Up, _Lp>& __b) noexcept + { return compare_three_way()(__a.get(), __b.get()); } + + template + inline strong_ordering + operator<=>(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { + using pointer = typename __shared_ptr<_Tp, _Lp>::element_type*; + return compare_three_way()(__a.get(), static_cast(nullptr)); + } +#else + template + inline bool + operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !__a; } + + template + inline bool + operator!=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return __a.get() != __b.get(); } + + template + inline bool + operator!=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return (bool)__a; } + + template + inline bool + operator!=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return (bool)__a; } + + template + inline bool + operator<(const __shared_ptr<_Tp, _Lp>& __a, + const __shared_ptr<_Up, _Lp>& __b) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + using _Up_elt = typename __shared_ptr<_Up, _Lp>::element_type; + using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; + return less<_Vp>()(__a.get(), __b.get()); + } + + template + inline bool + operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + return less<_Tp_elt*>()(__a.get(), nullptr); + } + + template + inline bool + operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + return less<_Tp_elt*>()(nullptr, __a.get()); + } + + template + inline bool + operator<=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return !(__b < __a); } + + template + inline bool + operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !(nullptr < __a); } + + template + inline bool + operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !(__a < nullptr); } + + template + inline bool + operator>(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return (__b < __a); } + + template + inline bool + operator>(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return nullptr < __a; } + + template + inline bool + operator>(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return __a < nullptr; } + + template + inline bool + operator>=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return !(__a < __b); } + + template + inline bool + operator>=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !(__a < nullptr); } + + template + inline bool + operator>=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !(nullptr < __a); } +#endif // three-way comparison + + // 20.7.2.2.8 shared_ptr specialized algorithms. + template + inline void + swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept + { __a.swap(__b); } + + // 20.7.2.2.9 shared_ptr casts + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// static_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, static_cast(__r.get())); + } + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(const_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// const_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, const_cast(__r.get())); + } + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(dynamic_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// dynamic_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(__r, __p); + return _Sp(); + } + +#if __cplusplus > 201402L + template + inline __shared_ptr<_Tp, _Lp> + reinterpret_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, reinterpret_cast(__r.get())); + } +#endif + + template + class __weak_ptr + { + template + using _Compatible = typename + enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; + + // Constraint for assignment from shared_ptr and weak_ptr: + template + using _Assignable = _Compatible<_Yp, __weak_ptr&>; + + public: + using element_type = typename remove_extent<_Tp>::type; + + constexpr __weak_ptr() noexcept + : _M_ptr(nullptr), _M_refcount() + { } + + __weak_ptr(const __weak_ptr&) noexcept = default; + + ~__weak_ptr() = default; + + // The "obvious" converting constructor implementation: + // + // template + // __weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) + // : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws + // { } + // + // has a serious problem. + // + // __r._M_ptr may already have been invalidated. The _M_ptr(__r._M_ptr) + // conversion may require access to *__r._M_ptr (virtual inheritance). + // + // It is not possible to avoid spurious access violations since + // in multithreaded programs __r._M_ptr may be invalidated at any point. + template> + __weak_ptr(const __weak_ptr<_Yp, _Lp>& __r) noexcept + : _M_refcount(__r._M_refcount) + { _M_ptr = __r.lock().get(); } + + template> + __weak_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) + { } + + __weak_ptr(__weak_ptr&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount)) + { __r._M_ptr = nullptr; } + + template> + __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept + : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount)) + { __r._M_ptr = nullptr; } + + __weak_ptr& + operator=(const __weak_ptr& __r) noexcept = default; + + template + _Assignable<_Yp> + operator=(const __weak_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r.lock().get(); + _M_refcount = __r._M_refcount; + return *this; + } + + template + _Assignable<_Yp> + operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; + return *this; + } + + __weak_ptr& + operator=(__weak_ptr&& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = std::move(__r._M_refcount); + __r._M_ptr = nullptr; + return *this; + } + + template + _Assignable<_Yp> + operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept + { + _M_ptr = __r.lock().get(); + _M_refcount = std::move(__r._M_refcount); + __r._M_ptr = nullptr; + return *this; + } + + __shared_ptr<_Tp, _Lp> + lock() const noexcept + { return __shared_ptr(*this, std::nothrow); } + + long + use_count() const noexcept + { return _M_refcount._M_get_use_count(); } + + bool + expired() const noexcept + { return _M_refcount._M_get_use_count() == 0; } + + template + bool + owner_before(const __shared_ptr<_Tp1, _Lp>& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + template + bool + owner_before(const __weak_ptr<_Tp1, _Lp>& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + void + reset() noexcept + { __weak_ptr().swap(*this); } + + void + swap(__weak_ptr& __s) noexcept + { + std::swap(_M_ptr, __s._M_ptr); + _M_refcount._M_swap(__s._M_refcount); + } + + private: + // Used by __enable_shared_from_this. + void + _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept + { + if (use_count() == 0) + { + _M_ptr = __ptr; + _M_refcount = __refcount; + } + } + + template friend class __shared_ptr; + template friend class __weak_ptr; + friend class __enable_shared_from_this<_Tp, _Lp>; + friend class enable_shared_from_this<_Tp>; +#if __cplusplus >= 202002L + friend _Sp_atomic>; +#endif + + element_type* _M_ptr; // Contained pointer. + __weak_count<_Lp> _M_refcount; // Reference counter. + }; + + // 20.7.2.3.6 weak_ptr specialized algorithms. + template + inline void + swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept + { __a.swap(__b); } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template + struct _Sp_owner_less : public binary_function<_Tp, _Tp, bool> + { + bool + operator()(const _Tp& __lhs, const _Tp& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + + bool + operator()(const _Tp& __lhs, const _Tp1& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + + bool + operator()(const _Tp1& __lhs, const _Tp& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + }; +#pragma GCC diagnostic pop + + template<> + struct _Sp_owner_less + { + template + auto + operator()(const _Tp& __lhs, const _Up& __rhs) const noexcept + -> decltype(__lhs.owner_before(__rhs)) + { return __lhs.owner_before(__rhs); } + + using is_transparent = void; + }; + + template + struct owner_less<__shared_ptr<_Tp, _Lp>> + : public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>> + { }; + + template + struct owner_less<__weak_ptr<_Tp, _Lp>> + : public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>> + { }; + + + template + class __enable_shared_from_this + { + protected: + constexpr __enable_shared_from_this() noexcept { } + + __enable_shared_from_this(const __enable_shared_from_this&) noexcept { } + + __enable_shared_from_this& + operator=(const __enable_shared_from_this&) noexcept + { return *this; } + + ~__enable_shared_from_this() { } + + public: + __shared_ptr<_Tp, _Lp> + shared_from_this() + { return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); } + + __shared_ptr + shared_from_this() const + { return __shared_ptr(this->_M_weak_this); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + __weak_ptr<_Tp, _Lp> + weak_from_this() noexcept + { return this->_M_weak_this; } + + __weak_ptr + weak_from_this() const noexcept + { return this->_M_weak_this; } +#endif + + private: + template + void + _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept + { _M_weak_this._M_assign(__p, __n); } + + friend const __enable_shared_from_this* + __enable_shared_from_this_base(const __shared_count<_Lp>&, + const __enable_shared_from_this* __p) + { return __p; } + + template + friend class __shared_ptr; + + mutable __weak_ptr<_Tp, _Lp> _M_weak_this; + }; + + template + inline __shared_ptr<_Tp, _Lp> + __allocate_shared(const _Alloc& __a, _Args&&... __args) + { + static_assert(!is_array<_Tp>::value, "make_shared not supported"); + + return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a}, + std::forward<_Args>(__args)...); + } + + template + inline __shared_ptr<_Tp, _Lp> + __make_shared(_Args&&... __args) + { + typedef typename std::remove_const<_Tp>::type _Tp_nc; + return std::__allocate_shared<_Tp, _Lp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); + } + + /// std::hash specialization for __shared_ptr. + template + struct hash<__shared_ptr<_Tp, _Lp>> + : public __hash_base> + { + size_t + operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept + { + return hash::element_type*>()( + __s.get()); + } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_BASE_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..639a88e17bdaa68d932406cb78284f6033e7af43 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@shared_ptr_base.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h new file mode 100644 index 0000000000000000000000000000000000000000..96fadea2cc75c70028a01b34c0347b37f8006696 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h @@ -0,0 +1,284 @@ +// The template and inlines for the -*- C++ -*- slice_array class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/slice_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _SLICE_ARRAY_H +#define _SLICE_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Class defining one-dimensional subset of an array. + * + * The slice class represents a one-dimensional subset of an array, + * specified by three parameters: start offset, size, and stride. The + * start offset is the index of the first element of the array that is part + * of the subset. The size is the total number of elements in the subset. + * Stride is the distance between each successive array element to include + * in the subset. + * + * For example, with an array of size 10, and a slice with offset 1, size 3 + * and stride 2, the subset consists of array elements 1, 3, and 5. + */ + class slice + { + public: + /// Construct an empty slice. + slice(); + + /** + * @brief Construct a slice. + * + * @param __o Offset in array of first element. + * @param __d Number of elements in slice. + * @param __s Stride between array elements. + */ + slice(size_t __o, size_t __d, size_t __s); + + /// Return array offset of first slice element. + size_t start() const; + /// Return size of slice. + size_t size() const; + /// Return array stride of slice. + size_t stride() const; + +#if __cpp_impl_three_way_comparison >= 201907L + /// Equality comparison + friend bool operator==(const slice&, const slice&) = default; +#endif + + private: + size_t _M_off; // offset + size_t _M_sz; // size + size_t _M_st; // stride unit + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 543. valarray slice default constructor + inline + slice::slice() + : _M_off(0), _M_sz(0), _M_st(0) {} + + inline + slice::slice(size_t __o, size_t __d, size_t __s) + : _M_off(__o), _M_sz(__d), _M_st(__s) {} + + inline size_t + slice::start() const + { return _M_off; } + + inline size_t + slice::size() const + { return _M_sz; } + + inline size_t + slice::stride() const + { return _M_st; } + + /** + * @brief Reference to one-dimensional subset of an array. + * + * A slice_array is a reference to the actual elements of an array + * specified by a slice. The way to get a slice_array is to call + * operator[](slice) on a valarray. The returned slice_array then permits + * carrying operations out on the referenced subset of elements in the + * original valarray. For example, operator+=(valarray) will add values + * to the subset of elements in the underlying valarray this slice_array + * refers to. + * + * @param Tp Element type. + */ + template + class slice_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + slice_array(const slice_array&); + + /// Assignment operator. Assigns slice elements to corresponding + /// elements of @a a. + slice_array& operator=(const slice_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp &) const; + // ~slice_array (); + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + friend class valarray<_Tp>; + slice_array(_Array<_Tp>, const slice&); + + const size_t _M_sz; + const size_t _M_stride; + const _Array<_Tp> _M_array; + +#if __cplusplus < 201103L + // not implemented + slice_array(); +#else + public: + slice_array() = delete; +#endif + }; + + template + inline + slice_array<_Tp>::slice_array(_Array<_Tp> __a, const slice& __s) + : _M_sz(__s.size()), _M_stride(__s.stride()), + _M_array(__a.begin() + __s.start()) {} + + template + inline + slice_array<_Tp>::slice_array(const slice_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_stride(__a._M_stride), _M_array(__a._M_array) {} + + // template + // inline slice_array<_Tp>::~slice_array () {} + + template + inline slice_array<_Tp>& + slice_array<_Tp>::operator=(const slice_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, __a._M_sz, __a._M_stride, + _M_array, _M_stride); + return *this; + } + + template + inline void + slice_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_sz, _M_stride, __t); } + + template + inline void + slice_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); } + + template + template + inline void + slice_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const + { std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \ + template \ + inline void \ + slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\ + } \ + \ + template \ + template \ + inline void \ + slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \ + } + + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _SLICE_ARRAY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..343214b0d1f75f49ab9a73b94622e6265cd5f109 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@slice_array.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc new file mode 100644 index 0000000000000000000000000000000000000000..054f537c4c2349a43ca90a46daa74184451fba5c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc @@ -0,0 +1,307 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/sstream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{sstream} + */ + +// +// ISO C++ 14882: 27.7 String-based streams +// + +#ifndef _SSTREAM_TCC +#define _SSTREAM_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + pbackfail(int_type __c) + { + int_type __ret = traits_type::eof(); + if (this->eback() < this->gptr()) + { + // Try to put back __c into input sequence in one of three ways. + // Order these tests done in is unspecified by the standard. + const bool __testeof = traits_type::eq_int_type(__c, __ret); + if (!__testeof) + { + const bool __testeq = traits_type::eq(traits_type:: + to_char_type(__c), + this->gptr()[-1]); + const bool __testout = this->_M_mode & ios_base::out; + if (__testeq || __testout) + { + this->gbump(-1); + if (!__testeq) + *this->gptr() = traits_type::to_char_type(__c); + __ret = __c; + } + } + else + { + this->gbump(-1); + __ret = traits_type::not_eof(__c); + } + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + overflow(int_type __c) + { + const bool __testout = this->_M_mode & ios_base::out; + if (__builtin_expect(!__testout, false)) + return traits_type::eof(); + + const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof()); + if (__builtin_expect(__testeof, false)) + return traits_type::not_eof(__c); + + const __size_type __capacity = _M_string.capacity(); + +#if _GLIBCXX_USE_CXX11_ABI + if (size_t(this->epptr() - this->pbase()) < __capacity) + { + // There is additional capacity in _M_string that can be used. + char_type* __base = const_cast(_M_string.data()); + _M_pbump(__base, __base + __capacity, this->pptr() - this->pbase()); + if (_M_mode & ios_base::in) + { + const __size_type __nget = this->gptr() - this->eback(); + const __size_type __eget = this->egptr() - this->eback(); + this->setg(__base, __base + __nget, __base + __eget + 1); + } + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + return __c; + } +#endif + + const __size_type __max_size = _M_string.max_size(); + const bool __testput = this->pptr() < this->epptr(); + if (__builtin_expect(!__testput && __capacity == __max_size, false)) + return traits_type::eof(); + + // Try to append __c into output sequence in one of two ways. + // Order these tests done in is unspecified by the standard. + const char_type __conv = traits_type::to_char_type(__c); + if (!__testput) + { + // NB: Start ostringstream buffers at 512 chars. This is an + // experimental value (pronounced "arbitrary" in some of the + // hipper English-speaking countries), and can be changed to + // suit particular needs. + // + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 169. Bad efficiency of overflow() mandated + // 432. stringbuf::overflow() makes only one write position + // available + const __size_type __opt_len = std::max(__size_type(2 * __capacity), + __size_type(512)); + const __size_type __len = std::min(__opt_len, __max_size); + __string_type __tmp(_M_string.get_allocator()); + __tmp.reserve(__len); + if (this->pbase()) + __tmp.assign(this->pbase(), this->epptr() - this->pbase()); + __tmp.push_back(__conv); + _M_string.swap(__tmp); + _M_sync(const_cast(_M_string.data()), + this->gptr() - this->eback(), this->pptr() - this->pbase()); + } + else + *this->pptr() = __conv; + this->pbump(1); + return __c; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + underflow() + { + int_type __ret = traits_type::eof(); + const bool __testin = this->_M_mode & ios_base::in; + if (__testin) + { + // Update egptr() to match the actual string end. + _M_update_egptr(); + + if (this->gptr() < this->egptr()) + __ret = traits_type::to_int_type(*this->gptr()); + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode) + { + pos_type __ret = pos_type(off_type(-1)); + bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; + const bool __testboth = __testin && __testout && __way != ios_base::cur; + __testin &= !(__mode & ios_base::out); + __testout &= !(__mode & ios_base::in); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 453. basic_stringbuf::seekoff need not always fail for an empty stream. + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if ((__beg || !__off) && (__testin || __testout || __testboth)) + { + _M_update_egptr(); + + off_type __newoffi = __off; + off_type __newoffo = __newoffi; + if (__way == ios_base::cur) + { + __newoffi += this->gptr() - __beg; + __newoffo += this->pptr() - __beg; + } + else if (__way == ios_base::end) + __newoffo = __newoffi += this->egptr() - __beg; + + if ((__testin || __testboth) + && __newoffi >= 0 + && this->egptr() - __beg >= __newoffi) + { + this->setg(this->eback(), this->eback() + __newoffi, + this->egptr()); + __ret = pos_type(__newoffi); + } + if ((__testout || __testboth) + && __newoffo >= 0 + && this->egptr() - __beg >= __newoffo) + { + _M_pbump(this->pbase(), this->epptr(), __newoffo); + __ret = pos_type(__newoffo); + } + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + seekpos(pos_type __sp, ios_base::openmode __mode) + { + pos_type __ret = pos_type(off_type(-1)); + const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; + + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if ((__beg || !off_type(__sp)) && (__testin || __testout)) + { + _M_update_egptr(); + + const off_type __pos(__sp); + const bool __testpos = (0 <= __pos + && __pos <= this->egptr() - __beg); + if (__testpos) + { + if (__testin) + this->setg(this->eback(), this->eback() + __pos, + this->egptr()); + if (__testout) + _M_pbump(this->pbase(), this->epptr(), __pos); + __ret = __sp; + } + } + return __ret; + } + + template + void + basic_stringbuf<_CharT, _Traits, _Alloc>:: + _M_sync(char_type* __base, __size_type __i, __size_type __o) + { + const bool __testin = _M_mode & ios_base::in; + const bool __testout = _M_mode & ios_base::out; + char_type* __endg = __base + _M_string.size(); + char_type* __endp = __base + _M_string.capacity(); + + if (__base != _M_string.data()) + { + // setbuf: __i == size of buffer area (_M_string.size() == 0). + __endg += __i; + __i = 0; + __endp = __endg; + } + + if (__testin) + this->setg(__base, __base + __i, __endg); + if (__testout) + { + _M_pbump(__base, __endp, __o); + // egptr() always tracks the string end. When !__testin, + // for the correct functioning of the streambuf inlines + // the other get area pointers are identical. + if (!__testin) + this->setg(__endg, __endg, __endg); + } + } + + template + void + basic_stringbuf<_CharT, _Traits, _Alloc>:: + _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off) + { + this->setp(__pbeg, __pend); + while (__off > __gnu_cxx::__numeric_traits::__max) + { + this->pbump(__gnu_cxx::__numeric_traits::__max); + __off -= __gnu_cxx::__numeric_traits::__max; + } + this->pbump(__off); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_stringbuf; + extern template class basic_istringstream; + extern template class basic_ostringstream; + extern template class basic_stringstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_stringbuf; + extern template class basic_istringstream; + extern template class basic_ostringstream; + extern template class basic_stringstream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..e55215fe9caa7f4cc70713c4d7ef2388fd0040a1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@sstream.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h new file mode 100644 index 0000000000000000000000000000000000000000..c8d589d2b0a4a64320a732a58141f0687a8c7616 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h @@ -0,0 +1,111 @@ +// -*- C++ -*- C library enhancements header. + +// Copyright (C) 2016-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/std_abs.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cmath, cstdlib} + */ + +#ifndef _GLIBCXX_BITS_STD_ABS_H +#define _GLIBCXX_BITS_STD_ABS_H + +#pragma GCC system_header + +#include + +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#ifdef __CORRECT_ISO_CPP_MATH_H_PROTO +# include_next +#endif +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS + +#undef abs + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::abs; + +#ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO + inline long + abs(long __i) { return __builtin_labs(__i); } +#endif + +#ifdef _GLIBCXX_USE_LONG_LONG + inline long long + abs(long long __x) { return __builtin_llabs (__x); } +#endif + +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// 2192. Validity and return type of std::abs(0u) is unclear +// 2294. should declare abs(double) +// 2735. std::abs(short), std::abs(signed char) and others should return int + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR double + abs(double __x) + { return __builtin_fabs(__x); } + + inline _GLIBCXX_CONSTEXPR float + abs(float __x) + { return __builtin_fabsf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + abs(long double __x) + { return __builtin_fabsl(__x); } +#endif + +#if defined(__GLIBCXX_TYPE_INT_N_0) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0 + abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1 + abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2 + abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3 + abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; } +#endif + +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) + __extension__ inline _GLIBCXX_CONSTEXPR + __float128 + abs(__float128 __x) + { return __x < 0 ? -__x : __x; } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C"++" + +#endif // _GLIBCXX_BITS_STD_ABS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..cadd718db1d9df37ab4f346284cc5a752c21faae Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_abs.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h new file mode 100644 index 0000000000000000000000000000000000000000..96918a04a35d4ae3afd93efad466b526f5c8061b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h @@ -0,0 +1,778 @@ +// Implementation of std::function -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/std_function.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_STD_FUNCTION_H +#define _GLIBCXX_STD_FUNCTION_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Exception class thrown when class template function's + * operator() is called with an empty target. + * @ingroup exceptions + */ + class bad_function_call : public std::exception + { + public: + virtual ~bad_function_call() noexcept; + + const char* what() const noexcept; + }; + + /** + * Trait identifying "location-invariant" types, meaning that the + * address of the object (or any of its members) will not escape. + * Trivially copyable types are location-invariant and users can + * specialize this trait for other types. + */ + template + struct __is_location_invariant + : is_trivially_copyable<_Tp>::type + { }; + + class _Undefined_class; + + union _Nocopy_types + { + void* _M_object; + const void* _M_const_object; + void (*_M_function_pointer)(); + void (_Undefined_class::*_M_member_pointer)(); + }; + + union [[gnu::may_alias]] _Any_data + { + void* _M_access() noexcept { return &_M_pod_data[0]; } + const void* _M_access() const noexcept { return &_M_pod_data[0]; } + + template + _Tp& + _M_access() noexcept + { return *static_cast<_Tp*>(_M_access()); } + + template + const _Tp& + _M_access() const noexcept + { return *static_cast(_M_access()); } + + _Nocopy_types _M_unused; + char _M_pod_data[sizeof(_Nocopy_types)]; + }; + + enum _Manager_operation + { + __get_type_info, + __get_functor_ptr, + __clone_functor, + __destroy_functor + }; + + template + class function; + + /// Base class of all polymorphic function object wrappers. + class _Function_base + { + public: + static const size_t _M_max_size = sizeof(_Nocopy_types); + static const size_t _M_max_align = __alignof__(_Nocopy_types); + + template + class _Base_manager + { + protected: + static const bool __stored_locally = + (__is_location_invariant<_Functor>::value + && sizeof(_Functor) <= _M_max_size + && __alignof__(_Functor) <= _M_max_align + && (_M_max_align % __alignof__(_Functor) == 0)); + + using _Local_storage = integral_constant; + + // Retrieve a pointer to the function object + static _Functor* + _M_get_pointer(const _Any_data& __source) noexcept + { + if _GLIBCXX17_CONSTEXPR (__stored_locally) + { + const _Functor& __f = __source._M_access<_Functor>(); + return const_cast<_Functor*>(std::__addressof(__f)); + } + else // have stored a pointer + return __source._M_access<_Functor*>(); + } + + private: + // Construct a location-invariant function object that fits within + // an _Any_data structure. + template + static void + _M_create(_Any_data& __dest, _Fn&& __f, true_type) + { + ::new (__dest._M_access()) _Functor(std::forward<_Fn>(__f)); + } + + // Construct a function object on the heap and store a pointer. + template + static void + _M_create(_Any_data& __dest, _Fn&& __f, false_type) + { + __dest._M_access<_Functor*>() + = new _Functor(std::forward<_Fn>(__f)); + } + + // Destroy an object stored in the internal buffer. + static void + _M_destroy(_Any_data& __victim, true_type) + { + __victim._M_access<_Functor>().~_Functor(); + } + + // Destroy an object located on the heap. + static void + _M_destroy(_Any_data& __victim, false_type) + { + delete __victim._M_access<_Functor*>(); + } + + public: + static bool + _M_manager(_Any_data& __dest, const _Any_data& __source, + _Manager_operation __op) + { + switch (__op) + { + case __get_type_info: +#if __cpp_rtti + __dest._M_access() = &typeid(_Functor); +#else + __dest._M_access() = nullptr; +#endif + break; + + case __get_functor_ptr: + __dest._M_access<_Functor*>() = _M_get_pointer(__source); + break; + + case __clone_functor: + _M_init_functor(__dest, + *const_cast(_M_get_pointer(__source))); + break; + + case __destroy_functor: + _M_destroy(__dest, _Local_storage()); + break; + } + return false; + } + + template + static void + _M_init_functor(_Any_data& __functor, _Fn&& __f) + noexcept(__and_<_Local_storage, + is_nothrow_constructible<_Functor, _Fn>>::value) + { + _M_create(__functor, std::forward<_Fn>(__f), _Local_storage()); + } + + template + static bool + _M_not_empty_function(const function<_Signature>& __f) noexcept + { return static_cast(__f); } + + template + static bool + _M_not_empty_function(_Tp* __fp) noexcept + { return __fp != nullptr; } + + template + static bool + _M_not_empty_function(_Tp _Class::* __mp) noexcept + { return __mp != nullptr; } + + template + static bool + _M_not_empty_function(const _Tp&) noexcept + { return true; } + }; + + _Function_base() = default; + + ~_Function_base() + { + if (_M_manager) + _M_manager(_M_functor, _M_functor, __destroy_functor); + } + + bool _M_empty() const { return !_M_manager; } + + using _Manager_type + = bool (*)(_Any_data&, const _Any_data&, _Manager_operation); + + _Any_data _M_functor{}; + _Manager_type _M_manager{}; + }; + + template + class _Function_handler; + + template + class _Function_handler<_Res(_ArgTypes...), _Functor> + : public _Function_base::_Base_manager<_Functor> + { + using _Base = _Function_base::_Base_manager<_Functor>; + + public: + static bool + _M_manager(_Any_data& __dest, const _Any_data& __source, + _Manager_operation __op) + { + switch (__op) + { +#if __cpp_rtti + case __get_type_info: + __dest._M_access() = &typeid(_Functor); + break; +#endif + case __get_functor_ptr: + __dest._M_access<_Functor*>() = _Base::_M_get_pointer(__source); + break; + + default: + _Base::_M_manager(__dest, __source, __op); + } + return false; + } + + static _Res + _M_invoke(const _Any_data& __functor, _ArgTypes&&... __args) + { + return std::__invoke_r<_Res>(*_Base::_M_get_pointer(__functor), + std::forward<_ArgTypes>(__args)...); + } + + template + static constexpr bool + _S_nothrow_init() noexcept + { + return __and_>::value; + } + }; + + // Specialization for invalid types + template<> + class _Function_handler + { + public: + static bool + _M_manager(_Any_data&, const _Any_data&, _Manager_operation) + { return false; } + }; + + // Avoids instantiating ill-formed specializations of _Function_handler + // in std::function<_Signature>::target<_Functor>(). + // e.g. _Function_handler and _Function_handler + // would be ill-formed. + template::value> + struct _Target_handler + : _Function_handler<_Signature, typename remove_cv<_Functor>::type> + { }; + + template + struct _Target_handler<_Signature, _Functor, false> + : _Function_handler + { }; + + /** + * @brief Polymorphic function wrapper. + * @ingroup functors + * @since C++11 + */ + template + class function<_Res(_ArgTypes...)> + : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>, + private _Function_base + { + // Equivalent to std::decay_t except that it produces an invalid type + // if the decayed type is the current specialization of std::function. + template, function>::value> + using _Decay_t + = typename __enable_if_t>::type; + + template, + typename _Res2 = __invoke_result<_DFunc&, _ArgTypes...>> + struct _Callable + : __is_invocable_impl<_Res2, _Res>::type + { }; + + template + using _Requires = __enable_if_t<_Cond::value, _Tp>; + + template + using _Handler + = _Function_handler<_Res(_ArgTypes...), __decay_t<_Functor>>; + + public: + typedef _Res result_type; + + // [3.7.2.1] construct/copy/destroy + + /** + * @brief Default construct creates an empty function call wrapper. + * @post `!(bool)*this` + */ + function() noexcept + : _Function_base() { } + + /** + * @brief Creates an empty function call wrapper. + * @post @c !(bool)*this + */ + function(nullptr_t) noexcept + : _Function_base() { } + + /** + * @brief %Function copy constructor. + * @param __x A %function object with identical call signature. + * @post `bool(*this) == bool(__x)` + * + * The newly-created %function contains a copy of the target of + * `__x` (if it has one). + */ + function(const function& __x) + : _Function_base() + { + if (static_cast(__x)) + { + __x._M_manager(_M_functor, __x._M_functor, __clone_functor); + _M_invoker = __x._M_invoker; + _M_manager = __x._M_manager; + } + } + + /** + * @brief %Function move constructor. + * @param __x A %function object rvalue with identical call signature. + * + * The newly-created %function contains the target of `__x` + * (if it has one). + */ + function(function&& __x) noexcept + : _Function_base(), _M_invoker(__x._M_invoker) + { + if (static_cast(__x)) + { + _M_functor = __x._M_functor; + _M_manager = __x._M_manager; + __x._M_manager = nullptr; + __x._M_invoker = nullptr; + } + } + + /** + * @brief Builds a %function that targets a copy of the incoming + * function object. + * @param __f A %function object that is callable with parameters of + * type `ArgTypes...` and returns a value convertible to `Res`. + * + * The newly-created %function object will target a copy of + * `__f`. If `__f` is `reference_wrapper`, then this function + * object will contain a reference to the function object `__f.get()`. + * If `__f` is a null function pointer, null pointer-to-member, or + * empty `std::function`, the newly-created object will be empty. + * + * If `__f` is a non-null function pointer or an object of type + * `reference_wrapper`, this function will not throw. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2774. std::function construction vs assignment + template>> + function(_Functor&& __f) + noexcept(_Handler<_Functor>::template _S_nothrow_init<_Functor>()) + : _Function_base() + { + static_assert(is_copy_constructible<__decay_t<_Functor>>::value, + "std::function target must be copy-constructible"); + static_assert(is_constructible<__decay_t<_Functor>, _Functor>::value, + "std::function target must be constructible from the " + "constructor argument"); + + using _My_handler = _Handler<_Functor>; + + if (_My_handler::_M_not_empty_function(__f)) + { + _My_handler::_M_init_functor(_M_functor, + std::forward<_Functor>(__f)); + _M_invoker = &_My_handler::_M_invoke; + _M_manager = &_My_handler::_M_manager; + } + } + + /** + * @brief Function assignment operator. + * @param __x A %function with identical call signature. + * @post `(bool)*this == (bool)x` + * @returns `*this` + * + * The target of `__x` is copied to `*this`. If `__x` has no + * target, then `*this` will be empty. + * + * If `__x` targets a function pointer or a reference to a function + * object, then this operation will not throw an exception. + */ + function& + operator=(const function& __x) + { + function(__x).swap(*this); + return *this; + } + + /** + * @brief Function move-assignment operator. + * @param __x A %function rvalue with identical call signature. + * @returns `*this` + * + * The target of `__x` is moved to `*this`. If `__x` has no + * target, then `*this` will be empty. + * + * If `__x` targets a function pointer or a reference to a function + * object, then this operation will not throw an exception. + */ + function& + operator=(function&& __x) noexcept + { + function(std::move(__x)).swap(*this); + return *this; + } + + /** + * @brief Function assignment to empty. + * @post `!(bool)*this` + * @returns `*this` + * + * The target of `*this` is deallocated, leaving it empty. + */ + function& + operator=(nullptr_t) noexcept + { + if (_M_manager) + { + _M_manager(_M_functor, _M_functor, __destroy_functor); + _M_manager = nullptr; + _M_invoker = nullptr; + } + return *this; + } + + /** + * @brief Function assignment to a new target. + * @param __f A function object that is callable with parameters of + * type `_ArgTypes...` and returns a value convertible + * to `_Res`. + * @return `*this` + * @since C++11 + * + * This function object wrapper will target a copy of `__f`. If `__f` + * is `reference_wrapper`, then this function object will contain + * a reference to the function object `__f.get()`. If `__f` is a null + * function pointer or null pointer-to-member, this object will be + * empty. + * + * If `__f` is a non-null function pointer or an object of type + * `reference_wrapper`, this function will not throw. + */ + template + _Requires<_Callable<_Functor>, function&> + operator=(_Functor&& __f) + noexcept(_Handler<_Functor>::template _S_nothrow_init<_Functor>()) + { + function(std::forward<_Functor>(__f)).swap(*this); + return *this; + } + + /// @overload + template + function& + operator=(reference_wrapper<_Functor> __f) noexcept + { + function(__f).swap(*this); + return *this; + } + + // [3.7.2.2] function modifiers + + /** + * @brief Swap the targets of two %function objects. + * @param __x A %function with identical call signature. + * + * Swap the targets of `this` function object and `__f`. + * This function will not throw exceptions. + */ + void swap(function& __x) noexcept + { + std::swap(_M_functor, __x._M_functor); + std::swap(_M_manager, __x._M_manager); + std::swap(_M_invoker, __x._M_invoker); + } + + // [3.7.2.3] function capacity + + /** + * @brief Determine if the %function wrapper has a target. + * + * @return `true` when this function object contains a target, + * or `false` when it is empty. + * + * This function will not throw exceptions. + */ + explicit operator bool() const noexcept + { return !_M_empty(); } + + // [3.7.2.4] function invocation + + /** + * @brief Invokes the function targeted by `*this`. + * @returns the result of the target. + * @throws `bad_function_call` when `!(bool)*this` + * + * The function call operator invokes the target function object + * stored by `this`. + */ + _Res + operator()(_ArgTypes... __args) const + { + if (_M_empty()) + __throw_bad_function_call(); + return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...); + } + +#if __cpp_rtti + // [3.7.2.5] function target access + /** + * @brief Determine the type of the target of this function object + * wrapper. + * + * @returns the type identifier of the target function object, or + * `typeid(void)` if `!(bool)*this`. + * + * This function will not throw exceptions. + */ + const type_info& + target_type() const noexcept + { + if (_M_manager) + { + _Any_data __typeinfo_result; + _M_manager(__typeinfo_result, _M_functor, __get_type_info); + if (auto __ti = __typeinfo_result._M_access()) + return *__ti; + } + return typeid(void); + } +#endif + + /** + * @brief Access the stored target function object. + * + * @return Returns a pointer to the stored target function object, + * if `typeid(_Functor).equals(target_type())`; otherwise, a null + * pointer. + * + * This function does not throw exceptions. + * + * @{ + */ + template + _Functor* + target() noexcept + { + const function* __const_this = this; + const _Functor* __func = __const_this->template target<_Functor>(); + // If is_function_v<_Functor> is true then const_cast<_Functor*> + // would be ill-formed, so use *const_cast<_Functor**> instead. + return *const_cast<_Functor**>(&__func); + } + + template + const _Functor* + target() const noexcept + { + if _GLIBCXX17_CONSTEXPR (is_object<_Functor>::value) + { + // For C++11 and C++14 if-constexpr is not used above, so + // _Target_handler avoids ill-formed _Function_handler types. + using _Handler = _Target_handler<_Res(_ArgTypes...), _Functor>; + + if (_M_manager == &_Handler::_M_manager +#if __cpp_rtti + || (_M_manager && typeid(_Functor) == target_type()) +#endif + ) + { + _Any_data __ptr; + _M_manager(__ptr, _M_functor, __get_functor_ptr); + return __ptr._M_access(); + } + } + return nullptr; + } + /// @} + + private: + using _Invoker_type = _Res (*)(const _Any_data&, _ArgTypes&&...); + _Invoker_type _M_invoker = nullptr; + }; + +#if __cpp_deduction_guides >= 201606 + template + struct __function_guide_helper + { }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) & noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) const noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) const & noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + function(_Res(*)(_ArgTypes...)) -> function<_Res(_ArgTypes...)>; + + template::type> + function(_Functor) -> function<_Signature>; +#endif + + // [20.7.15.2.6] null pointer comparisons + + /** + * @brief Test whether a polymorphic function object wrapper is empty. + * @returns `true` if the wrapper has no target, `false` otherwise + * + * This function will not throw exceptions. + */ + template + inline bool + operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept + { return !static_cast(__f); } + +#if __cpp_impl_three_way_comparison < 201907L + /// @overload + template + inline bool + operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept + { return !static_cast(__f); } + + /** + * @brief Test whether a polymorphic function object wrapper is non-empty. + * @returns `false` if the wrapper has no target, `true` otherwise + * + * This function will not throw exceptions. + */ + template + inline bool + operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept + { return static_cast(__f); } + + /// @overload + template + inline bool + operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept + { return static_cast(__f); } +#endif + + // [20.7.15.2.7] specialized algorithms + + /** + * @brief Swap the targets of two polymorphic function object wrappers. + * + * This function will not throw exceptions. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2062. Effect contradictions w/o no-throw guarantee of std::function swaps + template + inline void + swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept + { __x.swap(__y); } + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // function into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 +#endif // _GLIBCXX_STD_FUNCTION_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..2b5c37d9911805b517c4781056ddb617dda628c9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_function.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h new file mode 100644 index 0000000000000000000000000000000000000000..d3a1d5eaec90c3f2a7360318a8323ccfe6ca776b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h @@ -0,0 +1,248 @@ +// std::mutex implementation -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/std_mutex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{mutex} + */ + +#ifndef _GLIBCXX_MUTEX_H +#define _GLIBCXX_MUTEX_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup mutexes Mutexes + * @ingroup concurrency + * + * Classes for mutex support. + * @{ + */ + +#ifdef _GLIBCXX_HAS_GTHREADS + // Common base class for std::mutex and std::timed_mutex + class __mutex_base + { + protected: + typedef __gthread_mutex_t __native_type; + +#ifdef __GTHREAD_MUTEX_INIT + __native_type _M_mutex = __GTHREAD_MUTEX_INIT; + + constexpr __mutex_base() noexcept = default; +#else + __native_type _M_mutex; + + __mutex_base() noexcept + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); + } + + ~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); } +#endif + + __mutex_base(const __mutex_base&) = delete; + __mutex_base& operator=(const __mutex_base&) = delete; + }; + + /// The standard mutex type. + class mutex : private __mutex_base + { + public: + typedef __native_type* native_handle_type; + +#ifdef __GTHREAD_MUTEX_INIT + constexpr +#endif + mutex() noexcept = default; + ~mutex() = default; + + mutex(const mutex&) = delete; + mutex& operator=(const mutex&) = delete; + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() noexcept + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EPERM + __gthread_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() noexcept + { return &_M_mutex; } + }; + + // Implementation details for std::condition_variable + class __condvar + { + using timespec = __gthread_time_t; + + public: + __condvar() noexcept + { +#ifndef __GTHREAD_COND_INIT + __GTHREAD_COND_INIT_FUNCTION(&_M_cond); +#endif + } + + ~__condvar() + { + int __e __attribute__((__unused__)) = __gthread_cond_destroy(&_M_cond); + __glibcxx_assert(__e != EBUSY); // threads are still blocked + } + + __condvar(const __condvar&) = delete; + __condvar& operator=(const __condvar&) = delete; + + __gthread_cond_t* native_handle() noexcept { return &_M_cond; } + + // Expects: Calling thread has locked __m. + void + wait(mutex& __m) + { + int __e __attribute__((__unused__)) + = __gthread_cond_wait(&_M_cond, __m.native_handle()); + __glibcxx_assert(__e == 0); + } + + void + wait_until(mutex& __m, timespec& __abs_time) + { + __gthread_cond_timedwait(&_M_cond, __m.native_handle(), &__abs_time); + } + +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + void + wait_until(mutex& __m, clockid_t __clock, timespec& __abs_time) + { + pthread_cond_clockwait(&_M_cond, __m.native_handle(), __clock, + &__abs_time); + } +#endif + + void + notify_one() noexcept + { + int __e __attribute__((__unused__)) = __gthread_cond_signal(&_M_cond); + __glibcxx_assert(__e == 0); + } + + void + notify_all() noexcept + { + int __e __attribute__((__unused__)) = __gthread_cond_broadcast(&_M_cond); + __glibcxx_assert(__e == 0); + } + + protected: +#ifdef __GTHREAD_COND_INIT + __gthread_cond_t _M_cond = __GTHREAD_COND_INIT; +#else + __gthread_cond_t _M_cond; +#endif + }; + +#endif // _GLIBCXX_HAS_GTHREADS + + /// Do not acquire ownership of the mutex. + struct defer_lock_t { explicit defer_lock_t() = default; }; + + /// Try to acquire ownership of the mutex without blocking. + struct try_to_lock_t { explicit try_to_lock_t() = default; }; + + /// Assume the calling thread has already obtained mutex ownership + /// and manage it. + struct adopt_lock_t { explicit adopt_lock_t() = default; }; + + /// Tag used to prevent a scoped lock from acquiring ownership of a mutex. + _GLIBCXX17_INLINE constexpr defer_lock_t defer_lock { }; + + /// Tag used to prevent a scoped lock from blocking if a mutex is locked. + _GLIBCXX17_INLINE constexpr try_to_lock_t try_to_lock { }; + + /// Tag used to make a scoped lock take ownership of a locked mutex. + _GLIBCXX17_INLINE constexpr adopt_lock_t adopt_lock { }; + + /** @brief A simple scoped lock type. + * + * A lock_guard controls mutex ownership within a scope, releasing + * ownership in the destructor. + */ + template + class lock_guard + { + public: + typedef _Mutex mutex_type; + + explicit lock_guard(mutex_type& __m) : _M_device(__m) + { _M_device.lock(); } + + lock_guard(mutex_type& __m, adopt_lock_t) noexcept : _M_device(__m) + { } // calling thread owns mutex + + ~lock_guard() + { _M_device.unlock(); } + + lock_guard(const lock_guard&) = delete; + lock_guard& operator=(const lock_guard&) = delete; + + private: + mutex_type& _M_device; + }; + + /// @} group mutexes +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 +#endif // _GLIBCXX_MUTEX_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8a212994c9d05f7c3135817ce0cd6667c4491bf9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_mutex.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h new file mode 100644 index 0000000000000000000000000000000000000000..dd625de3bc3ed31cfef3c42692c13d1c3ec74232 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h @@ -0,0 +1,334 @@ +// std::thread declarations -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/std_thread.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{thread} + */ + +#ifndef _GLIBCXX_THREAD_H +#define _GLIBCXX_THREAD_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include + +#include // std::basic_ostream +#include // std::tuple +#include // std::hash +#include // std::__invoke +#include // not required, but helpful to users +#include // std::unique_ptr + +#ifdef _GLIBCXX_HAS_GTHREADS +# include +#else +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup threads + * @{ + */ + + /// thread + class thread + { + public: +#ifdef _GLIBCXX_HAS_GTHREADS + // Abstract base class for types that wrap arbitrary functors to be + // invoked in the new thread of execution. + struct _State + { + virtual ~_State(); + virtual void _M_run() = 0; + }; + using _State_ptr = unique_ptr<_State>; + + using native_handle_type = __gthread_t; +#else + using native_handle_type = int; +#endif + + /// thread::id + class id + { + native_handle_type _M_thread; + + public: + id() noexcept : _M_thread() { } + + explicit + id(native_handle_type __id) : _M_thread(__id) { } + + private: + friend class thread; + friend struct hash; + + friend bool + operator==(id __x, id __y) noexcept; + +#if __cpp_lib_three_way_comparison + friend strong_ordering + operator<=>(id __x, id __y) noexcept; +#else + friend bool + operator<(id __x, id __y) noexcept; +#endif + + template + friend basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, id __id); + }; + + private: + id _M_id; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2097. packaged_task constructors should be constrained + // 3039. Unnecessary decay in thread and packaged_task + template + using __not_same = __not_, thread>>; + + public: + thread() noexcept = default; + +#ifdef _GLIBCXX_HAS_GTHREADS + template>> + explicit + thread(_Callable&& __f, _Args&&... __args) + { + static_assert( __is_invocable::type, + typename decay<_Args>::type...>::value, + "std::thread arguments must be invocable after conversion to rvalues" + ); + +#ifdef GTHR_ACTIVE_PROXY + // Create a reference to pthread_create, not just the gthr weak symbol. + auto __depend = reinterpret_cast(&pthread_create); +#else + auto __depend = nullptr; +#endif + using _Wrapper = _Call_wrapper<_Callable, _Args...>; + // Create a call wrapper with DECAY_COPY(__f) as its target object + // and DECAY_COPY(__args)... as its bound argument entities. + _M_start_thread(_State_ptr(new _State_impl<_Wrapper>( + std::forward<_Callable>(__f), std::forward<_Args>(__args)...)), + __depend); + } +#endif // _GLIBCXX_HAS_GTHREADS + + ~thread() + { + if (joinable()) + std::__terminate(); + } + + thread(const thread&) = delete; + + thread(thread&& __t) noexcept + { swap(__t); } + + thread& operator=(const thread&) = delete; + + thread& operator=(thread&& __t) noexcept + { + if (joinable()) + std::__terminate(); + swap(__t); + return *this; + } + + void + swap(thread& __t) noexcept + { std::swap(_M_id, __t._M_id); } + + bool + joinable() const noexcept + { return !(_M_id == id()); } + + void + join(); + + void + detach(); + + id + get_id() const noexcept + { return _M_id; } + + /** @pre thread is joinable + */ + native_handle_type + native_handle() + { return _M_id._M_thread; } + + // Returns a value that hints at the number of hardware thread contexts. + static unsigned int + hardware_concurrency() noexcept; + +#ifdef _GLIBCXX_HAS_GTHREADS + private: + template + struct _State_impl : public _State + { + _Callable _M_func; + + template + _State_impl(_Args&&... __args) + : _M_func{{std::forward<_Args>(__args)...}} + { } + + void + _M_run() { _M_func(); } + }; + + void + _M_start_thread(_State_ptr, void (*)()); + +#if _GLIBCXX_THREAD_ABI_COMPAT + public: + struct _Impl_base; + typedef shared_ptr<_Impl_base> __shared_base_type; + struct _Impl_base + { + __shared_base_type _M_this_ptr; + virtual ~_Impl_base() = default; + virtual void _M_run() = 0; + }; + + private: + void + _M_start_thread(__shared_base_type, void (*)()); + + void + _M_start_thread(__shared_base_type); +#endif + + private: + // A call wrapper that does INVOKE(forwarded tuple elements...) + template + struct _Invoker + { + _Tuple _M_t; + + template + struct __result; + template + struct __result> + : __invoke_result<_Fn, _Args...> + { }; + + template + typename __result<_Tuple>::type + _M_invoke(_Index_tuple<_Ind...>) + { return std::__invoke(std::get<_Ind>(std::move(_M_t))...); } + + typename __result<_Tuple>::type + operator()() + { + using _Indices + = typename _Build_index_tuple::value>::__type; + return _M_invoke(_Indices()); + } + }; + + public: + template + using _Call_wrapper = _Invoker::type...>>; +#endif // _GLIBCXX_HAS_GTHREADS + }; + +#ifndef _GLIBCXX_HAS_GTHREADS + inline void thread::join() { std::__throw_system_error(EINVAL); } + inline void thread::detach() { std::__throw_system_error(EINVAL); } + inline unsigned int thread::hardware_concurrency() noexcept { return 0; } +#endif + + inline void + swap(thread& __x, thread& __y) noexcept + { __x.swap(__y); } + + inline bool + operator==(thread::id __x, thread::id __y) noexcept + { + // pthread_equal is undefined if either thread ID is not valid, so we + // can't safely use __gthread_equal on default-constructed values (nor + // the non-zero value returned by this_thread::get_id() for + // single-threaded programs using GNU libc). Assume EqualityComparable. + return __x._M_thread == __y._M_thread; + } + + // N.B. other comparison operators are defined in + + // DR 889. + /// std::hash specialization for thread::id. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const thread::id& __id) const noexcept + { return std::_Hash_impl::hash(__id._M_thread); } + }; + + namespace this_thread + { + /// this_thread::get_id + inline thread::id + get_id() noexcept + { +#ifndef _GLIBCXX_HAS_GTHREADS + return thread::id(1); +#elif defined _GLIBCXX_NATIVE_THREAD_ID + return thread::id(_GLIBCXX_NATIVE_THREAD_ID); +#else + return thread::id(__gthread_self()); +#endif + } + + /// this_thread::yield + inline void + yield() noexcept + { +#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD + __gthread_yield(); +#endif + } + + } // namespace this_thread + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 + +#endif // _GLIBCXX_THREAD_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7a403397d729060cd1740b0f8f687650d83ce54a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@std_thread.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h new file mode 100644 index 0000000000000000000000000000000000000000..1f07b9e65897da10b1548f5989a72a2f250d6296 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h @@ -0,0 +1,5896 @@ +// Algorithm implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_algo.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _STL_ALGO_H +#define _STL_ALGO_H 1 + +#include +#include +#include // for _Temporary_buffer +#include + +#if __cplusplus >= 201103L +#include +#endif + +#if _GLIBCXX_HOSTED && (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED) +#include // for rand +#endif + +// See concept_check.h for the __glibcxx_*_requires macros. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Swaps the median value of *__a, *__b and *__c under __comp to *__result + template + _GLIBCXX20_CONSTEXPR + void + __move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b, + _Iterator __c, _Compare __comp) + { + if (__comp(__a, __b)) + { + if (__comp(__b, __c)) + std::iter_swap(__result, __b); + else if (__comp(__a, __c)) + std::iter_swap(__result, __c); + else + std::iter_swap(__result, __a); + } + else if (__comp(__a, __c)) + std::iter_swap(__result, __a); + else if (__comp(__b, __c)) + std::iter_swap(__result, __c); + else + std::iter_swap(__result, __b); + } + + /// Provided for stable_partition to use. + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + __find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__negate(__pred), + std::__iterator_category(__first)); + } + + /// Like find_if_not(), but uses and updates a count of the + /// remaining range length instead of comparing against an end + /// iterator. + template + _GLIBCXX20_CONSTEXPR + _InputIterator + __find_if_not_n(_InputIterator __first, _Distance& __len, _Predicate __pred) + { + for (; __len; --__len, (void) ++__first) + if (!__pred(__first)) + break; + return __first; + } + + // set_difference + // set_intersection + // set_symmetric_difference + // set_union + // for_each + // find + // find_if + // find_first_of + // adjacent_find + // count + // count_if + // search + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator1 + __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __predicate) + { + // Test for empty ranges + if (__first1 == __last1 || __first2 == __last2) + return __first1; + + // Test for a pattern of length 1. + _ForwardIterator2 __p1(__first2); + if (++__p1 == __last2) + return std::__find_if(__first1, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); + + // General case. + _ForwardIterator1 __current = __first1; + + for (;;) + { + __first1 = + std::__find_if(__first1, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); + + if (__first1 == __last1) + return __last1; + + _ForwardIterator2 __p = __p1; + __current = __first1; + if (++__current == __last1) + return __last1; + + while (__predicate(__current, __p)) + { + if (++__p == __last2) + return __first1; + if (++__current == __last1) + return __last1; + } + ++__first1; + } + return __first1; + } + + // search_n + + /** + * This is an helper function for search_n overloaded for forward iterators. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __search_n_aux(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, _UnaryPredicate __unary_pred, + std::forward_iterator_tag) + { + __first = std::__find_if(__first, __last, __unary_pred); + while (__first != __last) + { + typename iterator_traits<_ForwardIterator>::difference_type + __n = __count; + _ForwardIterator __i = __first; + ++__i; + while (__i != __last && __n != 1 && __unary_pred(__i)) + { + ++__i; + --__n; + } + if (__n == 1) + return __first; + if (__i == __last) + return __last; + __first = std::__find_if(++__i, __last, __unary_pred); + } + return __last; + } + + /** + * This is an helper function for search_n overloaded for random access + * iterators. + */ + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIter + __search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last, + _Integer __count, _UnaryPredicate __unary_pred, + std::random_access_iterator_tag) + { + typedef typename std::iterator_traits<_RandomAccessIter>::difference_type + _DistanceType; + + _DistanceType __tailSize = __last - __first; + _DistanceType __remainder = __count; + + while (__remainder <= __tailSize) // the main loop... + { + __first += __remainder; + __tailSize -= __remainder; + // __first here is always pointing to one past the last element of + // next possible match. + _RandomAccessIter __backTrack = __first; + while (__unary_pred(--__backTrack)) + { + if (--__remainder == 0) + return (__first - __count); // Success + } + __remainder = __count + 1 - (__first - __backTrack); + } + return __last; // Failure + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, + _UnaryPredicate __unary_pred) + { + if (__count <= 0) + return __first; + + if (__count == 1) + return std::__find_if(__first, __last, __unary_pred); + + return std::__search_n_aux(__first, __last, __count, __unary_pred, + std::__iterator_category(__first)); + } + + // find_end for forward iterators. + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator1 + __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + forward_iterator_tag, forward_iterator_tag, + _BinaryPredicate __comp) + { + if (__first2 == __last2) + return __last1; + + _ForwardIterator1 __result = __last1; + while (1) + { + _ForwardIterator1 __new_result + = std::__search(__first1, __last1, __first2, __last2, __comp); + if (__new_result == __last1) + return __result; + else + { + __result = __new_result; + __first1 = __new_result; + ++__first1; + } + } + } + + // find_end for bidirectional iterators (much faster). + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator1 + __find_end(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + bidirectional_iterator_tag, bidirectional_iterator_tag, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator1>) + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator2>) + + typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1; + typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2; + + _RevIterator1 __rlast1(__first1); + _RevIterator2 __rlast2(__first2); + _RevIterator1 __rresult = std::__search(_RevIterator1(__last1), __rlast1, + _RevIterator2(__last2), __rlast2, + __comp); + + if (__rresult == __rlast1) + return __last1; + else + { + _BidirectionalIterator1 __result = __rresult.base(); + std::advance(__result, -std::distance(__first2, __last2)); + return __result; + } + } + + /** + * @brief Find last matching subsequence in a sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of sequence to match. + * @param __last2 End of sequence to match. + * @return The last iterator @c i in the range + * @p [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == + * @p *(__first2+N) for each @c N in the range @p + * [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) and returns an iterator to the __first + * element of the sub-sequence, or @p __last1 if the sub-sequence + * is not found. The sub-sequence will be the last such + * subsequence contained in [__first1,__last1). + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. This means that the returned + * iterator @c i will be in the range @p + * [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__find_end(__first1, __last1, __first2, __last2, + std::__iterator_category(__first1), + std::__iterator_category(__first2), + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Find last matching subsequence in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of sequence to match. + * @param __last2 End of sequence to match. + * @param __comp The predicate to use. + * @return The last iterator @c i in the range @p + * [__first1,__last1-(__last2-__first2)) such that @c + * predicate(*(i+N), @p (__first2+N)) is true for each @c N in the + * range @p [0,__last2-__first2), or @p __last1 if no such iterator + * exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) using comp as a predicate and returns an + * iterator to the first element of the sub-sequence, or @p __last1 + * if the sub-sequence is not found. The sub-sequence will be the + * last such subsequence contained in [__first,__last1). + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. This means that the returned + * iterator @c i will be in the range @p + * [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__find_end(__first1, __last1, __first2, __last2, + std::__iterator_category(__first1), + std::__iterator_category(__first2), + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cplusplus >= 201103L + /** + * @brief Checks that a predicate is true for all the elements + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p __pred is true for each element in the range + * @p [__first,__last), and false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == std::find_if_not(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is false for all the elements + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p __pred is false for each element in the range + * @p [__first,__last), and false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is true for at least one element + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if an element exists in the range @p + * [__first,__last) such that @p __pred is true, and false + * otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return !std::none_of(__first, __last, __pred); } + + /** + * @brief Find the first element in a sequence for which a + * predicate is false. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @p __pred(*i) is false, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + return std::__find_if_not(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Checks whether the sequence is partitioned. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the range @p [__first,__last) is partioned by @p __pred, + * i.e. if all elements that satisfy @p __pred appear before those that + * do not. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_partitioned(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + __first = std::find_if_not(__first, __last, __pred); + if (__first == __last) + return true; + ++__first; + return std::none_of(__first, __last, __pred); + } + + /** + * @brief Find the partition point of a partitioned range. + * @ingroup mutating_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __pred A predicate. + * @return An iterator @p mid such that @p all_of(__first, mid, __pred) + * and @p none_of(mid, __last, __pred) are both true. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + partition_point(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + + // A specific debug-mode test will be necessary... + __glibcxx_requires_valid_range(__first, __last); + + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__pred(*__middle)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } +#endif + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __remove_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + for (; __first != __last; ++__first) + if (!__pred(__first)) + { + *__result = *__first; + ++__result; + } + return __result; + } + + /** + * @brief Copy a sequence, removing elements of a given value. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __value The value to be removed. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) not equal + * to @p __value to the range beginning at @p __result. + * remove_copy() is stable, so the relative order of elements that + * are copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + remove_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Copy a sequence, removing elements for which a predicate is true. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns false to the range beginning at @p __result. + * + * remove_copy_if() is stable, so the relative order of elements that are + * copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + remove_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + +#if __cplusplus >= 201103L + /** + * @brief Copy the elements of a sequence for which a predicate is true. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns true to the range beginning at @p __result. + * + * copy_if() is stable, so the relative order of elements that are + * copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + { + *__result = *__first; + ++__result; + } + return __result; + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __copy_n(_InputIterator __first, _Size __n, + _OutputIterator __result, input_iterator_tag) + { + return std::__niter_wrap(__result, + __copy_n_a(__first, __n, + std::__niter_base(__result), true)); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __copy_n(_RandomAccessIterator __first, _Size __n, + _OutputIterator __result, random_access_iterator_tag) + { return std::copy(__first, __first + __n, __result); } + + /** + * @brief Copies the range [first,first+n) into [result,result+n). + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __n The number of elements to copy. + * @param __result An output iterator. + * @return result+n. + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + + const auto __n2 = std::__size_to_integer(__n); + if (__n2 <= 0) + return __result; + + __glibcxx_requires_can_increment(__first, __n2); + __glibcxx_requires_can_increment(__result, __n2); + + return std::__copy_n(__first, __n2, __result, + std::__iterator_category(__first)); + } + + /** + * @brief Copy the elements of a sequence to separate output sequences + * depending on the truth value of a predicate. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __out_true An output iterator. + * @param __out_false An output iterator. + * @param __pred A predicate. + * @return A pair designating the ends of the resulting sequences. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns true to the range beginning at @p out_true + * and each element for which @p __pred returns false to @p __out_false. + */ + template + _GLIBCXX20_CONSTEXPR + pair<_OutputIterator1, _OutputIterator2> + partition_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator1 __out_true, _OutputIterator2 __out_false, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator1, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator2, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + { + *__out_true = *__first; + ++__out_true; + } + else + { + *__out_false = *__first; + ++__out_false; + } + + return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false); + } +#endif // C++11 + + /** + * @brief Remove elements from a sequence. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __value The value to be removed. + * @return An iterator designating the end of the resulting sequence. + * + * All elements equal to @p __value are removed from the range + * @p [__first,__last). + * + * remove() is stable, so the relative order of elements that are + * not removed is unchanged. + * + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + remove(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Remove elements from a sequence using a predicate. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * All elements for which @p __pred returns true are removed from the range + * @p [__first,__last). + * + * remove_if() is stable, so the relative order of elements that are + * not removed is unchanged. + * + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + remove_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __adjacent_find(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + if (__first == __last) + return __last; + _ForwardIterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(__first, __next)) + return __first; + __first = __next; + } + return __last; + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __unique(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // Skip the beginning, if already unique. + __first = std::__adjacent_find(__first, __last, __binary_pred); + if (__first == __last) + return __last; + + // Do the real copy work. + _ForwardIterator __dest = __first; + ++__first; + while (++__first != __last) + if (!__binary_pred(__dest, __first)) + *++__dest = _GLIBCXX_MOVE(*__first); + return ++__dest; + } + + /** + * @brief Remove consecutive duplicate values from a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Removes all but the first element from each group of consecutive + * values that compare equal. + * unique() is stable, so the relative order of elements that are + * not removed is unchanged. + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + unique(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__unique(__first, __last, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Remove consecutive values from a sequence using a predicate. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __binary_pred A binary predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Removes all but the first element from each group of consecutive + * values for which @p __binary_pred returns true. + * unique() is stable, so the relative order of elements that are + * not removed is unchanged. + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + unique(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__unique(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for forward iterators and output iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __unique_copy(_ForwardIterator __first, _ForwardIterator __last, + _OutputIterator __result, _BinaryPredicate __binary_pred, + forward_iterator_tag, output_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + + _ForwardIterator __next = __first; + *__result = *__first; + while (++__next != __last) + if (!__binary_pred(__first, __next)) + { + __first = __next; + *++__result = *__first; + } + return ++__result; + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for input iterators and output iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, output_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_InputIterator>::value_type>) + + typename iterator_traits<_InputIterator>::value_type __value = *__first; + __decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred)) + __rebound_pred + = __gnu_cxx::__ops::__iter_comp_val(__binary_pred); + *__result = __value; + while (++__first != __last) + if (!__rebound_pred(__first, __value)) + { + __value = *__first; + *++__result = __value; + } + return ++__result; + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for input iterators and forward iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __unique_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, forward_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_InputIterator>::value_type>) + *__result = *__first; + while (++__first != __last) + if (!__binary_pred(__result, __first)) + *++__result = *__first; + return ++__result; + } + + /** + * This is an uglified reverse(_BidirectionalIterator, + * _BidirectionalIterator) + * overloaded for bidirectional iterators. + */ + template + _GLIBCXX20_CONSTEXPR + void + __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, + bidirectional_iterator_tag) + { + while (true) + if (__first == __last || __first == --__last) + return; + else + { + std::iter_swap(__first, __last); + ++__first; + } + } + + /** + * This is an uglified reverse(_BidirectionalIterator, + * _BidirectionalIterator) + * overloaded for random access iterators. + */ + template + _GLIBCXX20_CONSTEXPR + void + __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, + random_access_iterator_tag) + { + if (__first == __last) + return; + --__last; + while (__first < __last) + { + std::iter_swap(__first, __last); + ++__first; + --__last; + } + } + + /** + * @brief Reverse a sequence. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @return reverse() returns no value. + * + * Reverses the order of the elements in the range @p [__first,__last), + * so that the first element becomes the last etc. + * For every @c i such that @p 0<=i<=(__last-__first)/2), @p reverse() + * swaps @p *(__first+i) and @p *(__last-(i+1)) + */ + template + _GLIBCXX20_CONSTEXPR + inline void + reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_requires_valid_range(__first, __last); + std::__reverse(__first, __last, std::__iterator_category(__first)); + } + + /** + * @brief Copy a sequence, reversing its elements. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies the elements in the range @p [__first,__last) to the + * range @p [__result,__result+(__last-__first)) such that the + * order of the elements is reversed. For every @c i such that @p + * 0<=i<=(__last-__first), @p reverse_copy() performs the + * assignment @p *(__result+(__last-__first)-1-i) = *(__first+i). + * The ranges @p [__first,__last) and @p + * [__result,__result+(__last-__first)) must not overlap. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + while (__first != __last) + { + --__last; + *__result = *__last; + ++__result; + } + return __result; + } + + /** + * This is a helper function for the rotate algorithm specialized on RAIs. + * It returns the greatest common divisor of two integer values. + */ + template + _GLIBCXX20_CONSTEXPR + _EuclideanRingElement + __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n) + { + while (__n != 0) + { + _EuclideanRingElement __t = __m % __n; + __m = __n; + __n = __t; + } + return __m; + } + + inline namespace _V2 + { + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __rotate(_ForwardIterator __first, + _ForwardIterator __middle, + _ForwardIterator __last, + forward_iterator_tag) + { + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + _ForwardIterator __first2 = __middle; + do + { + std::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + } + while (__first2 != __last); + + _ForwardIterator __ret = __first; + + __first2 = __middle; + + while (__first2 != __last) + { + std::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + else if (__first2 == __last) + __first2 = __middle; + } + return __ret; + } + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator + __rotate(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + bidirectional_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + std::__reverse(__first, __middle, bidirectional_iterator_tag()); + std::__reverse(__middle, __last, bidirectional_iterator_tag()); + + while (__first != __middle && __middle != __last) + { + std::iter_swap(__first, --__last); + ++__first; + } + + if (__first == __middle) + { + std::__reverse(__middle, __last, bidirectional_iterator_tag()); + return __last; + } + else + { + std::__reverse(__first, __middle, bidirectional_iterator_tag()); + return __first; + } + } + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __rotate(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _Distance; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + _Distance __n = __last - __first; + _Distance __k = __middle - __first; + + if (__k == __n - __k) + { + std::swap_ranges(__first, __middle, __middle); + return __middle; + } + + _RandomAccessIterator __p = __first; + _RandomAccessIterator __ret = __first + (__last - __middle); + + for (;;) + { + if (__k < __n - __k) + { + if (__is_pod(_ValueType) && __k == 1) + { + _ValueType __t = _GLIBCXX_MOVE(*__p); + _GLIBCXX_MOVE3(__p + 1, __p + __n, __p); + *(__p + __n - 1) = _GLIBCXX_MOVE(__t); + return __ret; + } + _RandomAccessIterator __q = __p + __k; + for (_Distance __i = 0; __i < __n - __k; ++ __i) + { + std::iter_swap(__p, __q); + ++__p; + ++__q; + } + __n %= __k; + if (__n == 0) + return __ret; + std::swap(__n, __k); + __k = __n - __k; + } + else + { + __k = __n - __k; + if (__is_pod(_ValueType) && __k == 1) + { + _ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1)); + _GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n); + *__p = _GLIBCXX_MOVE(__t); + return __ret; + } + _RandomAccessIterator __q = __p + __n; + __p = __q - __k; + for (_Distance __i = 0; __i < __n - __k; ++ __i) + { + --__p; + --__q; + std::iter_swap(__p, __q); + } + __n %= __k; + if (__n == 0) + return __ret; + std::swap(__n, __k); + } + } + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 488. rotate throws away useful information + /** + * @brief Rotate the elements of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __middle A forward iterator. + * @param __last A forward iterator. + * @return first + (last - middle). + * + * Rotates the elements of the range @p [__first,__last) by + * @p (__middle - __first) positions so that the element at @p __middle + * is moved to @p __first, the element at @p __middle+1 is moved to + * @p __first+1 and so on for each element in the range + * @p [__first,__last). + * + * This effectively swaps the ranges @p [__first,__middle) and + * @p [__middle,__last). + * + * Performs + * @p *(__first+(n+(__last-__middle))%(__last-__first))=*(__first+n) + * for each @p n in the range @p [0,__last-__first). + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + rotate(_ForwardIterator __first, _ForwardIterator __middle, + _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + + return std::__rotate(__first, __middle, __last, + std::__iterator_category(__first)); + } + + } // namespace _V2 + + /** + * @brief Copy a sequence, rotating its elements. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __middle A forward iterator. + * @param __last A forward iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies the elements of the range @p [__first,__last) to the + * range beginning at @result, rotating the copied elements by + * @p (__middle-__first) positions so that the element at @p __middle + * is moved to @p __result, the element at @p __middle+1 is moved + * to @p __result+1 and so on for each element in the range @p + * [__first,__last). + * + * Performs + * @p *(__result+(n+(__last-__middle))%(__last-__first))=*(__first+n) + * for each @p n in the range @p [0,__last-__first). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, + _ForwardIterator __last, _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + + return std::copy(__first, __middle, + std::copy(__middle, __last, __result)); + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, forward_iterator_tag) + { + if (__first == __last) + return __first; + + while (__pred(*__first)) + if (++__first == __last) + return __first; + + _ForwardIterator __next = __first; + + while (++__next != __last) + if (__pred(*__next)) + { + std::iter_swap(__first, __next); + ++__first; + } + + return __first; + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator + __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, + _Predicate __pred, bidirectional_iterator_tag) + { + while (true) + { + while (true) + if (__first == __last) + return __first; + else if (__pred(*__first)) + ++__first; + else + break; + --__last; + while (true) + if (__first == __last) + return __first; + else if (!bool(__pred(*__last))) + --__last; + else + break; + std::iter_swap(__first, __last); + ++__first; + } + } + + // partition + + /// This is a helper function... + /// Requires __first != __last and !__pred(__first) + /// and __len == distance(__first, __last). + /// + /// !__pred(__first) allows us to guarantee that we don't + /// move-assign an element onto itself. + template + _ForwardIterator + __stable_partition_adaptive(_ForwardIterator __first, + _ForwardIterator __last, + _Predicate __pred, _Distance __len, + _Pointer __buffer, + _Distance __buffer_size) + { + if (__len == 1) + return __first; + + if (__len <= __buffer_size) + { + _ForwardIterator __result1 = __first; + _Pointer __result2 = __buffer; + + // The precondition guarantees that !__pred(__first), so + // move that element to the buffer before starting the loop. + // This ensures that we only call __pred once per element. + *__result2 = _GLIBCXX_MOVE(*__first); + ++__result2; + ++__first; + for (; __first != __last; ++__first) + if (__pred(__first)) + { + *__result1 = _GLIBCXX_MOVE(*__first); + ++__result1; + } + else + { + *__result2 = _GLIBCXX_MOVE(*__first); + ++__result2; + } + + _GLIBCXX_MOVE3(__buffer, __result2, __result1); + return __result1; + } + + _ForwardIterator __middle = __first; + std::advance(__middle, __len / 2); + _ForwardIterator __left_split = + std::__stable_partition_adaptive(__first, __middle, __pred, + __len / 2, __buffer, + __buffer_size); + + // Advance past true-predicate values to satisfy this + // function's preconditions. + _Distance __right_len = __len - __len / 2; + _ForwardIterator __right_split = + std::__find_if_not_n(__middle, __right_len, __pred); + + if (__right_len) + __right_split = + std::__stable_partition_adaptive(__right_split, __last, __pred, + __right_len, + __buffer, __buffer_size); + + return std::rotate(__left_split, __middle, __right_split); + } + + template + _ForwardIterator + __stable_partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + __first = std::__find_if_not(__first, __last, __pred); + + if (__first == __last) + return __first; + + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _Temporary_buffer<_ForwardIterator, _ValueType> + __buf(__first, std::distance(__first, __last)); + return + std::__stable_partition_adaptive(__first, __last, __pred, + _DistanceType(__buf.requested_size()), + __buf.begin(), + _DistanceType(__buf.size())); + } + + /** + * @brief Move elements for which a predicate is true to the beginning + * of a sequence, preserving relative ordering. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate functor. + * @return An iterator @p middle such that @p __pred(i) is true for each + * iterator @p i in the range @p [first,middle) and false for each @p i + * in the range @p [middle,last). + * + * Performs the same function as @p partition() with the additional + * guarantee that the relative ordering of elements in each group is + * preserved, so any two elements @p x and @p y in the range + * @p [__first,__last) such that @p __pred(x)==__pred(y) will have the same + * relative ordering after calling @p stable_partition(). + */ + template + inline _ForwardIterator + stable_partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__stable_partition(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /// This is a helper function for the sort routines. + template + _GLIBCXX20_CONSTEXPR + void + __heap_select(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, _Compare __comp) + { + std::__make_heap(__first, __middle, __comp); + for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) + if (__comp(__i, __first)) + std::__pop_heap(__first, __middle, __i, __comp); + } + + // partial_sort + + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last, + _Compare __comp) + { + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef iterator_traits<_RandomAccessIterator> _RItTraits; + typedef typename _RItTraits::difference_type _DistanceType; + + if (__result_first == __result_last) + return __result_last; + _RandomAccessIterator __result_real_last = __result_first; + while (__first != __last && __result_real_last != __result_last) + { + *__result_real_last = *__first; + ++__result_real_last; + ++__first; + } + + std::__make_heap(__result_first, __result_real_last, __comp); + while (__first != __last) + { + if (__comp(__first, __result_first)) + std::__adjust_heap(__result_first, _DistanceType(0), + _DistanceType(__result_real_last + - __result_first), + _InputValueType(*__first), __comp); + ++__first; + } + std::__sort_heap(__result_first, __result_real_last, __comp); + return __result_real_last; + } + + /** + * @brief Copy the smallest elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __result_first A random-access iterator. + * @param __result_last Another random-access iterator. + * @return An iterator indicating the end of the resulting sequence. + * + * Copies and sorts the smallest N values from the range @p [__first,__last) + * to the range beginning at @p __result_first, where the number of + * elements to be copied, @p N, is the smaller of @p (__last-__first) and + * @p (__result_last-__result_first). + * After the sort if @e i and @e j are iterators in the range + * @p [__result_first,__result_first+N) such that i precedes j then + * *j<*i is false. + * The value returned is @p __result_first+N. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _OutputValueType; +#endif + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_LessThanOpConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_valid_range(__result_first, __result_last); + + return std::__partial_sort_copy(__first, __last, + __result_first, __result_last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Copy the smallest elements of a sequence using a predicate for + * comparison. + * @ingroup sorting_algorithms + * @param __first An input iterator. + * @param __last Another input iterator. + * @param __result_first A random-access iterator. + * @param __result_last Another random-access iterator. + * @param __comp A comparison functor. + * @return An iterator indicating the end of the resulting sequence. + * + * Copies and sorts the smallest N values from the range @p [__first,__last) + * to the range beginning at @p result_first, where the number of + * elements to be copied, @p N, is the smaller of @p (__last-__first) and + * @p (__result_last-__result_first). + * After the sort if @e i and @e j are iterators in the range + * @p [__result_first,__result_first+N) such that i precedes j then + * @p __comp(*j,*i) is false. + * The value returned is @p __result_first+N. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last, + _Compare __comp) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _OutputValueType; +#endif + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _InputValueType, _OutputValueType>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _OutputValueType, _OutputValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_valid_range(__result_first, __result_last); + + return std::__partial_sort_copy(__first, __last, + __result_first, __result_last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __unguarded_linear_insert(_RandomAccessIterator __last, + _Compare __comp) + { + typename iterator_traits<_RandomAccessIterator>::value_type + __val = _GLIBCXX_MOVE(*__last); + _RandomAccessIterator __next = __last; + --__next; + while (__comp(__val, __next)) + { + *__last = _GLIBCXX_MOVE(*__next); + __last = __next; + --__next; + } + *__last = _GLIBCXX_MOVE(__val); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__first == __last) return; + + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + if (__comp(__i, __first)) + { + typename iterator_traits<_RandomAccessIterator>::value_type + __val = _GLIBCXX_MOVE(*__i); + _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1); + *__first = _GLIBCXX_MOVE(__val); + } + else + std::__unguarded_linear_insert(__i, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + inline void + __unguarded_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + for (_RandomAccessIterator __i = __first; __i != __last; ++__i) + std::__unguarded_linear_insert(__i, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + /** + * @doctodo + * This controls some aspect of the sort routines. + */ + enum { _S_threshold = 16 }; + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __final_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__last - __first > int(_S_threshold)) + { + std::__insertion_sort(__first, __first + int(_S_threshold), __comp); + std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, + __comp); + } + else + std::__insertion_sort(__first, __last, __comp); + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __unguarded_partition(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _RandomAccessIterator __pivot, _Compare __comp) + { + while (true) + { + while (__comp(__first, __pivot)) + ++__first; + --__last; + while (__comp(__pivot, __last)) + --__last; + if (!(__first < __last)) + return __first; + std::iter_swap(__first, __last); + ++__first; + } + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + __unguarded_partition_pivot(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + _RandomAccessIterator __mid = __first + (__last - __first) / 2; + std::__move_median_to_first(__first, __first + 1, __mid, __last - 1, + __comp); + return std::__unguarded_partition(__first + 1, __last, __first, __comp); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + _Compare __comp) + { + std::__heap_select(__first, __middle, __last, __comp); + std::__sort_heap(__first, __middle, __comp); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __introsort_loop(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Size __depth_limit, _Compare __comp) + { + while (__last - __first > int(_S_threshold)) + { + if (__depth_limit == 0) + { + std::__partial_sort(__first, __last, __last, __comp); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition_pivot(__first, __last, __comp); + std::__introsort_loop(__cut, __last, __depth_limit, __comp); + __last = __cut; + } + } + + // sort + + template + _GLIBCXX20_CONSTEXPR + inline void + __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + if (__first != __last) + { + std::__introsort_loop(__first, __last, + std::__lg(__last - __first) * 2, + __comp); + std::__final_insertion_sort(__first, __last, __comp); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Size __depth_limit, + _Compare __comp) + { + while (__last - __first > 3) + { + if (__depth_limit == 0) + { + std::__heap_select(__first, __nth + 1, __last, __comp); + // Place the nth largest element in its final position. + std::iter_swap(__first, __nth); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition_pivot(__first, __last, __comp); + if (__cut <= __nth) + __first = __cut; + else + __last = __cut; + } + std::__insertion_sort(__first, __last, __comp); + } + + // nth_element + + // lower_bound moved to stl_algobase.h + + /** + * @brief Finds the first position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An iterator pointing to the first element not less + * than @p __val, or end() if every element is less + * than @p __val. + * @ingroup binary_search_algorithms + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + + return std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp(__val, __middle)) + __len = __half; + else + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + } + return __first; + } + + /** + * @brief Finds the last position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An iterator pointing to the first element greater than @p __val, + * or end() if no elements are greater than @p __val. + * @ingroup binary_search_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + return std::__upper_bound(__first, __last, __val, + __gnu_cxx::__ops::__val_less_iter()); + } + + /** + * @brief Finds the last position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An iterator pointing to the first element greater than @p __val, + * or end() if no elements are greater than @p __val. + * @ingroup binary_search_algorithms + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + return std::__upper_bound(__first, __last, __val, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + pair<_ForwardIterator, _ForwardIterator> + __equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, + _CompareItTp __comp_it_val, _CompareTpIt __comp_val_it) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp_it_val(__middle, __val)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else if (__comp_val_it(__val, __middle)) + __len = __half; + else + { + _ForwardIterator __left + = std::__lower_bound(__first, __middle, __val, __comp_it_val); + std::advance(__first, __len); + _ForwardIterator __right + = std::__upper_bound(++__middle, __first, __val, __comp_val_it); + return pair<_ForwardIterator, _ForwardIterator>(__left, __right); + } + } + return pair<_ForwardIterator, _ForwardIterator>(__first, __first); + } + + /** + * @brief Finds the largest subrange in which @p __val could be inserted + * at any place in it without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An pair of iterators defining the subrange. + * @ingroup binary_search_algorithms + * + * This is equivalent to + * @code + * std::make_pair(lower_bound(__first, __last, __val), + * upper_bound(__first, __last, __val)) + * @endcode + * but does not actually call those functions. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + return std::__equal_range(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val(), + __gnu_cxx::__ops::__val_less_iter()); + } + + /** + * @brief Finds the largest subrange in which @p __val could be inserted + * at any place in it without changing the ordering. + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An pair of iterators defining the subrange. + * @ingroup binary_search_algorithms + * + * This is equivalent to + * @code + * std::make_pair(lower_bound(__first, __last, __val, __comp), + * upper_bound(__first, __last, __val, __comp)) + * @endcode + * but does not actually call those functions. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + return std::__equal_range(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp), + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + /** + * @brief Determines whether an element exists in a range. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return True if @p __val (or its equivalent) is in [@p + * __first,@p __last ]. + * + * Note that this does not actually return an iterator to @p __val. For + * that, use std::find or a container's specialized find member functions. + */ + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + _ForwardIterator __i + = std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val()); + return __i != __last && !(__val < *__i); + } + + /** + * @brief Determines whether an element exists in a range. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return True if @p __val (or its equivalent) is in @p [__first,__last]. + * + * Note that this does not actually return an iterator to @p __val. For + * that, use std::find or a container's specialized find member functions. + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + _ForwardIterator __i + = std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + return __i != __last && !bool(__comp(__val, *__i)); + } + + // merge + + /// This is a helper function for the __merge_adaptive routines. + template + void + __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + if (__first1 != __last1) + _GLIBCXX_MOVE3(__first1, __last1, __result); + } + + /// This is a helper function for the __merge_adaptive routines. + template + void + __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + _BidirectionalIterator3 __result, + _Compare __comp) + { + if (__first1 == __last1) + { + _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); + return; + } + else if (__first2 == __last2) + return; + + --__last1; + --__last2; + while (true) + { + if (__comp(__last2, __last1)) + { + *--__result = _GLIBCXX_MOVE(*__last1); + if (__first1 == __last1) + { + _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + return; + } + --__last1; + } + else + { + *--__result = _GLIBCXX_MOVE(*__last2); + if (__first2 == __last2) + return; + --__last2; + } + } + } + + /// This is a helper function for the merge routines. + template + _BidirectionalIterator1 + __rotate_adaptive(_BidirectionalIterator1 __first, + _BidirectionalIterator1 __middle, + _BidirectionalIterator1 __last, + _Distance __len1, _Distance __len2, + _BidirectionalIterator2 __buffer, + _Distance __buffer_size) + { + _BidirectionalIterator2 __buffer_end; + if (__len1 > __len2 && __len2 <= __buffer_size) + { + if (__len2) + { + __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); + _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last); + return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first); + } + else + return __first; + } + else if (__len1 <= __buffer_size) + { + if (__len1) + { + __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); + _GLIBCXX_MOVE3(__middle, __last, __first); + return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last); + } + else + return __last; + } + else + return std::rotate(__first, __middle, __last); + } + + /// This is a helper function for the merge routines. + template + void + __merge_adaptive(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Distance __len1, _Distance __len2, + _Pointer __buffer, _Distance __buffer_size, + _Compare __comp) + { + if (__len1 <= __len2 && __len1 <= __buffer_size) + { + _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); + std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last, + __first, __comp); + } + else if (__len2 <= __buffer_size) + { + _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); + std::__move_merge_adaptive_backward(__first, __middle, __buffer, + __buffer_end, __last, __comp); + } + else + { + _BidirectionalIterator __first_cut = __first; + _BidirectionalIterator __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) + { + __len11 = __len1 / 2; + std::advance(__first_cut, __len11); + __second_cut + = std::__lower_bound(__middle, __last, *__first_cut, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + __len22 = std::distance(__middle, __second_cut); + } + else + { + __len22 = __len2 / 2; + std::advance(__second_cut, __len22); + __first_cut + = std::__upper_bound(__first, __middle, *__second_cut, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + __len11 = std::distance(__first, __first_cut); + } + + _BidirectionalIterator __new_middle + = std::__rotate_adaptive(__first_cut, __middle, __second_cut, + __len1 - __len11, __len22, __buffer, + __buffer_size); + std::__merge_adaptive(__first, __first_cut, __new_middle, __len11, + __len22, __buffer, __buffer_size, __comp); + std::__merge_adaptive(__new_middle, __second_cut, __last, + __len1 - __len11, + __len2 - __len22, __buffer, + __buffer_size, __comp); + } + } + + /// This is a helper function for the merge routines. + template + void + __merge_without_buffer(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Distance __len1, _Distance __len2, + _Compare __comp) + { + if (__len1 == 0 || __len2 == 0) + return; + + if (__len1 + __len2 == 2) + { + if (__comp(__middle, __first)) + std::iter_swap(__first, __middle); + return; + } + + _BidirectionalIterator __first_cut = __first; + _BidirectionalIterator __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) + { + __len11 = __len1 / 2; + std::advance(__first_cut, __len11); + __second_cut + = std::__lower_bound(__middle, __last, *__first_cut, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + __len22 = std::distance(__middle, __second_cut); + } + else + { + __len22 = __len2 / 2; + std::advance(__second_cut, __len22); + __first_cut + = std::__upper_bound(__first, __middle, *__second_cut, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + __len11 = std::distance(__first, __first_cut); + } + + _BidirectionalIterator __new_middle + = std::rotate(__first_cut, __middle, __second_cut); + std::__merge_without_buffer(__first, __first_cut, __new_middle, + __len11, __len22, __comp); + std::__merge_without_buffer(__new_middle, __second_cut, __last, + __len1 - __len11, __len2 - __len22, __comp); + } + + template + void + __inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_BidirectionalIterator>::value_type + _ValueType; + typedef typename iterator_traits<_BidirectionalIterator>::difference_type + _DistanceType; + typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; + + if (__first == __middle || __middle == __last) + return; + + const _DistanceType __len1 = std::distance(__first, __middle); + const _DistanceType __len2 = std::distance(__middle, __last); + + // __merge_adaptive will use a buffer for the smaller of + // [first,middle) and [middle,last). + _TmpBuf __buf(__first, std::min(__len1, __len2)); + + if (__buf.begin() == 0) + std::__merge_without_buffer + (__first, __middle, __last, __len1, __len2, __comp); + else + std::__merge_adaptive + (__first, __middle, __last, __len1, __len2, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + /** + * @brief Merges two sorted ranges in place. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Merges two sorted and consecutive ranges, [__first,__middle) and + * [__middle,__last), and puts the result in [__first,__last). The + * output will be sorted. The sort is @e stable, that is, for + * equivalent elements in the two ranges, elements from the first + * range will always come before elements from the second. + * + * If enough additional memory is available, this takes (__last-__first)-1 + * comparisons. Otherwise an NlogN algorithm is used, where N is + * distance(__first,__last). + */ + template + inline void + inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_sorted(__first, __middle); + __glibcxx_requires_sorted(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__inplace_merge(__first, __middle, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Merges two sorted ranges in place. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @param __comp A functor to use for comparisons. + * @return Nothing. + * + * Merges two sorted and consecutive ranges, [__first,__middle) and + * [middle,last), and puts the result in [__first,__last). The output will + * be sorted. The sort is @e stable, that is, for equivalent + * elements in the two ranges, elements from the first range will always + * come before elements from the second. + * + * If enough additional memory is available, this takes (__last-__first)-1 + * comparisons. Otherwise an NlogN algorithm is used, where N is + * distance(__first,__last). + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + inline void + inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_sorted_pred(__first, __middle, __comp); + __glibcxx_requires_sorted_pred(__middle, __last, __comp); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__inplace_merge(__first, __middle, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + + /// This is a helper function for the __merge_sort_loop routines. + template + _OutputIterator + __move_merge(_InputIterator __first1, _InputIterator __last1, + _InputIterator __first2, _InputIterator __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + return _GLIBCXX_MOVE3(__first2, __last2, + _GLIBCXX_MOVE3(__first1, __last1, + __result)); + } + + template + void + __merge_sort_loop(_RandomAccessIterator1 __first, + _RandomAccessIterator1 __last, + _RandomAccessIterator2 __result, _Distance __step_size, + _Compare __comp) + { + const _Distance __two_step = 2 * __step_size; + + while (__last - __first >= __two_step) + { + __result = std::__move_merge(__first, __first + __step_size, + __first + __step_size, + __first + __two_step, + __result, __comp); + __first += __two_step; + } + __step_size = std::min(_Distance(__last - __first), __step_size); + + std::__move_merge(__first, __first + __step_size, + __first + __step_size, __last, __result, __comp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __chunk_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Distance __chunk_size, _Compare __comp) + { + while (__last - __first >= __chunk_size) + { + std::__insertion_sort(__first, __first + __chunk_size, __comp); + __first += __chunk_size; + } + std::__insertion_sort(__first, __last, __comp); + } + + enum { _S_chunk_size = 7 }; + + template + void + __merge_sort_with_buffer(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Pointer __buffer, _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _Distance; + + const _Distance __len = __last - __first; + const _Pointer __buffer_last = __buffer + __len; + + _Distance __step_size = _S_chunk_size; + std::__chunk_insertion_sort(__first, __last, __step_size, __comp); + + while (__step_size < __len) + { + std::__merge_sort_loop(__first, __last, __buffer, + __step_size, __comp); + __step_size *= 2; + std::__merge_sort_loop(__buffer, __buffer_last, __first, + __step_size, __comp); + __step_size *= 2; + } + } + + template + void + __stable_sort_adaptive(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Pointer __buffer, _Distance __buffer_size, + _Compare __comp) + { + const _Distance __len = (__last - __first + 1) / 2; + const _RandomAccessIterator __middle = __first + __len; + if (__len > __buffer_size) + { + std::__stable_sort_adaptive(__first, __middle, __buffer, + __buffer_size, __comp); + std::__stable_sort_adaptive(__middle, __last, __buffer, + __buffer_size, __comp); + } + else + { + std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp); + std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp); + } + + std::__merge_adaptive(__first, __middle, __last, + _Distance(__middle - __first), + _Distance(__last - __middle), + __buffer, __buffer_size, + __comp); + } + + /// This is a helper function for the stable sorting routines. + template + void + __inplace_stable_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__last - __first < 15) + { + std::__insertion_sort(__first, __last, __comp); + return; + } + _RandomAccessIterator __middle = __first + (__last - __first) / 2; + std::__inplace_stable_sort(__first, __middle, __comp); + std::__inplace_stable_sort(__middle, __last, __comp); + std::__merge_without_buffer(__first, __middle, __last, + __middle - __first, + __last - __middle, + __comp); + } + + // stable_sort + + // Set algorithms: includes, set_union, set_intersection, set_difference, + // set_symmetric_difference. All of these algorithms have the precondition + // that their input ranges are sorted and the postcondition that their output + // ranges are sorted. + + template + _GLIBCXX20_CONSTEXPR + bool + __includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + return false; + if (!__comp(__first1, __first2)) + ++__first2; + ++__first1; + } + + return __first2 == __last2; + } + + /** + * @brief Determines whether all elements of a sequence exists in a range. + * @param __first1 Start of search range. + * @param __last1 End of search range. + * @param __first2 Start of sequence + * @param __last2 End of sequence. + * @return True if each element in [__first2,__last2) is contained in order + * within [__first1,__last1). False otherwise. + * @ingroup set_algorithms + * + * This operation expects both [__first1,__last1) and + * [__first2,__last2) to be sorted. Searches for the presence of + * each element in [__first2,__last2) within [__first1,__last1). + * The iterators over each range only move forward, so this is a + * linear algorithm. If an element in [__first2,__last2) is not + * found before the search iterator reaches @p __last2, false is + * returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return std::__includes(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Determines whether all elements of a sequence exists in a range + * using comparison. + * @ingroup set_algorithms + * @param __first1 Start of search range. + * @param __last1 End of search range. + * @param __first2 Start of sequence + * @param __last2 End of sequence. + * @param __comp Comparison function to use. + * @return True if each element in [__first2,__last2) is contained + * in order within [__first1,__last1) according to comp. False + * otherwise. @ingroup set_algorithms + * + * This operation expects both [__first1,__last1) and + * [__first2,__last2) to be sorted. Searches for the presence of + * each element in [__first2,__last2) within [__first1,__last1), + * using comp to decide. The iterators over each range only move + * forward, so this is a linear algorithm. If an element in + * [__first2,__last2) is not found before the search iterator + * reaches @p __last2, false is returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return std::__includes(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + // nth_element + // merge + // set_difference + // set_intersection + // set_union + // stable_sort + // set_symmetric_difference + // min_element + // max_element + + template + _GLIBCXX20_CONSTEXPR + bool + __next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + if (__first == __last) + return false; + _BidirectionalIterator __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) + { + _BidirectionalIterator __ii = __i; + --__i; + if (__comp(__i, __ii)) + { + _BidirectionalIterator __j = __last; + while (!__comp(__i, --__j)) + {} + std::iter_swap(__i, __j); + std::__reverse(__ii, __last, + std::__iterator_category(__first)); + return true; + } + if (__i == __first) + { + std::__reverse(__first, __last, + std::__iterator_category(__first)); + return false; + } + } + } + + /** + * @brief Permute range into the next @e dictionary ordering. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return False if wrapped to first permutation, true otherwise. + * + * Treats all permutations of the range as a set of @e dictionary sorted + * sequences. Permutes the current sequence into the next one of this set. + * Returns true if there are more sequences to generate. If the sequence + * is the largest of the set, the smallest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__next_permutation + (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Permute range into the next @e dictionary ordering using + * comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp A comparison functor. + * @return False if wrapped to first permutation, true otherwise. + * + * Treats all permutations of the range [__first,__last) as a set of + * @e dictionary sorted sequences ordered by @p __comp. Permutes the current + * sequence into the next one of this set. Returns true if there are more + * sequences to generate. If the sequence is the largest of the set, the + * smallest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__next_permutation + (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + bool + __prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + if (__first == __last) + return false; + _BidirectionalIterator __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) + { + _BidirectionalIterator __ii = __i; + --__i; + if (__comp(__ii, __i)) + { + _BidirectionalIterator __j = __last; + while (!__comp(--__j, __i)) + {} + std::iter_swap(__i, __j); + std::__reverse(__ii, __last, + std::__iterator_category(__first)); + return true; + } + if (__i == __first) + { + std::__reverse(__first, __last, + std::__iterator_category(__first)); + return false; + } + } + } + + /** + * @brief Permute range into the previous @e dictionary ordering. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return False if wrapped to last permutation, true otherwise. + * + * Treats all permutations of the range as a set of @e dictionary sorted + * sequences. Permutes the current sequence into the previous one of this + * set. Returns true if there are more sequences to generate. If the + * sequence is the smallest of the set, the largest is generated and false + * returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__prev_permutation(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Permute range into the previous @e dictionary ordering using + * comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp A comparison functor. + * @return False if wrapped to last permutation, true otherwise. + * + * Treats all permutations of the range [__first,__last) as a set of + * @e dictionary sorted sequences ordered by @p __comp. Permutes the current + * sequence into the previous one of this set. Returns true if there are + * more sequences to generate. If the sequence is the smallest of the set, + * the largest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__prev_permutation(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + // replace + // replace_if + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __replace_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _Predicate __pred, const _Tp& __new_value) + { + for (; __first != __last; ++__first, (void)++__result) + if (__pred(__first)) + *__result = __new_value; + else + *__result = *__first; + return __result; + } + + /** + * @brief Copy a sequence, replacing each element of one value with another + * value. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __old_value The value to be replaced. + * @param __new_value The replacement value. + * @return The end of the output sequence, @p result+(last-first). + * + * Copies each element in the input range @p [__first,__last) to the + * output range @p [__result,__result+(__last-__first)) replacing elements + * equal to @p __old_value with @p __new_value. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + replace_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + const _Tp& __old_value, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__replace_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__iter_equals_val(__old_value), + __new_value); + } + + /** + * @brief Copy a sequence, replacing each value for which a predicate + * returns true with another value. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @param __new_value The replacement value. + * @return The end of the output sequence, @p __result+(__last-__first). + * + * Copies each element in the range @p [__first,__last) to the range + * @p [__result,__result+(__last-__first)) replacing elements for which + * @p __pred returns true with @p __new_value. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + replace_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _Predicate __pred, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__replace_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__pred_iter(__pred), + __new_value); + } + +#if __cplusplus >= 201103L + /** + * @brief Determines whether the elements of a sequence are sorted. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return True if the elements are sorted, false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_sorted(_ForwardIterator __first, _ForwardIterator __last) + { return std::is_sorted_until(__first, __last) == __last; } + + /** + * @brief Determines whether the elements of a sequence are sorted + * according to a comparison functor. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return True if the elements are sorted, false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_sorted(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { return std::is_sorted_until(__first, __last, __comp) == __last; } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) + return __last; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (__comp(__next, __first)) + return __next; + return __next; + } + + /** + * @brief Determines the end of a sorted sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return An iterator pointing to the last iterator i in [__first, __last) + * for which the range [__first, i) is sorted. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__is_sorted_until(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Determines the end of a sorted sequence using comparison functor. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return An iterator pointing to the last iterator i in [__first, __last) + * for which the range [__first, i) is sorted. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__is_sorted_until(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Determines min and max at once as an ordered pair. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return A pair(__b, __a) if __b is smaller than __a, pair(__a, + * __b) otherwise. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair + minmax(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + + return __b < __a ? pair(__b, __a) + : pair(__a, __b); + } + + /** + * @brief Determines min and max at once as an ordered pair. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor @endlink. + * @return A pair(__b, __a) if __b is smaller than __a, pair(__a, + * __b) otherwise. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair + minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + return __comp(__b, __a) ? pair(__b, __a) + : pair(__a, __b); + } + + template + _GLIBCXX14_CONSTEXPR + pair<_ForwardIterator, _ForwardIterator> + __minmax_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + _ForwardIterator __next = __first; + if (__first == __last + || ++__next == __last) + return std::make_pair(__first, __first); + + _ForwardIterator __min{}, __max{}; + if (__comp(__next, __first)) + { + __min = __next; + __max = __first; + } + else + { + __min = __first; + __max = __next; + } + + __first = __next; + ++__first; + + while (__first != __last) + { + __next = __first; + if (++__next == __last) + { + if (__comp(__first, __min)) + __min = __first; + else if (!__comp(__first, __max)) + __max = __first; + break; + } + + if (__comp(__next, __first)) + { + if (__comp(__next, __min)) + __min = __next; + if (!__comp(__first, __max)) + __max = __first; + } + else + { + if (__comp(__first, __min)) + __min = __first; + if (!__comp(__next, __max)) + __max = __next; + } + + __first = __next; + ++__first; + } + + return std::make_pair(__min, __max); + } + + /** + * @brief Return a pair of iterators pointing to the minimum and maximum + * elements in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return make_pair(m, M), where m is the first iterator i in + * [__first, __last) such that no other element in the range is + * smaller, and where M is the last iterator i in [__first, __last) + * such that no other element in the range is larger. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + minmax_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__minmax_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return a pair of iterators pointing to the minimum and maximum + * elements in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return make_pair(m, M), where m is the first iterator i in + * [__first, __last) such that no other element in the range is + * smaller, and where M is the last iterator i in [__first, __last) + * such that no other element in the range is larger. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + minmax_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__minmax_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l) + { + __glibcxx_requires_irreflexive(__l.begin(), __l.end()); + pair __p = + std::__minmax_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_less_iter()); + return std::make_pair(*__p.first, *__p.second); + } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l, _Compare __comp) + { + __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp); + pair __p = + std::__minmax_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + return std::make_pair(*__p.first, *__p.second); + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __pred A binary predicate. + * @return true if there exists a permutation of the elements in + * the range [__first2, __first2 + (__last1 - __first1)), + * beginning with ForwardIterator2 begin, such that + * equal(__first1, __last1, __begin, __pred) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _BinaryPredicate __pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return std::__is_permutation(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_comp_iter(__pred)); + } + +#if __cplusplus > 201103L + template + _GLIBCXX20_CONSTEXPR + bool + __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) + { + using _Cat1 + = typename iterator_traits<_ForwardIterator1>::iterator_category; + using _Cat2 + = typename iterator_traits<_ForwardIterator2>::iterator_category; + using _It1_is_RA = is_same<_Cat1, random_access_iterator_tag>; + using _It2_is_RA = is_same<_Cat2, random_access_iterator_tag>; + constexpr bool __ra_iters = _It1_is_RA() && _It2_is_RA(); + if (__ra_iters) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + } + + // Efficiently compare identical prefixes: O(N) if sequences + // have the same elements in the same order. + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!__pred(__first1, __first2)) + break; + + if (__ra_iters) + { + if (__first1 == __last1) + return true; + } + else + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 == 0 && __d2 == 0) + return true; + if (__d1 != __d2) + return false; + } + + for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) + { + if (__scan != std::__find_if(__first1, __scan, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) + continue; // We've seen this one before. + + auto __matches = std::__count_if(__first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); + if (0 == __matches + || std::__count_if(__scan, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) + != __matches) + return false; + } + return true; + } + + /** + * @brief Checks whether a permutaion of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of first range. + * @return true if there exists a permutation of the elements in the range + * [__first2, __last2), beginning with ForwardIterator2 begin, + * such that equal(__first1, __last1, begin) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return + std::__is_permutation(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of first range. + * @param __pred A binary predicate. + * @return true if there exists a permutation of the elements in the range + * [__first2, __last2), beginning with ForwardIterator2 begin, + * such that equal(__first1, __last1, __begin, __pred) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__is_permutation(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred)); + } + +#if __cplusplus >= 201703L + +#define __cpp_lib_clamp 201603L + + /** + * @brief Returns the value clamped between lo and hi. + * @ingroup sorting_algorithms + * @param __val A value of arbitrary type. + * @param __lo A lower limit of arbitrary type. + * @param __hi An upper limit of arbitrary type. + * @retval `__lo` if `__val < __lo` + * @retval `__hi` if `__hi < __val` + * @retval `__val` otherwise. + * @pre `_Tp` is LessThanComparable and `(__hi < __lo)` is false. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi) + { + __glibcxx_assert(!(__hi < __lo)); + return std::min(std::max(__val, __lo), __hi); + } + + /** + * @brief Returns the value clamped between lo and hi. + * @ingroup sorting_algorithms + * @param __val A value of arbitrary type. + * @param __lo A lower limit of arbitrary type. + * @param __hi An upper limit of arbitrary type. + * @param __comp A comparison functor. + * @retval `__lo` if `__comp(__val, __lo)` + * @retval `__hi` if `__comp(__hi, __val)` + * @retval `__val` otherwise. + * @pre `__comp(__hi, __lo)` is false. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp) + { + __glibcxx_assert(!__comp(__hi, __lo)); + return std::min(std::max(__val, __lo, __comp), __hi, __comp); + } +#endif // C++17 +#endif // C++14 + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + /** + * @brief Generate two uniformly distributed integers using a + * single distribution invocation. + * @param __b0 The upper bound for the first integer. + * @param __b1 The upper bound for the second integer. + * @param __g A UniformRandomBitGenerator. + * @return A pair (i, j) with i and j uniformly distributed + * over [0, __b0) and [0, __b1), respectively. + * + * Requires: __b0 * __b1 <= __g.max() - __g.min(). + * + * Using uniform_int_distribution with a range that is very + * small relative to the range of the generator ends up wasting + * potentially expensively generated randomness, since + * uniform_int_distribution does not store leftover randomness + * between invocations. + * + * If we know we want two integers in ranges that are sufficiently + * small, we can compose the ranges, use a single distribution + * invocation, and significantly reduce the waste. + */ + template + pair<_IntType, _IntType> + __gen_two_uniform_ints(_IntType __b0, _IntType __b1, + _UniformRandomBitGenerator&& __g) + { + _IntType __x + = uniform_int_distribution<_IntType>{0, (__b0 * __b1) - 1}(__g); + return std::make_pair(__x / __b1, __x % __b1); + } + + /** + * @brief Shuffle the elements of a sequence using a uniform random + * number generator. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __g A UniformRandomNumberGenerator (26.5.1.3). + * @return Nothing. + * + * Reorders the elements in the range @p [__first,__last) using @p __g to + * provide random numbers. + */ + template + void + shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, + _UniformRandomNumberGenerator&& __g) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return; + + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + typedef typename std::make_unsigned<_DistanceType>::type __ud_type; + typedef typename std::uniform_int_distribution<__ud_type> __distr_type; + typedef typename __distr_type::param_type __p_type; + + typedef typename remove_reference<_UniformRandomNumberGenerator>::type + _Gen; + typedef typename common_type::type + __uc_type; + + const __uc_type __urngrange = __g.max() - __g.min(); + const __uc_type __urange = __uc_type(__last - __first); + + if (__urngrange / __urange >= __urange) + // I.e. (__urngrange >= __urange * __urange) but without wrap issues. + { + _RandomAccessIterator __i = __first + 1; + + // Since we know the range isn't empty, an even number of elements + // means an uneven number of elements /to swap/, in which case we + // do the first one up front: + + if ((__urange % 2) == 0) + { + __distr_type __d{0, 1}; + std::iter_swap(__i++, __first + __d(__g)); + } + + // Now we know that __last - __i is even, so we do the rest in pairs, + // using a single distribution invocation to produce swap positions + // for two successive elements at a time: + + while (__i != __last) + { + const __uc_type __swap_range = __uc_type(__i - __first) + 1; + + const pair<__uc_type, __uc_type> __pospos = + __gen_two_uniform_ints(__swap_range, __swap_range + 1, __g); + + std::iter_swap(__i++, __first + __pospos.first); + std::iter_swap(__i++, __first + __pospos.second); + } + + return; + } + + __distr_type __d; + + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first))); + } +#endif // USE C99_STDINT + +#endif // C++11 + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + /** + * @brief Apply a function to every element of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __f A unary function object. + * @return @p __f + * + * Applies the function object @p __f to each element in the range + * @p [first,last). @p __f must not modify the order of the sequence. + * If @p __f has a return value it is ignored. + */ + template + _GLIBCXX20_CONSTEXPR + _Function + for_each(_InputIterator __first, _InputIterator __last, _Function __f) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + for (; __first != __last; ++__first) + __f(*__first); + return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant. + } + +#if __cplusplus >= 201703L + /** + * @brief Apply a function to every element of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __n A value convertible to an integer. + * @param __f A unary function object. + * @return `__first+__n` + * + * Applies the function object `__f` to each element in the range + * `[first, first+n)`. `__f` must not modify the order of the sequence. + * If `__f` has a return value it is ignored. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + for_each_n(_InputIterator __first, _Size __n, _Function __f) + { + auto __n2 = std::__size_to_integer(__n); + using _Cat = typename iterator_traits<_InputIterator>::iterator_category; + if constexpr (is_base_of_v) + { + if (__n2 <= 0) + return __first; + auto __last = __first + __n2; + std::for_each(__first, __last, std::move(__f)); + return __last; + } + else + { + while (__n2-->0) + { + __f(*__first); + ++__first; + } + return __first; + } + } +#endif // C++17 + + /** + * @brief Find the first occurrence of a value in a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __val The value to find. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @c *i == @p __val, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find(_InputIterator __first, _InputIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__val)); + } + + /** + * @brief Find the first element in a sequence for which a + * predicate is true. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @p __pred(*i) is true, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find_if(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Find element from a set in a sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of match candidates. + * @param __last2 End of match candidates. + * @return The first iterator @c i in the range + * @p [__first1,__last1) such that @c *i == @p *(i2) such that i2 is an + * iterator in [__first2,__last2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for an element that is + * equal to some element in the range [__first2,__last2). If + * found, returns an iterator in the range [__first1,__last1), + * otherwise returns @p __last1. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + find_first_of(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, _ForwardIterator __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + for (; __first1 != __last1; ++__first1) + for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) + if (*__first1 == *__iter) + return __first1; + return __last1; + } + + /** + * @brief Find element from a set in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of match candidates. + * @param __last2 End of match candidates. + * @param __comp Predicate to use. + * @return The first iterator @c i in the range + * @p [__first1,__last1) such that @c comp(*i, @p *(i2)) is true + * and i2 is an iterator in [__first2,__last2), or @p __last1 if no + * such iterator exists. + * + + * Searches the range @p [__first1,__last1) for an element that is + * equal to some element in the range [__first2,__last2). If + * found, returns an iterator in the range [__first1,__last1), + * otherwise returns @p __last1. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + find_first_of(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, _ForwardIterator __last2, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + for (; __first1 != __last1; ++__first1) + for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) + if (__comp(*__first1, *__iter)) + return __first1; + return __last1; + } + + /** + * @brief Find two adjacent values in a sequence that are equal. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return The first iterator @c i such that @c i and @c i+1 are both + * valid iterators in @p [__first,__last) and such that @c *i == @c *(i+1), + * or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + adjacent_find(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__adjacent_find(__first, __last, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Find two adjacent values in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __binary_pred A binary predicate. + * @return The first iterator @c i such that @c i and @c i+1 are both + * valid iterators in @p [__first,__last) and such that + * @p __binary_pred(*i,*(i+1)) is true, or @p __last if no such iterator + * exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + adjacent_find(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__adjacent_find(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + + /** + * @brief Count the number of copies of a value in a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __value The value to be counted. + * @return The number of iterators @c i in the range @p [__first,__last) + * for which @c *i == @p __value + */ + template + _GLIBCXX20_CONSTEXPR + inline typename iterator_traits<_InputIterator>::difference_type + count(_InputIterator __first, _InputIterator __last, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__count_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Count the elements of a sequence for which a predicate is true. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The number of iterators @c i in the range @p [__first,__last) + * for which @p __pred(*i) is true. + */ + template + _GLIBCXX20_CONSTEXPR + inline typename iterator_traits<_InputIterator>::difference_type + count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__count_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Search a sequence for a matching sub-sequence. + * @ingroup non_mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @param __last2 A forward iterator. + * @return The first iterator @c i in the range @p + * [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == @p + * *(__first2+N) for each @c N in the range @p + * [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) and returns an iterator to the first element + * of the sub-sequence, or @p __last1 if the sub-sequence is not + * found. + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. + * + * This means that the returned iterator @c i will be in the range + * @p [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__search(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Search a sequence for a matching sub-sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @param __last2 A forward iterator. + * @param __predicate A binary predicate. + * @return The first iterator @c i in the range + * @p [__first1,__last1-(__last2-__first2)) such that + * @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range + * @p [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2), using @p __predicate to determine equality, + * and returns an iterator to the first element of the + * sub-sequence, or @p __last1 if no such iterator exists. + * + * @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __predicate) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__search(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__predicate)); + } + + /** + * @brief Search a sequence for a number of consecutive values. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __count The number of consecutive values. + * @param __val The value to find. + * @return The first iterator @c i in the range @p + * [__first,__last-__count) such that @c *(i+N) == @p __val for + * each @c N in the range @p [0,__count), or @p __last if no such + * iterator exists. + * + * Searches the range @p [__first,__last) for @p count consecutive elements + * equal to @p __val. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__search_n(__first, __last, __count, + __gnu_cxx::__ops::__iter_equals_val(__val)); + } + + + /** + * @brief Search a sequence for a number of consecutive values using a + * predicate. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __count The number of consecutive values. + * @param __val The value to find. + * @param __binary_pred A binary predicate. + * @return The first iterator @c i in the range @p + * [__first,__last-__count) such that @p + * __binary_pred(*(i+N),__val) is true for each @c N in the range + * @p [0,__count), or @p __last if no such iterator exists. + * + * Searches the range @p [__first,__last) for @p __count + * consecutive elements for which the predicate returns true. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__search_n(__first, __last, __count, + __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val)); + } + +#if __cplusplus >= 201703L + /** @brief Search a sequence using a Searcher object. + * + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __searcher A callable object. + * @return @p __searcher(__first,__last).first + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search(_ForwardIterator __first, _ForwardIterator __last, + const _Searcher& __searcher) + { return __searcher(__first, __last).first; } +#endif + + /** + * @brief Perform an operation on a sequence. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __unary_op A unary operator. + * @return An output iterator equal to @p __result+(__last-__first). + * + * Applies the operator to each element in the input range and assigns + * the results to successive elements of the output sequence. + * Evaluates @p *(__result+N)=unary_op(*(__first+N)) for each @c N in the + * range @p [0,__last-__first). + * + * @p unary_op must not alter its argument. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _UnaryOperation __unary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _UnaryOperation" + __typeof__(__unary_op(*__first))>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first, (void)++__result) + *__result = __unary_op(*__first); + return __result; + } + + /** + * @brief Perform an operation on corresponding elements of two sequences. + * @ingroup mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __result An output iterator. + * @param __binary_op A binary operator. + * @return An output iterator equal to @p result+(last-first). + * + * Applies the operator to the corresponding elements in the two + * input ranges and assigns the results to successive elements of the + * output sequence. + * Evaluates @p + * *(__result+N)=__binary_op(*(__first1+N),*(__first2+N)) for each + * @c N in the range @p [0,__last1-__first1). + * + * @p binary_op must not alter either of its arguments. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _OutputIterator __result, + _BinaryOperation __binary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _BinaryOperation" + __typeof__(__binary_op(*__first1,*__first2))>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result) + *__result = __binary_op(*__first1, *__first2); + return __result; + } + + /** + * @brief Replace each occurrence of one value in a sequence with another + * value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __old_value The value to be replaced. + * @param __new_value The replacement value. + * @return replace() returns no value. + * + * For each iterator @c i in the range @p [__first,__last) if @c *i == + * @p __old_value then the assignment @c *i = @p __new_value is performed. + */ + template + _GLIBCXX20_CONSTEXPR + void + replace(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __old_value, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (*__first == __old_value) + *__first = __new_value; + } + + /** + * @brief Replace each value in a sequence for which a predicate returns + * true with another value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate. + * @param __new_value The replacement value. + * @return replace_if() returns no value. + * + * For each iterator @c i in the range @p [__first,__last) if @p __pred(*i) + * is true then the assignment @c *i = @p __new_value is performed. + */ + template + _GLIBCXX20_CONSTEXPR + void + replace_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + *__first = __new_value; + } + + /** + * @brief Assign the result of a function object to each value in a + * sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __gen A function object taking no arguments and returning + * std::iterator_traits<_ForwardIterator>::value_type + * @return generate() returns no value. + * + * Performs the assignment @c *i = @p __gen() for each @c i in the range + * @p [__first,__last). + */ + template + _GLIBCXX20_CONSTEXPR + void + generate(_ForwardIterator __first, _ForwardIterator __last, + _Generator __gen) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_GeneratorConcept<_Generator, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + *__first = __gen(); + } + + /** + * @brief Assign the result of a function object to each value in a + * sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __n The length of the sequence. + * @param __gen A function object taking no arguments and returning + * std::iterator_traits<_ForwardIterator>::value_type + * @return The end of the sequence, @p __first+__n + * + * Performs the assignment @c *i = @p __gen() for each @c i in the range + * @p [__first,__first+__n). + * + * If @p __n is negative, the function does nothing and returns @p __first. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 865. More algorithms that throw away information + // DR 426. search_n(), fill_n(), and generate_n() with negative n + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + generate_n(_OutputIterator __first, _Size __n, _Generator __gen) + { + // concept requirements + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _Generator" + __typeof__(__gen())>) + + typedef __decltype(std::__size_to_integer(__n)) _IntSize; + for (_IntSize __niter = std::__size_to_integer(__n); + __niter > 0; --__niter, (void) ++__first) + *__first = __gen(); + return __first; + } + + /** + * @brief Copy a sequence, removing consecutive duplicate values. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) to the range + * beginning at @p __result, except that only the first element is copied + * from groups of consecutive elements that compare equal. + * unique_copy() is stable, so the relative order of elements that are + * copied is unchanged. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 538. 241 again: Does unique_copy() require CopyConstructible and + * Assignable? + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, + __gnu_cxx::__ops::__iter_equal_to_iter(), + std::__iterator_category(__first), + std::__iterator_category(__result)); + } + + /** + * @brief Copy a sequence, removing consecutive values using a predicate. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __binary_pred A binary predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) to the range + * beginning at @p __result, except that only the first element is copied + * from groups of consecutive elements for which @p __binary_pred returns + * true. + * unique_copy() is stable, so the relative order of elements that are + * copied is unchanged. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _BinaryPredicate __binary_pred) + { + // concept requirements -- predicates checked later + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred), + std::__iterator_category(__first), + std::__iterator_category(__result)); + } + +#if __cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED +#if _GLIBCXX_HOSTED + /** + * @brief Randomly shuffle the elements of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return Nothing. + * + * Reorder the elements in the range @p [__first,__last) using a random + * distribution, so that every possible ordering of the sequence is + * equally likely. + * + * @deprecated + * Since C++14 `std::random_shuffle` is not part of the C++ standard. + * Use `std::shuffle` instead, which was introduced in C++11. + */ + template + _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle") + inline void + random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first != __last) + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + // XXX rand() % N is not uniformly distributed + _RandomAccessIterator __j = __first + + std::rand() % ((__i - __first) + 1); + if (__i != __j) + std::iter_swap(__i, __j); + } + } +#endif + + /** + * @brief Shuffle the elements of a sequence using a random number + * generator. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __rand The RNG functor or function. + * @return Nothing. + * + * Reorders the elements in the range @p [__first,__last) using @p __rand to + * provide a random distribution. Calling @p __rand(N) for a positive + * integer @p N should return a randomly chosen integer from the + * range [0,N). + * + * @deprecated + * Since C++14 `std::random_shuffle` is not part of the C++ standard. + * Use `std::shuffle` instead, which was introduced in C++11. + */ + template + _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle") + void + random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, +#if __cplusplus >= 201103L + _RandomNumberGenerator&& __rand) +#else + _RandomNumberGenerator& __rand) +#endif + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return; + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + _RandomAccessIterator __j = __first + __rand((__i - __first) + 1); + if (__i != __j) + std::iter_swap(__i, __j); + } + } +#endif // C++11 || USE_DEPRECATED + + /** + * @brief Move elements for which a predicate is true to the beginning + * of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate functor. + * @return An iterator @p middle such that @p __pred(i) is true for each + * iterator @p i in the range @p [__first,middle) and false for each @p i + * in the range @p [middle,__last). + * + * @p __pred must not modify its operand. @p partition() does not preserve + * the relative ordering of elements in each group, use + * @p stable_partition() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__partition(__first, __last, __pred, + std::__iterator_category(__first)); + } + + + /** + * @brief Sort the smallest elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the smallest @p (__middle-__first) elements in the range + * @p [first,last) and moves them to the range @p [__first,__middle). The + * order of the remaining elements in the range @p [__middle,__last) is + * undefined. + * After the sort if @e i and @e j are iterators in the range + * @p [__first,__middle) such that i precedes j and @e k is an iterator in + * the range @p [__middle,__last) then *j<*i and *k<*i are both false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__partial_sort(__first, __middle, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the smallest elements of a sequence using a predicate + * for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the smallest @p (__middle-__first) elements in the range + * @p [__first,__last) and moves them to the range @p [__first,__middle). The + * order of the remaining elements in the range @p [__middle,__last) is + * undefined. + * After the sort if @e i and @e j are iterators in the range + * @p [__first,__middle) such that i precedes j and @e k is an iterator in + * the range @p [__middle,__last) then @p *__comp(j,*i) and @p __comp(*k,*i) + * are both false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__partial_sort(__first, __middle, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Sort a sequence just enough to find a particular position. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __nth Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Rearranges the elements in the range @p [__first,__last) so that @p *__nth + * is the same element that would have been in that position had the + * whole sequence been sorted. The elements either side of @p *__nth are + * not completely sorted, but for any iterator @e i in the range + * @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it + * holds that *j < *i is false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __nth); + __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive(__first, __last); + + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort a sequence just enough to find a particular position + * using a predicate for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __nth Another iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Rearranges the elements in the range @p [__first,__last) so that @p *__nth + * is the same element that would have been in that position had the + * whole sequence been sorted. The elements either side of @p *__nth are + * not completely sorted, but for any iterator @e i in the range + * @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it + * holds that @p __comp(*j,*i) is false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __nth); + __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Sort the elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @e i in the range @p [__first,__last-1), + * *(i+1)<*i is false. + * + * The relative ordering of equivalent elements is not preserved, use + * @p stable_sort() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the elements of a sequence using a predicate for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that @p __comp(*(i+1),*i) is false for every iterator @e i in the + * range @p [__first,__last-1). + * + * The relative ordering of equivalent elements is not preserved, use + * @p stable_sort() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + } + ++__result; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Merges two sorted ranges. + * @ingroup sorting_algorithms + * @param __first1 An iterator. + * @param __first2 Another iterator. + * @param __last1 Another iterator. + * @param __last2 Another iterator. + * @param __result An iterator pointing to the end of the merged range. + * @return An output iterator equal to @p __result + (__last1 - __first1) + * + (__last2 - __first2). + * + * Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into + * the sorted range @p [__result, __result + (__last1-__first1) + + * (__last2-__first2)). Both input ranges must be sorted, and the + * output range must not overlap with either of the input ranges. + * The sort is @e stable, that is, for equivalent elements in the + * two ranges, elements from the first range will always come + * before elements from the second. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__merge(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Merges two sorted ranges. + * @ingroup sorting_algorithms + * @param __first1 An iterator. + * @param __first2 Another iterator. + * @param __last1 Another iterator. + * @param __last2 Another iterator. + * @param __result An iterator pointing to the end of the merged range. + * @param __comp A functor to use for comparisons. + * @return An output iterator equal to @p __result + (__last1 - __first1) + * + (__last2 - __first2). + * + * Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into + * the sorted range @p [__result, __result + (__last1-__first1) + + * (__last2-__first2)). Both input ranges must be sorted, and the + * output range must not overlap with either of the input ranges. + * The sort is @e stable, that is, for equivalent elements in the + * two ranges, elements from the first range will always come + * before elements from the second. + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__merge(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + inline void + __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf; + + if (__first == __last) + return; + + // __stable_sort_adaptive sorts the range in two halves, + // so the buffer only needs to fit half the range at once. + _TmpBuf __buf(__first, (__last - __first + 1) / 2); + + if (__buf.begin() == 0) + std::__inplace_stable_sort(__first, __last, __comp); + else + std::__stable_sort_adaptive(__first, __last, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + /** + * @brief Sort the elements of a sequence, preserving the relative order + * of equivalent elements. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @p i in the range @p [__first,__last-1), + * @p *(i+1)<*i is false. + * + * The relative ordering of equivalent elements is preserved, so any two + * elements @p x and @p y in the range @p [__first,__last) such that + * @p x + inline void + stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + _GLIBCXX_STD_A::__stable_sort(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the elements of a sequence using a predicate for comparison, + * preserving the relative order of equivalent elements. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @p i in the range @p [__first,__last-1), + * @p __comp(*(i+1),*i) is false. + * + * The relative ordering of equivalent elements is preserved, so any two + * elements @p x and @p y in the range @p [__first,__last) such that + * @p __comp(x,y) is false and @p __comp(y,x) is false will have the same + * relative ordering after calling @p stable_sort(). + */ + template + inline void + stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + _GLIBCXX_STD_A::__stable_sort(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + } + else if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + ++__first2; + } + ++__result; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Return the union of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * each range in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other, + * that element is copied and the iterator advanced. If an element is + * contained in both ranges, the element from the first range is copied and + * both ranges advance. The output range may not overlap either input + * range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_union(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the union of two sorted ranges using a comparison functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * each range in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other + * according to @p __comp, that element is copied and the iterator advanced. + * If an equivalent element according to @p __comp is contained in both + * ranges, the element from the first range is copied and both ranges + * advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_union(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + ++__first1; + else if (__comp(__first2, __first1)) + ++__first2; + else + { + *__result = *__first1; + ++__first1; + ++__first2; + ++__result; + } + return __result; + } + + /** + * @brief Return the intersection of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * both ranges in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other, + * that iterator advances. If an element is contained in both ranges, the + * element from the first range is copied and both ranges advance. The + * output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the intersection of two sorted ranges using comparison + * functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * both ranges in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other + * according to @p __comp, that iterator advances. If an element is + * contained in both ranges according to @p __comp, the element from the + * first range is copied and both ranges advance. The output range may not + * overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(__first2, __first1)) + ++__first2; + else + { + ++__first1; + ++__first2; + } + return std::copy(__first1, __last1, __result); + } + + /** + * @brief Return the difference of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * the first range but not the second in order to the output range. + * Iterators increment for each range. When the current element of the + * first range is less than the second, that element is copied and the + * iterator advances. If the current element of the second range is less, + * the iterator advances, but no element is copied. If an element is + * contained in both ranges, no elements are copied and both ranges + * advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the difference of two sorted ranges using comparison + * functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * the first range but not the second in order to the output range. + * Iterators increment for each range. When the current element of the + * first range is less than the second according to @p __comp, that element + * is copied and the iterator advances. If the current element of the + * second range is less, no element is copied and the iterator advances. + * If an element is contained in both ranges according to @p __comp, no + * elements are copied and both ranges advance. The output range may not + * overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_symmetric_difference(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _OutputIterator __result, + _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + ++__result; + } + else + { + ++__first1; + ++__first2; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Return the symmetric difference of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * one range but not the other in order to the output range. Iterators + * increment for each range. When the current element of one range is less + * than the other, that element is copied and the iterator advances. If an + * element is contained in both ranges, no elements are copied and both + * ranges advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the symmetric difference of two sorted ranges using + * comparison functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * one range but not the other in order to the output range. Iterators + * increment for each range. When the current element of one range is less + * than the other according to @p comp, that element is copied and the + * iterator advances. If an element is contained in both ranges according + * to @p __comp, no elements are copied and both ranges advance. The output + * range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + __min_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) + return __first; + _ForwardIterator __result = __first; + while (++__first != __last) + if (__comp(__first, __result)) + __result = __first; + return __result; + } + + /** + * @brief Return the minimum element in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return Iterator referencing the first instance of the smallest value. + */ + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + inline min_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return _GLIBCXX_STD_A::__min_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the minimum element in a range using comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return Iterator referencing the first instance of the smallest value + * according to __comp. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + min_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return _GLIBCXX_STD_A::__min_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + __max_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) return __first; + _ForwardIterator __result = __first; + while (++__first != __last) + if (__comp(__result, __first)) + __result = __first; + return __result; + } + + /** + * @brief Return the maximum element in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return Iterator referencing the first instance of the largest value. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + max_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return _GLIBCXX_STD_A::__max_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the maximum element in a range using comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return Iterator referencing the first instance of the largest value + * according to __comp. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + max_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return _GLIBCXX_STD_A::__max_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cplusplus >= 201103L + // N2722 + DR 915. + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l) + { + __glibcxx_requires_irreflexive(__l.begin(), __l.end()); + return *_GLIBCXX_STD_A::__min_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_less_iter()); + } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l, _Compare __comp) + { + __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp); + return *_GLIBCXX_STD_A::__min_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l) + { + __glibcxx_requires_irreflexive(__l.begin(), __l.end()); + return *_GLIBCXX_STD_A::__max_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_less_iter()); + } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l, _Compare __comp) + { + __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp); + return *_GLIBCXX_STD_A::__max_element(__l.begin(), __l.end(), + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } +#endif // C++11 + +#if __cplusplus >= 201402L + /// Reservoir sampling algorithm. + template + _RandomAccessIterator + __sample(_InputIterator __first, _InputIterator __last, input_iterator_tag, + _RandomAccessIterator __out, random_access_iterator_tag, + _Size __n, _UniformRandomBitGenerator&& __g) + { + using __distrib_type = uniform_int_distribution<_Size>; + using __param_type = typename __distrib_type::param_type; + __distrib_type __d{}; + _Size __sample_sz = 0; + while (__first != __last && __sample_sz != __n) + { + __out[__sample_sz++] = *__first; + ++__first; + } + for (auto __pop_sz = __sample_sz; __first != __last; + ++__first, (void) ++__pop_sz) + { + const auto __k = __d(__g, __param_type{0, __pop_sz}); + if (__k < __n) + __out[__k] = *__first; + } + return __out + __sample_sz; + } + + /// Selection sampling algorithm. + template + _OutputIterator + __sample(_ForwardIterator __first, _ForwardIterator __last, + forward_iterator_tag, + _OutputIterator __out, _Cat, + _Size __n, _UniformRandomBitGenerator&& __g) + { + using __distrib_type = uniform_int_distribution<_Size>; + using __param_type = typename __distrib_type::param_type; + using _USize = make_unsigned_t<_Size>; + using _Gen = remove_reference_t<_UniformRandomBitGenerator>; + using __uc_type = common_type_t; + + if (__first == __last) + return __out; + + __distrib_type __d{}; + _Size __unsampled_sz = std::distance(__first, __last); + __n = std::min(__n, __unsampled_sz); + + // If possible, we use __gen_two_uniform_ints to efficiently produce + // two random numbers using a single distribution invocation: + + const __uc_type __urngrange = __g.max() - __g.min(); + if (__urngrange / __uc_type(__unsampled_sz) >= __uc_type(__unsampled_sz)) + // I.e. (__urngrange >= __unsampled_sz * __unsampled_sz) but without + // wrapping issues. + { + while (__n != 0 && __unsampled_sz >= 2) + { + const pair<_Size, _Size> __p = + __gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g); + + --__unsampled_sz; + if (__p.first < __n) + { + *__out++ = *__first; + --__n; + } + + ++__first; + + if (__n == 0) break; + + --__unsampled_sz; + if (__p.second < __n) + { + *__out++ = *__first; + --__n; + } + + ++__first; + } + } + + // The loop above is otherwise equivalent to this one-at-a-time version: + + for (; __n != 0; ++__first) + if (__d(__g, __param_type{0, --__unsampled_sz}) < __n) + { + *__out++ = *__first; + --__n; + } + return __out; + } + +#if __cplusplus > 201402L +#define __cpp_lib_sample 201603L + /// Take a random sample from a population. + template + _SampleIterator + sample(_PopulationIterator __first, _PopulationIterator __last, + _SampleIterator __out, _Distance __n, + _UniformRandomBitGenerator&& __g) + { + using __pop_cat = typename + std::iterator_traits<_PopulationIterator>::iterator_category; + using __samp_cat = typename + std::iterator_traits<_SampleIterator>::iterator_category; + + static_assert( + __or_, + is_convertible<__samp_cat, random_access_iterator_tag>>::value, + "output range must use a RandomAccessIterator when input range" + " does not meet the ForwardIterator requirements"); + + static_assert(is_integral<_Distance>::value, + "sample size must be an integer type"); + + typename iterator_traits<_PopulationIterator>::difference_type __d = __n; + return _GLIBCXX_STD_A:: + __sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d, + std::forward<_UniformRandomBitGenerator>(__g)); + } +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_ALGO +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_ALGO_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..0910a8cb93fcc42c8c65b86f0b434792b2ca0dbc Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algo.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h new file mode 100644 index 0000000000000000000000000000000000000000..84a1f9e98f645d2a0eddb1b054fb5502deac7403 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h @@ -0,0 +1,2228 @@ +// Core algorithmic facilities -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_algobase.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _STL_ALGOBASE_H +#define _STL_ALGOBASE_H 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For std::swap +#include +#if __cplusplus >= 201103L +# include +#endif +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /* + * A constexpr wrapper for __builtin_memcmp. + * @param __num The number of elements of type _Tp (not bytes). + */ + template + _GLIBCXX14_CONSTEXPR + inline int + __memcmp(const _Tp* __first1, const _Up* __first2, size_t __num) + { +#if __cplusplus >= 201103L + static_assert(sizeof(_Tp) == sizeof(_Up), "can be compared with memcmp"); +#endif +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for(; __num > 0; ++__first1, ++__first2, --__num) + if (*__first1 != *__first2) + return *__first1 < *__first2 ? -1 : 1; + return 0; + } + else +#endif + return __builtin_memcmp(__first1, __first2, sizeof(_Tp) * __num); + } + +#if __cplusplus < 201103L + // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a + // nutshell, we are partially implementing the resolution of DR 187, + // when it's safe, i.e., the value_types are equal. + template + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + typedef typename iterator_traits<_ForwardIterator1>::value_type + _ValueType1; + _ValueType1 __tmp = *__a; + *__a = *__b; + *__b = __tmp; + } + }; + + template<> + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + swap(*__a, *__b); + } + }; +#endif // C++03 + + /** + * @brief Swaps the contents of two iterators. + * @ingroup mutating_algorithms + * @param __a An iterator. + * @param __b Another iterator. + * @return Nothing. + * + * This function swaps the values pointed to by two iterators, not the + * iterators themselves. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator1>) + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator2>) + +#if __cplusplus < 201103L + typedef typename iterator_traits<_ForwardIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_ForwardIterator2>::value_type + _ValueType2; + + __glibcxx_function_requires(_ConvertibleConcept<_ValueType1, + _ValueType2>) + __glibcxx_function_requires(_ConvertibleConcept<_ValueType2, + _ValueType1>) + + typedef typename iterator_traits<_ForwardIterator1>::reference + _ReferenceType1; + typedef typename iterator_traits<_ForwardIterator2>::reference + _ReferenceType2; + std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value + && __are_same<_ValueType1&, _ReferenceType1>::__value + && __are_same<_ValueType2&, _ReferenceType2>::__value>:: + iter_swap(__a, __b); +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 187. iter_swap underspecified + swap(*__a, *__b); +#endif + } + + /** + * @brief Swap the elements of two sequences. + * @ingroup mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @return An iterator equal to @p first2+(last1-first1). + * + * Swaps each element in the range @p [first1,last1) with the + * corresponding element in the range @p [first2,(last1-first1)). + * The ranges must not overlap. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator2 + swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator1>) + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + std::iter_swap(__first1, __first2); + return __first2; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return The lesser of the parameters. + * + * This is the simple classic generic implementation. It will work on + * temporary expressions, since they are only evaluated once, unlike a + * preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + min(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + //return __b < __a ? __b : __a; + if (__b < __a) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return The greater of the parameters. + * + * This is the simple classic generic implementation. It will work on + * temporary expressions, since they are only evaluated once, unlike a + * preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + max(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + //return __a < __b ? __b : __a; + if (__a < __b) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The lesser of the parameters. + * + * This will work on temporary expressions, since they are only evaluated + * once, unlike a preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + min(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + //return __comp(__b, __a) ? __b : __a; + if (__comp(__b, __a)) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The greater of the parameters. + * + * This will work on temporary expressions, since they are only evaluated + * once, unlike a preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + max(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + //return __comp(__a, __b) ? __b : __a; + if (__comp(__a, __b)) + return __b; + return __a; + } + + // Fallback implementation of the function in bits/stl_iterator.h used to + // remove the __normal_iterator wrapper. See copy, fill, ... + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __niter_base(_Iterator __it) + _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) + { return __it; } + + template + _Ite + __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, + std::random_access_iterator_tag>&); + + // Reverse the __niter_base transformation to get a + // __normal_iterator back again (this assumes that __normal_iterator + // is only used to wrap random access iterators, like pointers). + template + _GLIBCXX20_CONSTEXPR + inline _From + __niter_wrap(_From __from, _To __res) + { return __from + (__res - std::__niter_base(__from)); } + + // No need to wrap, iterator already has the right type. + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __niter_wrap(const _Iterator&, _Iterator __res) + { return __res; } + + // All of these auxiliary structs serve two purposes. (1) Replace + // calls to copy with memmove whenever possible. (Memmove, not memcpy, + // because the input and output ranges are permitted to overlap.) + // (2) If we're using random access iterators, then write the loop as + // a for loop with an explicit count. + + template + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + for (; __first != __last; ++__result, (void)++__first) + *__result = *__first; + return __result; + } + }; + +#if __cplusplus >= 201103L + template + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + for (; __first != __last; ++__result, (void)++__first) + *__result = std::move(*__first); + return __result; + } + }; +#endif + + template<> + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::difference_type _Distance; + for(_Distance __n = __last - __first; __n > 0; --__n) + { + *__result = *__first; + ++__first; + ++__result; + } + return __result; + } + }; + +#if __cplusplus >= 201103L + template<> + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::difference_type _Distance; + for(_Distance __n = __last - __first; __n > 0; --__n) + { + *__result = std::move(*__first); + ++__first; + ++__result; + } + return __result; + } + }; +#endif + + template + struct __copy_move<_IsMove, true, random_access_iterator_tag> + { + template + _GLIBCXX20_CONSTEXPR + static _Tp* + __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) + { +#if __cplusplus >= 201103L + using __assignable = __conditional_t<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::value, "type must be assignable" ); +#endif + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); + return __result + _Num; + } + }; + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + struct _Deque_iterator; + + struct _Bit_iterator; + +_GLIBCXX_END_NAMESPACE_CONTAINER + + // Helpers for streambuf iterators (either istream or ostream). + // NB: avoid including , relatively large. + template + struct char_traits; + + template + class istreambuf_iterator; + + template + class ostreambuf_iterator; + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type + __copy_move_a2(_CharT*, _CharT*, + ostreambuf_iterator<_CharT, char_traits<_CharT> >); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type + __copy_move_a2(const _CharT*, const _CharT*, + ostreambuf_iterator<_CharT, char_traits<_CharT> >); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >, + istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*); + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_move_a2( + istreambuf_iterator<_CharT, char_traits<_CharT> >, + istreambuf_iterator<_CharT, char_traits<_CharT> >, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a2(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::iterator_category _Category; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__copy_move<_IsMove, false, _Category>:: + __copy_m(__first, __last, __result); +#endif + return std::__copy_move<_IsMove, __memcpyable<_OI, _II>::__value, + _Category>::__copy_m(__first, __last, __result); + } + + template + _OI + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _OI); + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_a1(_II, _II, _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a1(_II __first, _II __last, _OI __result) + { return std::__copy_move_a2<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a(_II __first, _II __last, _OI __result) + { + return std::__niter_wrap(__result, + std::__copy_move_a1<_IsMove>(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result))); + } + + template + _OI + __copy_move_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + _OI); + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_a(_II, _II, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_a(const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __copy_n_a(_InputIterator __first, _Size __n, _OutputIterator __result, + bool) + { + if (__n > 0) + { + while (true) + { + *__result = *__first; + ++__result; + if (--__n > 0) + ++__first; + else + break; + } + } + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, _CharT*>::__type + __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT> >, + _Size, _CharT*, bool); + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT> >, _Size, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>, + bool); + + /** + * @brief Copies the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return result + (last - first) + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). Result may not be contained within + * [first,last); the copy_backward function should be used instead. + * + * Note that the end of the output range is permitted to be contained + * within [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OI + copy(_II __first, _II __last, _OI __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II>) + __glibcxx_function_requires(_OutputIteratorConcept<_OI, + typename iterator_traits<_II>::reference>) + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return std::__copy_move_a<__is_move_iterator<_II>::__value> + (std::__miter_base(__first), std::__miter_base(__last), __result); + } + +#if __cplusplus >= 201103L + /** + * @brief Moves the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return result + (last - first) + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). Result may not be contained within + * [first,last); the move_backward function should be used instead. + * + * Note that the end of the output range is permitted to be contained + * within [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OI + move(_II __first, _II __last, _OI __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II>) + __glibcxx_function_requires(_OutputIteratorConcept<_OI, + typename iterator_traits<_II>::value_type&&>) + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return std::__copy_move_a(std::__miter_base(__first), + std::__miter_base(__last), __result); + } + +#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp) +#else +#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp) +#endif + + template + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + while (__first != __last) + *--__result = *--__last; + return __result; + } + }; + +#if __cplusplus >= 201103L + template + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + while (__first != __last) + *--__result = std::move(*--__last); + return __result; + } + }; +#endif + + template<> + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) + *--__result = *--__last; + return __result; + } + }; + +#if __cplusplus >= 201103L + template<> + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) + *--__result = std::move(*--__last); + return __result; + } + }; +#endif + + template + struct __copy_move_backward<_IsMove, true, random_access_iterator_tag> + { + template + _GLIBCXX20_CONSTEXPR + static _Tp* + __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) + { +#if __cplusplus >= 201103L + using __assignable = __conditional_t<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::value, "type must be assignable" ); +#endif + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + return __result - _Num; + } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result) + { + typedef typename iterator_traits<_BI1>::iterator_category _Category; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__copy_move_backward<_IsMove, false, _Category>:: + __copy_move_b(__first, __last, __result); +#endif + return std::__copy_move_backward<_IsMove, + __memcpyable<_BI2, _BI1>::__value, + _Category>::__copy_move_b(__first, + __last, + __result); + } + + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + __copy_move_backward_a1(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_move_backward_a2<_IsMove>(__first, __last, __result); } + + template + _OI + __copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _OI); + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_backward_a1(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_backward_a(_II __first, _II __last, _OI __result) + { + return std::__niter_wrap(__result, + std::__copy_move_backward_a1<_IsMove> + (std::__niter_base(__first), std::__niter_base(__last), + std::__niter_base(__result))); + } + + template + _OI + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + _OI); + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_backward_a(_II, _II, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); + + /** + * @brief Copies the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result A bidirectional iterator. + * @return result - (last - first) + * + * The function has the same effect as copy, but starts at the end of the + * range and works its way to the start, returning the start of the result. + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + * + * Result may not be in the range (first,last]. Use copy instead. Note + * that the start of the output range may overlap [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>) + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>) + __glibcxx_function_requires(_OutputIteratorConcept<_BI2, + typename iterator_traits<_BI1>::reference>) + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return std::__copy_move_backward_a<__is_move_iterator<_BI1>::__value> + (std::__miter_base(__first), std::__miter_base(__last), __result); + } + +#if __cplusplus >= 201103L + /** + * @brief Moves the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result A bidirectional iterator. + * @return result - (last - first) + * + * The function has the same effect as move, but starts at the end of the + * range and works its way to the start, returning the start of the result. + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + * + * Result may not be in the range (first,last]. Use move instead. Note + * that the start of the output range may overlap [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + move_backward(_BI1 __first, _BI1 __last, _BI2 __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>) + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>) + __glibcxx_function_requires(_OutputIteratorConcept<_BI2, + typename iterator_traits<_BI1>::value_type&&>) + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return std::__copy_move_backward_a(std::__miter_base(__first), + std::__miter_base(__last), + __result); + } + +#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp) +#else +#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp) +#endif + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if::__value, void>::__type + __fill_a1(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + for (; __first != __last; ++__first) + *__first = __value; + } + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type + __fill_a1(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __first != __last; ++__first) + *__first = __tmp; + } + + // Specialization: for char types we can use memset. + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type + __fill_a1(_Tp* __first, _Tp* __last, const _Tp& __c) + { + const _Tp __tmp = __c; +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for (; __first != __last; ++__first) + *__first = __tmp; + return; + } +#endif + if (const size_t __len = __last - __first) + __builtin_memset(__first, static_cast(__tmp), __len); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __fill_a1(::__gnu_cxx::__normal_iterator<_Ite, _Cont> __first, + ::__gnu_cxx::__normal_iterator<_Ite, _Cont> __last, + const _Tp& __value) + { std::__fill_a1(__first.base(), __last.base(), __value); } + + template + void + __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _VTp&); + + _GLIBCXX20_CONSTEXPR + void + __fill_a1(_GLIBCXX_STD_C::_Bit_iterator, _GLIBCXX_STD_C::_Bit_iterator, + const bool&); + + template + _GLIBCXX20_CONSTEXPR + inline void + __fill_a(_FIte __first, _FIte __last, const _Tp& __value) + { std::__fill_a1(__first, __last, __value); } + + template + void + __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const _Tp&); + + /** + * @brief Fills the range [first,last) with copies of value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __value A reference-to-const of arbitrary type. + * @return Nothing. + * + * This function fills a range with copies of the same value. For char + * types filling contiguous areas of memory, this becomes an inline call + * to @c memset or @c wmemset. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_requires_valid_range(__first, __last); + + std::__fill_a(__first, __last, __value); + } + + // Used by fill_n, generate_n, etc. to convert _Size to an integral type: + inline _GLIBCXX_CONSTEXPR int + __size_to_integer(int __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned + __size_to_integer(unsigned __n) { return __n; } + inline _GLIBCXX_CONSTEXPR long + __size_to_integer(long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned long + __size_to_integer(unsigned long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(long long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned long long + __size_to_integer(unsigned long long __n) { return __n; } + +#if defined(__GLIBCXX_TYPE_INT_N_0) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0 + __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; } + __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_0 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_0 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1 + __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) { return __n; } + __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_1 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_1 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2 + __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) { return __n; } + __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_2 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_2 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_3 + __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) { return __n; } + __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_3 __n) { return __n; } +#endif + + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(float __n) { return (long long)__n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(double __n) { return (long long)__n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(long double __n) { return (long long)__n; } +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) + __extension__ inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(__float128 __n) { return (long long)__n; } +#endif + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if::__value, _OutputIterator>::__type + __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) + { + for (; __n > 0; --__n, (void) ++__first) + *__first = __value; + return __first; + } + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type + __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __n > 0; --__n, (void) ++__first) + *__first = __tmp; + return __first; + } + + template + ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + _Size __n, const _Tp& __value, + std::input_iterator_tag); + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::output_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + return __fill_n_a1(__first, __n, __value); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::input_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + return __fill_n_a1(__first, __n, __value); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::random_access_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + if (__n <= 0) + return __first; + + __glibcxx_requires_can_increment(__first, __n); + + std::__fill_a(__first, __first + __n, __value); + return __first + __n; + } + + /** + * @brief Fills the range [first,first+n) with copies of value. + * @ingroup mutating_algorithms + * @param __first An output iterator. + * @param __n The count of copies to perform. + * @param __value A reference-to-const of arbitrary type. + * @return The iterator at first+n. + * + * This function fills a range with copies of the same value. For char + * types filling contiguous areas of memory, this becomes an inline call + * to @c memset or @c wmemset. + * + * If @p __n is negative, the function does nothing. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 865. More algorithms that throw away information + // DR 426. search_n(), fill_n(), and generate_n() with negative n + template + _GLIBCXX20_CONSTEXPR + inline _OI + fill_n(_OI __first, _Size __n, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_OutputIteratorConcept<_OI, const _Tp&>) + + return std::__fill_n_a(__first, std::__size_to_integer(__n), __value, + std::__iterator_category(__first)); + } + + template + struct __equal + { + template + _GLIBCXX20_CONSTEXPR + static bool + equal(_II1 __first1, _II1 __last1, _II2 __first2) + { + for (; __first1 != __last1; ++__first1, (void) ++__first2) + if (!(*__first1 == *__first2)) + return false; + return true; + } + }; + + template<> + struct __equal + { + template + _GLIBCXX20_CONSTEXPR + static bool + equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) + { + if (const size_t __len = (__last1 - __first1)) + return !std::__memcmp(__first1, __first2, __len); + return true; + } + }; + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _II); + + template + bool + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>); + + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal_aux1(_II1 __first1, _II1 __last1, _II2 __first2) + { + typedef typename iterator_traits<_II1>::value_type _ValueType1; + const bool __simple = ((__is_integer<_ValueType1>::__value + || __is_pointer<_ValueType1>::__value) + && __memcmpable<_II1, _II2>::__value); + return std::__equal<__simple>::equal(__first1, __last1, __first2); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) + { + return std::__equal_aux1(std::__niter_base(__first1), + std::__niter_base(__last1), + std::__niter_base(__first2)); + } + + template + bool + __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + _II2); + + template + bool + __equal_aux(_II1, _II1, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); + + template + bool + __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); + + template + struct __lc_rai + { + template + _GLIBCXX20_CONSTEXPR + static _II1 + __newlast1(_II1, _II1 __last1, _II2, _II2) + { return __last1; } + + template + _GLIBCXX20_CONSTEXPR + static bool + __cnd2(_II __first, _II __last) + { return __first != __last; } + }; + + template<> + struct __lc_rai + { + template + _GLIBCXX20_CONSTEXPR + static _RAI1 + __newlast1(_RAI1 __first1, _RAI1 __last1, + _RAI2 __first2, _RAI2 __last2) + { + const typename iterator_traits<_RAI1>::difference_type + __diff1 = __last1 - __first1; + const typename iterator_traits<_RAI2>::difference_type + __diff2 = __last2 - __first2; + return __diff2 < __diff1 ? __first1 + __diff2 : __last1; + } + + template + static _GLIBCXX20_CONSTEXPR bool + __cnd2(_RAI, _RAI) + { return true; } + }; + + template + _GLIBCXX20_CONSTEXPR + bool + __lexicographical_compare_impl(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2, + _Compare __comp) + { + typedef typename iterator_traits<_II1>::iterator_category _Category1; + typedef typename iterator_traits<_II2>::iterator_category _Category2; + typedef std::__lc_rai<_Category1, _Category2> __rai_type; + + __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2); + for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); + ++__first1, (void)++__first2) + { + if (__comp(__first1, __first2)) + return true; + if (__comp(__first2, __first1)) + return false; + } + return __first1 == __last1 && __first2 != __last2; + } + + template + struct __lexicographical_compare + { + template + _GLIBCXX20_CONSTEXPR + static bool + __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + using __gnu_cxx::__ops::__iter_less_iter; + return std::__lexicographical_compare_impl(__first1, __last1, + __first2, __last2, + __iter_less_iter()); + } + + template + _GLIBCXX20_CONSTEXPR + static int + __3way(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + while (__first1 != __last1) + { + if (__first2 == __last2) + return +1; + if (*__first1 < *__first2) + return -1; + if (*__first2 < *__first1) + return +1; + ++__first1; + ++__first2; + } + return int(__first2 == __last2) - 1; + } + }; + + template<> + struct __lexicographical_compare + { + template + _GLIBCXX20_CONSTEXPR + static bool + __lc(const _Tp* __first1, const _Tp* __last1, + const _Up* __first2, const _Up* __last2) + { return __3way(__first1, __last1, __first2, __last2) < 0; } + + template + _GLIBCXX20_CONSTEXPR + static ptrdiff_t + __3way(const _Tp* __first1, const _Tp* __last1, + const _Up* __first2, const _Up* __last2) + { + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + if (const size_t __len = std::min(__len1, __len2)) + if (int __result = std::__memcmp(__first1, __first2, __len)) + return __result; + return ptrdiff_t(__len1 - __len2); + } + }; + + template + _GLIBCXX20_CONSTEXPR + inline bool + __lexicographical_compare_aux1(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { + typedef typename iterator_traits<_II1>::value_type _ValueType1; + typedef typename iterator_traits<_II2>::value_type _ValueType2; + const bool __simple = + (__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value + && __is_pointer<_II1>::__value + && __is_pointer<_II2>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v>> + && !is_volatile_v>> +#endif + ); + + return std::__lexicographical_compare<__simple>::__lc(__first1, __last1, + __first2, __last2); + } + + template + bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _Tp2*, _Tp2*); + + template + bool + __lexicographical_compare_aux1(_Tp1*, _Tp1*, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + _GLIBCXX20_CONSTEXPR + inline bool + __lexicographical_compare_aux(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { + return std::__lexicographical_compare_aux1(std::__niter_base(__first1), + std::__niter_base(__last1), + std::__niter_base(__first2), + std::__niter_base(__last2)); + } + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + _II2, _II2); + + template + bool + __lexicographical_compare_aux( + _II1, _II1, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&); + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&); + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp(__middle, __val)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } + + /** + * @brief Finds the first position in which @a val could be inserted + * without changing the ordering. + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An iterator pointing to the first element not less + * than @a val, or end() if every element is less than + * @a val. + * @ingroup binary_search_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + + return std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val()); + } + + /// This is a helper function for the sort routines and for random.tcc. + // Precondition: __n > 0. + inline _GLIBCXX_CONSTEXPR int + __lg(int __n) + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned + __lg(unsigned __n) + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + + inline _GLIBCXX_CONSTEXPR long + __lg(long __n) + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned long + __lg(unsigned long __n) + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + + inline _GLIBCXX_CONSTEXPR long long + __lg(long long __n) + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned long long + __lg(unsigned long long __n) + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @return A boolean true or false. + * + * This compares the elements of two ranges using @c == and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_II1 __first1, _II1 __last1, _II2 __first2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_II1>::value_type, + typename iterator_traits<_II2>::value_type>) + __glibcxx_requires_can_increment_range(__first1, __last1, __first2); + + return std::__equal_aux(__first1, __last1, __first2); + } + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A boolean true or false. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_IIter1 __first1, _IIter1 __last1, + _IIter2 __first2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_IIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_IIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!bool(__binary_pred(*__first1, *__first2))) + return false; + return true; + } + +#if __cplusplus >= 201103L + // 4-iterator version of std::equal for use in C++11. + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + using _RATag = random_access_iterator_tag; + using _Cat1 = typename iterator_traits<_II1>::iterator_category; + using _Cat2 = typename iterator_traits<_II2>::iterator_category; + using _RAIters = __and_, is_same<_Cat2, _RATag>>; + if (_RAIters()) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + return _GLIBCXX_STD_A::equal(__first1, __last1, __first2); + } + + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!(*__first1 == *__first2)) + return false; + return __first1 == __last1 && __first2 == __last2; + } + + // 4-iterator version of std::equal for use in C++11. + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, + _BinaryPredicate __binary_pred) + { + using _RATag = random_access_iterator_tag; + using _Cat1 = typename iterator_traits<_II1>::iterator_category; + using _Cat2 = typename iterator_traits<_II2>::iterator_category; + using _RAIters = __and_, is_same<_Cat2, _RATag>>; + if (_RAIters()) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + return _GLIBCXX_STD_A::equal(__first1, __last1, __first2, + __binary_pred); + } + + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!bool(__binary_pred(*__first1, *__first2))) + return false; + return __first1 == __last1 && __first2 == __last2; + } +#endif // C++11 + +#if __cplusplus > 201103L + +#define __cpp_lib_robust_nonmodifying_seq_ops 201304L + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A boolean true or false. + * + * This compares the elements of two ranges using @c == and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_II1>::value_type, + typename iterator_traits<_II2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2); + } + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A boolean true or false. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_IIter1 __first1, _IIter1 __last1, + _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_IIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_IIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2, + __binary_pred); + } +#endif // C++14 + + /** + * @brief Performs @b dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A boolean true or false. + * + * Returns true if the sequence of elements defined by the range + * [first1,last1) is lexicographically less than the sequence of elements + * defined by the range [first2,last2). Returns false otherwise. + * (Quoted from [25.3.8]/1.) If the iterators are all character pointers, + * then this is an inline call to @c memcmp. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + lexicographical_compare(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename iterator_traits<_II1>::value_type _ValueType1; + typedef typename iterator_traits<_II2>::value_type _ValueType2; +#endif + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__lexicographical_compare_aux(__first1, __last1, + __first2, __last2); + } + + /** + * @brief Performs @b dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return A boolean true or false. + * + * The same as the four-parameter @c lexicographical_compare, but uses the + * comp parameter instead of @c <. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + lexicographical_compare(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__lexicographical_compare_impl + (__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cpp_lib_three_way_comparison + // Iter points to a contiguous range of unsigned narrow character type + // or std::byte, suitable for comparison by memcmp. + template + concept __is_byte_iter = contiguous_iterator<_Iter> + && __is_memcmp_ordered>::__value; + + // Return a struct with two members, initialized to the smaller of x and y + // (or x if they compare equal) and the result of the comparison x <=> y. + template + constexpr auto + __min_cmp(_Tp __x, _Tp __y) + { + struct _Res { + _Tp _M_min; + decltype(__x <=> __y) _M_cmp; + }; + auto __c = __x <=> __y; + if (__c > 0) + return _Res{__y, __c}; + return _Res{__x, __c}; + } + + /** + * @brief Performs dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The comparison category that `__comp(*__first1, *__first2)` + * returns. + */ + template + constexpr auto + lexicographical_compare_three_way(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _InputIter2 __last2, + _Comp __comp) + -> decltype(__comp(*__first1, *__first2)) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + using _Cat = decltype(__comp(*__first1, *__first2)); + static_assert(same_as, _Cat>); + + if (!std::__is_constant_evaluated()) + if constexpr (same_as<_Comp, __detail::_Synth3way> + || same_as<_Comp, compare_three_way>) + if constexpr (__is_byte_iter<_InputIter1>) + if constexpr (__is_byte_iter<_InputIter2>) + { + const auto [__len, __lencmp] = _GLIBCXX_STD_A:: + __min_cmp(__last1 - __first1, __last2 - __first2); + if (__len) + { + const auto __c + = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0; + if (__c != 0) + return __c; + } + return __lencmp; + } + + while (__first1 != __last1) + { + if (__first2 == __last2) + return strong_ordering::greater; + if (auto __cmp = __comp(*__first1, *__first2); __cmp != 0) + return __cmp; + ++__first1; + ++__first2; + } + return (__first2 == __last2) <=> true; // See PR 94006 + } + + template + constexpr auto + lexicographical_compare_three_way(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _InputIter2 __last2) + { + return _GLIBCXX_STD_A:: + lexicographical_compare_three_way(__first1, __last1, __first2, __last2, + compare_three_way{}); + } +#endif // three_way_comparison + + template + _GLIBCXX20_CONSTEXPR + pair<_InputIterator1, _InputIterator2> + __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _BinaryPredicate __binary_pred) + { + while (__first1 != __last1 && __binary_pred(__first1, __first2)) + { + ++__first1; + ++__first2; + } + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using @c == and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + +#if __cplusplus > 201103L + + template + _GLIBCXX20_CONSTEXPR + pair<_InputIterator1, _InputIterator2> + __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __binary_pred) + { + while (__first1 != __last1 && __first2 != __last2 + && __binary_pred(__first1, __first2)) + { + ++__first1; + ++__first2; + } + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using @c == and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } +#endif + +_GLIBCXX_END_NAMESPACE_ALGO + + /// This is an overload used by find algos for the Input Iterator case. + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + __find_if(_InputIterator __first, _InputIterator __last, + _Predicate __pred, input_iterator_tag) + { + while (__first != __last && !__pred(__first)) + ++__first; + return __first; + } + + /// This is an overload used by find algos for the RAI case. + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Predicate __pred, random_access_iterator_tag) + { + typename iterator_traits<_RandomAccessIterator>::difference_type + __trip_count = (__last - __first) >> 2; + + for (; __trip_count > 0; --__trip_count) + { + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + } + + switch (__last - __first) + { + case 3: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 2: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 1: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 0: + default: + return __last; + } + } + + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) + { + return __find_if(__first, __last, __pred, + std::__iterator_category(__first)); + } + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { + typename iterator_traits<_InputIterator>::difference_type __n = 0; + for (; __first != __last; ++__first) + if (__pred(__first)) + ++__n; + return __n; + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __remove_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + __first = std::__find_if(__first, __last, __pred); + if (__first == __last) + return __first; + _ForwardIterator __result = __first; + ++__first; + for (; __first != __last; ++__first) + if (!__pred(__first)) + { + *__result = _GLIBCXX_MOVE(*__first); + ++__result; + } + return __result; + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _BinaryPredicate __pred) + { + // Efficiently compare identical prefixes: O(N) if sequences + // have the same elements in the same order. + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!__pred(__first1, __first2)) + break; + + if (__first1 == __last1) + return true; + + // Establish __last2 assuming equal ranges by iterating over the + // rest of the list. + _ForwardIterator2 __last2 = __first2; + std::advance(__last2, std::distance(__first1, __last1)); + for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) + { + if (__scan != std::__find_if(__first1, __scan, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) + continue; // We've seen this one before. + + auto __matches + = std::__count_if(__first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); + if (0 == __matches || + std::__count_if(__scan, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) + != __matches) + return false; + } + return true; + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @return true if there exists a permutation of the elements in the range + * [__first2, __first2 + (__last1 - __first1)), beginning with + * ForwardIterator2 begin, such that equal(__first1, __last1, begin) + * returns true; otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return std::__is_permutation(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +// NB: This file is included within many other C++ includes, as a way +// of getting the base algorithms. So, make sure that parallel bits +// come in too if requested. +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f15031ae98d8ac367299c1fb6e4bbec1baa63d8c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_algobase.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h new file mode 100644 index 0000000000000000000000000000000000000000..d256af40f407b9110f0f21d1c1303448847a966b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h @@ -0,0 +1,1585 @@ +// vector specialization -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_bvector.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _STL_BVECTOR_H +#define _STL_BVECTOR_H 1 + +#if __cplusplus >= 201103L +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef unsigned long _Bit_type; + enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) }; + + __attribute__((__nonnull__)) + _GLIBCXX20_CONSTEXPR + void + __fill_bvector_n(_Bit_type*, size_t, bool) _GLIBCXX_NOEXCEPT; + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + struct _Bit_reference + { + _Bit_type * _M_p; + _Bit_type _M_mask; + + _GLIBCXX20_CONSTEXPR + _Bit_reference(_Bit_type * __x, _Bit_type __y) + : _M_p(__x), _M_mask(__y) { } + + _GLIBCXX20_CONSTEXPR + _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } + +#if __cplusplus >= 201103L + _Bit_reference(const _Bit_reference&) = default; +#endif + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + operator bool() const _GLIBCXX_NOEXCEPT + { return !!(*_M_p & _M_mask); } + + _GLIBCXX20_CONSTEXPR + _Bit_reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + if (__x) + *_M_p |= _M_mask; + else + *_M_p &= ~_M_mask; + return *this; + } + + _GLIBCXX20_CONSTEXPR + _Bit_reference& + operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT + { return *this = bool(__x); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + bool + operator==(const _Bit_reference& __x) const + { return bool(*this) == bool(__x); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + bool + operator<(const _Bit_reference& __x) const + { return !bool(*this) && bool(__x); } + + _GLIBCXX20_CONSTEXPR + void + flip() _GLIBCXX_NOEXCEPT + { *_M_p ^= _M_mask; } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + _GLIBCXX20_CONSTEXPR + friend void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } +#endif + }; + +// Ignore warnings about std::iterator. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + struct _Bit_iterator_base + : public std::iterator + { + _Bit_type * _M_p; + unsigned int _M_offset; + + _GLIBCXX20_CONSTEXPR + _Bit_iterator_base(_Bit_type * __x, unsigned int __y) + : _M_p(__x), _M_offset(__y) { } + + _GLIBCXX20_CONSTEXPR + void + _M_bump_up() + { + if (_M_offset++ == int(_S_word_bit) - 1) + { + _M_offset = 0; + ++_M_p; + } + } + + _GLIBCXX20_CONSTEXPR + void + _M_bump_down() + { + if (_M_offset-- == 0) + { + _M_offset = int(_S_word_bit) - 1; + --_M_p; + } + } + + _GLIBCXX20_CONSTEXPR + void + _M_incr(ptrdiff_t __i) + { + difference_type __n = __i + _M_offset; + _M_p += __n / int(_S_word_bit); + __n = __n % int(_S_word_bit); + if (__n < 0) + { + __n += int(_S_word_bit); + --_M_p; + } + _M_offset = static_cast(__n); + } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR bool + operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; } + +#if __cpp_lib_three_way_comparison + [[nodiscard]] + friend constexpr strong_ordering + operator<=>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + noexcept + { + if (const auto __cmp = __x._M_p <=> __y._M_p; __cmp != 0) + return __cmp; + return __x._M_offset <=> __y._M_offset; + } +#else + _GLIBCXX_NODISCARD + friend bool + operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { + return __x._M_p < __y._M_p + || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); + } + + _GLIBCXX_NODISCARD + friend bool + operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x == __y); } + + _GLIBCXX_NODISCARD + friend bool + operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return __y < __x; } + + _GLIBCXX_NODISCARD + friend bool + operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__y < __x); } + + _GLIBCXX_NODISCARD + friend bool + operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x < __y); } +#endif // three-way comparison + + friend _GLIBCXX20_CONSTEXPR ptrdiff_t + operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { + return (int(_S_word_bit) * (__x._M_p - __y._M_p) + + __x._M_offset - __y._M_offset); + } + }; +#pragma GCC diagnostic pop + + struct _Bit_iterator : public _Bit_iterator_base + { + typedef _Bit_reference reference; +#if __cplusplus > 201703L + typedef void pointer; +#else + typedef _Bit_reference* pointer; +#endif + typedef _Bit_iterator iterator; + + _GLIBCXX20_CONSTEXPR + _Bit_iterator() : _Bit_iterator_base(0, 0) { } + + _GLIBCXX20_CONSTEXPR + _Bit_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + _GLIBCXX20_CONSTEXPR + iterator + _M_const_cast() const + { return *this; } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + operator*() const + { return reference(_M_p, 1UL << _M_offset); } + + _GLIBCXX20_CONSTEXPR + iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + _GLIBCXX20_CONSTEXPR + iterator + operator++(int) + { + iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + _GLIBCXX20_CONSTEXPR + iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + _GLIBCXX20_CONSTEXPR + iterator + operator--(int) + { + iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + _GLIBCXX20_CONSTEXPR + iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + _GLIBCXX20_CONSTEXPR + iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + operator[](difference_type __i) const + { return *(*this + __i); } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR iterator + operator+(const iterator& __x, difference_type __n) + { + iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR iterator + operator+(difference_type __n, const iterator& __x) + { return __x + __n; } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR iterator + operator-(const iterator& __x, difference_type __n) + { + iterator __tmp = __x; + __tmp -= __n; + return __tmp; + } + }; + + struct _Bit_const_iterator : public _Bit_iterator_base + { + typedef bool reference; + typedef bool const_reference; +#if __cplusplus > 201703L + typedef void pointer; +#else + typedef const bool* pointer; +#endif + typedef _Bit_const_iterator const_iterator; + + _GLIBCXX20_CONSTEXPR + _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } + + _GLIBCXX20_CONSTEXPR + _Bit_const_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + _GLIBCXX20_CONSTEXPR + _Bit_const_iterator(const _Bit_iterator& __x) + : _Bit_iterator_base(__x._M_p, __x._M_offset) { } + + _GLIBCXX20_CONSTEXPR + _Bit_iterator + _M_const_cast() const + { return _Bit_iterator(_M_p, _M_offset); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + operator*() const + { return _Bit_reference(_M_p, 1UL << _M_offset); } + + _GLIBCXX20_CONSTEXPR + const_iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + _GLIBCXX20_CONSTEXPR + const_iterator + operator++(int) + { + const_iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + _GLIBCXX20_CONSTEXPR + const_iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + _GLIBCXX20_CONSTEXPR + const_iterator + operator--(int) + { + const_iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + _GLIBCXX20_CONSTEXPR + const_iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + _GLIBCXX20_CONSTEXPR + const_iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + operator[](difference_type __i) const + { return *(*this + __i); } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR const_iterator + operator+(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR const_iterator + operator-(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp -= __n; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend _GLIBCXX20_CONSTEXPR const_iterator + operator+(difference_type __n, const const_iterator& __x) + { return __x + __n; } + }; + + template + struct _Bvector_base + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Bit_type>::other _Bit_alloc_type; + typedef typename __gnu_cxx::__alloc_traits<_Bit_alloc_type> + _Bit_alloc_traits; + typedef typename _Bit_alloc_traits::pointer _Bit_pointer; + + struct _Bvector_impl_data + { +#if !_GLIBCXX_INLINE_VERSION + _Bit_iterator _M_start; +#else + // We don't need the offset field for the start, it's always zero. + struct { + _Bit_type* _M_p; + // Allow assignment from iterators (assume offset is zero): + _GLIBCXX20_CONSTEXPR + void operator=(_Bit_iterator __it) { _M_p = __it._M_p; } + } _M_start; +#endif + _Bit_iterator _M_finish; + _Bit_pointer _M_end_of_storage; + + _GLIBCXX20_CONSTEXPR + _Bvector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _Bvector_impl_data(const _Bvector_impl_data&) = default; + + _Bvector_impl_data& + operator=(const _Bvector_impl_data&) = default; + + _GLIBCXX20_CONSTEXPR + _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept + : _Bvector_impl_data(__x) + { __x._M_reset(); } + + _GLIBCXX20_CONSTEXPR + void + _M_move_data(_Bvector_impl_data&& __x) noexcept + { + *this = __x; + __x._M_reset(); + } +#endif + + _GLIBCXX20_CONSTEXPR + void + _M_reset() _GLIBCXX_NOEXCEPT + { *this = _Bvector_impl_data(); } + + _GLIBCXX20_CONSTEXPR + void + _M_swap_data(_Bvector_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + std::swap(*this, __x); + } + }; + + struct _Bvector_impl + : public _Bit_alloc_type, public _Bvector_impl_data + { + _GLIBCXX20_CONSTEXPR + _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Bit_alloc_type>::value) + : _Bit_alloc_type() + { } + + _GLIBCXX20_CONSTEXPR + _Bvector_impl(const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Bit_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + // Not defaulted, to enforce noexcept(true) even when + // !is_nothrow_move_constructible<_Bit_alloc_type>. + _GLIBCXX20_CONSTEXPR + _Bvector_impl(_Bvector_impl&& __x) noexcept + : _Bit_alloc_type(std::move(__x)), _Bvector_impl_data(std::move(__x)) + { } + + _GLIBCXX20_CONSTEXPR + _Bvector_impl(_Bit_alloc_type&& __a, _Bvector_impl&& __x) noexcept + : _Bit_alloc_type(std::move(__a)), _Bvector_impl_data(std::move(__x)) + { } +#endif + + _GLIBCXX20_CONSTEXPR + _Bit_type* + _M_end_addr() const _GLIBCXX_NOEXCEPT + { + if (this->_M_end_of_storage) + return std::__addressof(this->_M_end_of_storage[-1]) + 1; + return 0; + } + }; + + public: + typedef _Alloc allocator_type; + + _GLIBCXX20_CONSTEXPR + _Bit_alloc_type& + _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _GLIBCXX20_CONSTEXPR + const _Bit_alloc_type& + _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _GLIBCXX20_CONSTEXPR + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Bit_allocator()); } + +#if __cplusplus >= 201103L + _Bvector_base() = default; +#else + _Bvector_base() { } +#endif + + _GLIBCXX20_CONSTEXPR + _Bvector_base(const allocator_type& __a) + : _M_impl(__a) { } + +#if __cplusplus >= 201103L + _Bvector_base(_Bvector_base&&) = default; + + _GLIBCXX20_CONSTEXPR + _Bvector_base(_Bvector_base&& __x, const allocator_type& __a) noexcept + : _M_impl(_Bit_alloc_type(__a), std::move(__x._M_impl)) + { } +#endif + + _GLIBCXX20_CONSTEXPR + ~_Bvector_base() + { this->_M_deallocate(); } + + protected: + _Bvector_impl _M_impl; + + _GLIBCXX20_CONSTEXPR + _Bit_pointer + _M_allocate(size_t __n) + { + _Bit_pointer __p = _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + __n = _S_nword(__n); + for (size_t __i = 0; __i < __n; ++__i) + __p[__i] = 0ul; + } +#endif + return __p; + } + + _GLIBCXX20_CONSTEXPR + void + _M_deallocate() + { + if (_M_impl._M_start._M_p) + { + const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p; + _Bit_alloc_traits::deallocate(_M_impl, + _M_impl._M_end_of_storage - __n, + __n); + _M_impl._M_reset(); + } + } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + void + _M_move_data(_Bvector_base&& __x) noexcept + { _M_impl._M_move_data(std::move(__x._M_impl)); } +#endif + + _GLIBCXX_CONSTEXPR + static size_t + _S_nword(size_t __n) + { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); } + }; + + /** + * @brief A specialization of vector for booleans which offers fixed time + * access to individual elements in any order. + * + * @ingroup sequences + * + * @tparam _Alloc Allocator type. + * + * Note that vector does not actually meet the requirements for being + * a container. This is because the reference and pointer types are not + * really references and pointers to bool. See DR96 for details. @see + * vector for function documentation. + * + * In some terminology a %vector can be described as a dynamic + * C-style array, it offers fast and efficient access to individual + * elements in any order and saves the user from worrying about + * memory and size allocation. Subscripting ( @c [] ) access is + * also provided as with C-style arrays. + */ + template + class vector : protected _Bvector_base<_Alloc> + { + typedef _Bvector_base<_Alloc> _Base; + typedef typename _Base::_Bit_pointer _Bit_pointer; + typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits; + +#if __cplusplus >= 201103L + friend struct std::hash; +#endif + + public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Bit_reference reference; + typedef bool const_reference; + typedef _Bit_reference* pointer; + typedef const bool* const_pointer; + typedef _Bit_iterator iterator; + typedef _Bit_const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef _Alloc allocator_type; + + _GLIBCXX20_CONSTEXPR + allocator_type + get_allocator() const + { return _Base::get_allocator(); } + + protected: + using _Base::_M_allocate; + using _Base::_M_deallocate; + using _Base::_S_nword; + using _Base::_M_get_Bit_allocator; + + public: +#if __cplusplus >= 201103L + vector() = default; +#else + vector() { } +#endif + + _GLIBCXX20_CONSTEXPR + explicit + vector(const allocator_type& __a) + : _Base(__a) { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + explicit + vector(size_type __n, const allocator_type& __a = allocator_type()) + : vector(__n, false, __a) + { } + + _GLIBCXX20_CONSTEXPR + vector(size_type __n, const bool& __value, + const allocator_type& __a = allocator_type()) +#else + explicit + vector(size_type __n, const bool& __value = bool(), + const allocator_type& __a = allocator_type()) +#endif + : _Base(__a) + { + _M_initialize(__n); + _M_initialize_value(__value); + } + + _GLIBCXX20_CONSTEXPR + vector(const vector& __x) + : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator())) + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + } + +#if __cplusplus >= 201103L + vector(vector&&) = default; + + private: + _GLIBCXX20_CONSTEXPR + vector(vector&& __x, const allocator_type& __a, true_type) noexcept + : _Base(std::move(__x), __a) + { } + + _GLIBCXX20_CONSTEXPR + vector(vector&& __x, const allocator_type& __a, false_type) + : _Base(__a) + { + if (__x.get_allocator() == __a) + this->_M_move_data(std::move(__x)); + else + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + __x.clear(); + } + } + + public: + _GLIBCXX20_CONSTEXPR + vector(vector&& __x, const __type_identity_t& __a) + noexcept(_Bit_alloc_traits::_S_always_equal()) + : vector(std::move(__x), __a, + typename _Bit_alloc_traits::is_always_equal{}) + { } + + _GLIBCXX20_CONSTEXPR + vector(const vector& __x, const __type_identity_t& __a) + : _Base(__a) + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + } + + _GLIBCXX20_CONSTEXPR + vector(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_initialize_range(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_initialize_range(__first, __last, + std::__iterator_category(__first)); + } +#else + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + _GLIBCXX20_CONSTEXPR + ~vector() _GLIBCXX_NOEXCEPT { } + + _GLIBCXX20_CONSTEXPR + vector& + operator=(const vector& __x) + { + if (&__x == this) + return *this; +#if __cplusplus >= 201103L + if (_Bit_alloc_traits::_S_propagate_on_copy_assign()) + { + if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator()) + { + this->_M_deallocate(); + std::__alloc_on_copy(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + _M_initialize(__x.size()); + } + else + std::__alloc_on_copy(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } +#endif + if (__x.size() > capacity()) + { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); + return *this; + } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + vector& + operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move()) + { + if (_Bit_alloc_traits::_S_propagate_on_move_assign() + || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator()) + { + this->_M_deallocate(); + this->_M_move_data(std::move(__x)); + std::__alloc_on_move(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } + else + { + if (__x.size() > capacity()) + { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); + __x.clear(); + } + return *this; + } + + _GLIBCXX20_CONSTEXPR + vector& + operator=(initializer_list __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } +#endif + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + _GLIBCXX20_CONSTEXPR + void + assign(size_type __n, const bool& __x) + { _M_fill_assign(__n, __x); } + +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + void + assign(initializer_list __l) + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } +#endif + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_start._M_p, 0); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + iterator + end() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_iterator + cend() const noexcept + { return this->_M_impl._M_finish; } + + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + size() const _GLIBCXX_NOEXCEPT + { return size_type(end() - begin()); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + max_size() const _GLIBCXX_NOEXCEPT + { + const size_type __isize = + __gnu_cxx::__numeric_traits::__max + - int(_S_word_bit) + 1; + const size_type __asize + = _Bit_alloc_traits::max_size(_M_get_Bit_allocator()); + return (__asize <= __isize / int(_S_word_bit) + ? __asize * int(_S_word_bit) : __isize); + } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0) + - begin()); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + bool + empty() const _GLIBCXX_NOEXCEPT + { return begin() == end(); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + operator[](size_type __n) + { return begin()[__n]; } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + operator[](size_type __n) const + { return begin()[__n]; } + + protected: + _GLIBCXX20_CONSTEXPR + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("vector::_M_range_check: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + _GLIBCXX20_CONSTEXPR + reference + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } + + _GLIBCXX20_CONSTEXPR + const_reference + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } + + _GLIBCXX20_CONSTEXPR + void + reserve(size_type __n) + { + if (__n > max_size()) + __throw_length_error(__N("vector::reserve")); + if (capacity() < __n) + _M_reallocate(__n); + } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + front() + { return *begin(); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + front() const + { return *begin(); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + back() + { return *(end() - 1); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + back() const + { return *(end() - 1); } + + _GLIBCXX20_CONSTEXPR + void + push_back(bool __x) + { + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) + *this->_M_impl._M_finish++ = __x; + else + _M_insert_aux(end(), __x); + } + + _GLIBCXX20_CONSTEXPR + void + swap(vector& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value + || _M_get_Bit_allocator() == __x._M_get_Bit_allocator()); +#endif + this->_M_impl._M_swap_data(__x._M_impl); + _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } + + // [23.2.5]/1, third-to-last entry in synopsis listing + _GLIBCXX20_CONSTEXPR + static void + swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + _GLIBCXX20_CONSTEXPR + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const bool& __x) +#else + insert(iterator __position, const bool& __x) +#endif + { + const difference_type __n = __position - begin(); + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr() + && __position == end()) + *this->_M_impl._M_finish++ = __x; + else + _M_insert_aux(__position._M_const_cast(), __x); + return begin() + __n; + } + +#if _GLIBCXX_USE_DEPRECATED + _GLIBCXX_DEPRECATED_SUGGEST("insert(position, false)") + iterator + insert(const_iterator __position) + { return this->insert(__position._M_const_cast(), false); } +#endif + +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, + _InputIterator __first, _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_insert_range(__position._M_const_cast(), + __first, __last, + std::__iterator_category(__first)); + return begin() + __offset; + } +#else + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, size_type __n, const bool& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(__position._M_const_cast(), __n, __x); + return begin() + __offset; + } +#else + void + insert(iterator __position, size_type __n, const bool& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } +#endif + + _GLIBCXX20_CONSTEXPR + void + pop_back() + { --this->_M_impl._M_finish; } + + _GLIBCXX20_CONSTEXPR + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { return _M_erase(__position._M_const_cast()); } + + _GLIBCXX20_CONSTEXPR + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } + + _GLIBCXX20_CONSTEXPR + void + resize(size_type __new_size, bool __x = bool()) + { + if (__new_size < size()) + _M_erase_at_end(begin() + difference_type(__new_size)); + else + insert(end(), __new_size - size(), __x); + } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + void + shrink_to_fit() + { _M_shrink_to_fit(); } +#endif + + _GLIBCXX20_CONSTEXPR + void + flip() _GLIBCXX_NOEXCEPT + { + _Bit_type * const __end = this->_M_impl._M_end_addr(); + for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p) + *__p = ~*__p; + } + + _GLIBCXX20_CONSTEXPR + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(begin()); } + +#if __cplusplus >= 201103L + template +#if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + push_back(bool(__args...)); +#if __cplusplus > 201402L + return back(); +#endif + } + + template + _GLIBCXX20_CONSTEXPR + iterator + emplace(const_iterator __pos, _Args&&... __args) + { return insert(__pos, bool(__args...)); } +#endif + + protected: + // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + _GLIBCXX20_CONSTEXPR + iterator + _M_copy_aligned(const_iterator __first, const_iterator __last, + iterator __result) + { + _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); + return std::copy(const_iterator(__last._M_p, 0), __last, + iterator(__q, 0)); + } + + _GLIBCXX20_CONSTEXPR + void + _M_initialize(size_type __n) + { + if (__n) + { + _Bit_pointer __q = this->_M_allocate(__n); + this->_M_impl._M_end_of_storage = __q + _S_nword(__n); + iterator __start = iterator(std::__addressof(*__q), 0); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __start + difference_type(__n); + } + } + + _GLIBCXX20_CONSTEXPR + void + _M_initialize_value(bool __x) _GLIBCXX_NOEXCEPT + { + if (_Bit_type* __p = this->_M_impl._M_start._M_p) + __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x); + } + + _GLIBCXX20_CONSTEXPR + void + _M_reallocate(size_type __n); + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + bool + _M_shrink_to_fit(); +#endif + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { + _M_initialize(static_cast(__n)); + _M_initialize_value(__x); + } + + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_initialize_range(__first, __last, + std::__iterator_category(__first)); } +#endif + + template + _GLIBCXX20_CONSTEXPR + void + _M_initialize_range(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + for (; __first != __last; ++__first) + push_back(*__first); + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + _M_initialize(__n); + std::copy(__first, __last, begin()); + } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#endif + + _GLIBCXX20_CONSTEXPR + void + _M_fill_assign(size_t __n, bool __x) + { + if (__n > size()) + { + _M_initialize_value(__x); + insert(end(), __n - size(), __x); + } + else + { + _M_erase_at_end(begin() + __n); + _M_initialize_value(__x); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + iterator __cur = begin(); + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + insert(end(), __first, __last); + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + if (__len < size()) + _M_erase_at_end(std::copy(__first, __last, begin())); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + __true_type) + { _M_fill_insert(__pos, __n, __x); } + + template + void + _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + __false_type) + { _M_insert_range(__pos, __first, __last, + std::__iterator_category(__first)); } +#endif + + _GLIBCXX20_CONSTEXPR + void + _M_fill_insert(iterator __position, size_type __n, bool __x); + + template + _GLIBCXX20_CONSTEXPR + void + _M_insert_range(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + _GLIBCXX20_CONSTEXPR + void + _M_insert_aux(iterator __position, bool __x); + + _GLIBCXX20_CONSTEXPR + size_type + _M_check_len(size_type __n, const char* __s) const + { + if (max_size() - size() < __n) + __throw_length_error(__N(__s)); + + const size_type __len = size() + std::max(size(), __n); + return (__len < size() || __len > max_size()) ? max_size() : __len; + } + + _GLIBCXX20_CONSTEXPR + void + _M_erase_at_end(iterator __pos) + { this->_M_impl._M_finish = __pos; } + + _GLIBCXX20_CONSTEXPR + iterator + _M_erase(iterator __pos); + + _GLIBCXX20_CONSTEXPR + iterator + _M_erase(iterator __first, iterator __last); + + protected: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // N.B. DR 464 says nothing about vector but we need something + // here due to the using-declaration in __gnu_debug::vector. + // vector class. +#if __cplusplus >= 201103L + void data() = delete; +#else + void data() { } +#endif + }; + +_GLIBCXX_END_NAMESPACE_CONTAINER + + // Fill a partial word. + _GLIBCXX20_CONSTEXPR + inline void + __fill_bvector(_Bit_type* __v, unsigned int __first, unsigned int __last, + bool __x) _GLIBCXX_NOEXCEPT + { + const _Bit_type __fmask = ~0ul << __first; + const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last); + const _Bit_type __mask = __fmask & __lmask; + + if (__x) + *__v |= __mask; + else + *__v &= ~__mask; + } + + // Fill N full words, as if using memset, but usable in constant expressions. + __attribute__((__nonnull__)) + _GLIBCXX20_CONSTEXPR + inline void + __fill_bvector_n(_Bit_type* __p, size_t __n, bool __x) _GLIBCXX_NOEXCEPT + { +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for (size_t __i = 0; __i < __n; ++__i) + __p[__i] = __x ? ~0ul : 0ul; + return; + } +#endif + __builtin_memset(__p, __x ? ~0 : 0, __n * sizeof(_Bit_type)); + } + + + _GLIBCXX20_CONSTEXPR + inline void + __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first, + _GLIBCXX_STD_C::_Bit_iterator __last, const bool& __x) + { + if (__first._M_p != __last._M_p) + { + _Bit_type* __first_p = __first._M_p; + if (__first._M_offset != 0) + __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x); + + __fill_bvector_n(__first_p, __last._M_p - __first_p, __x); + + if (__last._M_offset != 0) + __fill_bvector(__last._M_p, 0, __last._M_offset, __x); + } + else if (__first._M_offset != __last._M_offset) + __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x); + } + +#if __cplusplus >= 201103L + // DR 1182. + /// std::hash specialization for vector. + template + struct hash<_GLIBCXX_STD_C::vector> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::vector&) const noexcept; + }; +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1aff5602dd21bb99716e57539f720022b685b5b1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_bvector.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h new file mode 100644 index 0000000000000000000000000000000000000000..9531222809c64aba711fbcebb1eaa9092b6e1643 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h @@ -0,0 +1,267 @@ +// nonstandard construct and destroy functions -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_construct.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_CONSTRUCT_H +#define _STL_CONSTRUCT_H 1 + +#include +#include +#include // for iterator_traits +#include // for advance + +/* This file provides the C++17 functions std::destroy_at, std::destroy, and + * std::destroy_n, and the C++20 function std::construct_at. + * It also provides std::_Construct, std::_Destroy,and std::_Destroy_n functions + * which are defined in all standard modes and so can be used in C++98-14 code. + * The _Destroy functions will dispatch to destroy_at during constant + * evaluation, because calls to that function are intercepted by the compiler + * to allow use in constant expressions. + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + template + _GLIBCXX20_CONSTEXPR inline void + destroy_at(_Tp* __location) + { + if constexpr (__cplusplus > 201703L && is_array_v<_Tp>) + { + for (auto& __x : *__location) + std::destroy_at(std::__addressof(__x)); + } + else + __location->~_Tp(); + } + +#if __cplusplus >= 202002L + template + constexpr auto + construct_at(_Tp* __location, _Args&&... __args) + noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) + -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...)) + { return ::new((void*)__location) _Tp(std::forward<_Args>(__args)...); } +#endif // C++20 +#endif// C++17 + + /** + * Constructs an object in existing memory by invoking an allocated + * object's constructor with an initializer. + */ +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + inline void + _Construct(_Tp* __p, _Args&&... __args) + { +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + { + // Allow std::_Construct to be used in constant expressions. + std::construct_at(__p, std::forward<_Args>(__args)...); + return; + } +#endif + ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); + } +#else + template + inline void + _Construct(_T1* __p, const _T2& __value) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 402. wrong new expression in [some_]allocator::construct + ::new(static_cast(__p)) _T1(__value); + } +#endif + + template + inline void + _Construct_novalue(_T1* __p) + { ::new((void*)__p) _T1; } + + template + _GLIBCXX20_CONSTEXPR void + _Destroy(_ForwardIterator __first, _ForwardIterator __last); + + /** + * Destroy the object pointed to by a pointer type. + */ + template + _GLIBCXX14_CONSTEXPR inline void + _Destroy(_Tp* __pointer) + { +#if __cplusplus > 201703L + std::destroy_at(__pointer); +#else + __pointer->~_Tp(); +#endif + } + + template + struct _Destroy_aux + { + template + static _GLIBCXX20_CONSTEXPR void + __destroy(_ForwardIterator __first, _ForwardIterator __last) + { + for (; __first != __last; ++__first) + std::_Destroy(std::__addressof(*__first)); + } + }; + + template<> + struct _Destroy_aux + { + template + static void + __destroy(_ForwardIterator, _ForwardIterator) { } + }; + + /** + * Destroy a range of objects. If the value_type of the object has + * a trivial destructor, the compiler should optimize all of this + * away, otherwise the objects' destructors must be invoked. + */ + template + _GLIBCXX20_CONSTEXPR inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _Value_type; +#if __cplusplus >= 201103L + // A deleted destructor is trivial, this ensures we reject such types: + static_assert(is_destructible<_Value_type>::value, + "value type is destructible"); +#endif +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return _Destroy_aux::__destroy(__first, __last); +#endif + std::_Destroy_aux<__has_trivial_destructor(_Value_type)>:: + __destroy(__first, __last); + } + + template + struct _Destroy_n_aux + { + template + static _GLIBCXX20_CONSTEXPR _ForwardIterator + __destroy_n(_ForwardIterator __first, _Size __count) + { + for (; __count > 0; (void)++__first, --__count) + std::_Destroy(std::__addressof(*__first)); + return __first; + } + }; + + template<> + struct _Destroy_n_aux + { + template + static _ForwardIterator + __destroy_n(_ForwardIterator __first, _Size __count) + { + std::advance(__first, __count); + return __first; + } + }; + + /** + * Destroy a range of objects. If the value_type of the object has + * a trivial destructor, the compiler should optimize all of this + * away, otherwise the objects' destructors must be invoked. + */ + template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator + _Destroy_n(_ForwardIterator __first, _Size __count) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _Value_type; +#if __cplusplus >= 201103L + // A deleted destructor is trivial, this ensures we reject such types: + static_assert(is_destructible<_Value_type>::value, + "value type is destructible"); +#endif +#if __cplusplus >= 202002L + if (std::__is_constant_evaluated()) + return _Destroy_n_aux::__destroy_n(__first, __count); +#endif + return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>:: + __destroy_n(__first, __count); + } + +#if __cplusplus >= 201703L + template + _GLIBCXX20_CONSTEXPR inline void + destroy(_ForwardIterator __first, _ForwardIterator __last) + { + std::_Destroy(__first, __last); + } + + template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator + destroy_n(_ForwardIterator __first, _Size __count) + { + return std::_Destroy_n(__first, __count); + } +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_CONSTRUCT_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..902aea285d90b14a87255916b66ff6a0f8e13771 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_construct.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h new file mode 100644 index 0000000000000000000000000000000000000000..7fa9b0b3c09259d92701e0daa38b8459ab59730c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h @@ -0,0 +1,2385 @@ +// Deque implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_deque.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{deque} + */ + +#ifndef _STL_DEQUE_H +#define _STL_DEQUE_H 1 + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#include // for __is_bitwise_relocatable +#endif +#if __cplusplus > 201703L +# include +#endif + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * @brief This function controls the size of memory nodes. + * @param __size The size of an element. + * @return The number (not byte size) of elements per node. + * + * This function started off as a compiler kludge from SGI, but + * seems to be a useful wrapper around a repeated constant + * expression. The @b 512 is tunable (and no other code needs to + * change), but no investigation has been done since inheriting the + * SGI code. Touch _GLIBCXX_DEQUE_BUF_SIZE only if you know what + * you are doing, however: changing it breaks the binary + * compatibility!! + */ + +#ifndef _GLIBCXX_DEQUE_BUF_SIZE +#define _GLIBCXX_DEQUE_BUF_SIZE 512 +#endif + + _GLIBCXX_CONSTEXPR inline size_t + __deque_buf_size(size_t __size) + { return (__size < _GLIBCXX_DEQUE_BUF_SIZE + ? size_t(_GLIBCXX_DEQUE_BUF_SIZE / __size) : size_t(1)); } + + + /** + * @brief A deque::iterator. + * + * Quite a bit of intelligence here. Much of the functionality of + * deque is actually passed off to this class. A deque holds two + * of these internally, marking its valid range. Access to + * elements is done as offsets of either of those two, relying on + * operator overloading in this class. + * + * All the functions are op overloads except for _M_set_node. + */ + template + struct _Deque_iterator + { +#if __cplusplus < 201103L + typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; + typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; + typedef _Tp* _Elt_pointer; + typedef _Tp** _Map_pointer; +#else + private: + template + using __iter = _Deque_iterator<_Tp, _CvTp&, __ptr_rebind<_Ptr, _CvTp>>; + public: + typedef __iter<_Tp> iterator; + typedef __iter const_iterator; + typedef __ptr_rebind<_Ptr, _Tp> _Elt_pointer; + typedef __ptr_rebind<_Ptr, _Elt_pointer> _Map_pointer; +#endif + + static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT + { return __deque_buf_size(sizeof(_Tp)); } + + typedef std::random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Ptr pointer; + typedef _Ref reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Deque_iterator _Self; + + _Elt_pointer _M_cur; + _Elt_pointer _M_first; + _Elt_pointer _M_last; + _Map_pointer _M_node; + + _Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT + : _M_cur(__x), _M_first(*__y), + _M_last(*__y + _S_buffer_size()), _M_node(__y) { } + + _Deque_iterator() _GLIBCXX_NOEXCEPT + : _M_cur(), _M_first(), _M_last(), _M_node() { } + +#if __cplusplus < 201103L + // Conversion from iterator to const_iterator. + _Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } +#else + // Conversion from iterator to const_iterator. + template, + is_same<_Iter, iterator>>> + _Deque_iterator(const _Iter& __x) noexcept + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } + + _Deque_iterator(const _Deque_iterator& __x) noexcept + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } + + _Deque_iterator& operator=(const _Deque_iterator&) = default; +#endif + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(_M_cur, _M_node); } + + _GLIBCXX_NODISCARD + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *_M_cur; } + + _GLIBCXX_NODISCARD + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return _M_cur; } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + ++_M_cur; + if (_M_cur == _M_last) + { + _M_set_node(_M_node + 1); + _M_cur = _M_first; + } + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + ++*this; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + if (_M_cur == _M_first) + { + _M_set_node(_M_node - 1); + _M_cur = _M_last; + } + --_M_cur; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + --*this; + return __tmp; + } + + _Self& + operator+=(difference_type __n) _GLIBCXX_NOEXCEPT + { + const difference_type __offset = __n + (_M_cur - _M_first); + if (__offset >= 0 && __offset < difference_type(_S_buffer_size())) + _M_cur += __n; + else + { + const difference_type __node_offset = + __offset > 0 ? __offset / difference_type(_S_buffer_size()) + : -difference_type((-__offset - 1) + / _S_buffer_size()) - 1; + _M_set_node(_M_node + __node_offset); + _M_cur = _M_first + (__offset - __node_offset + * difference_type(_S_buffer_size())); + } + return *this; + } + + _Self& + operator-=(difference_type __n) _GLIBCXX_NOEXCEPT + { return *this += -__n; } + + _GLIBCXX_NODISCARD + reference + operator[](difference_type __n) const _GLIBCXX_NOEXCEPT + { return *(*this + __n); } + + /** + * Prepares to traverse new_node. Sets everything except + * _M_cur, which should therefore be set by the caller + * immediately afterwards, based on _M_first and _M_last. + */ + void + _M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT + { + _M_node = __new_node; + _M_first = *__new_node; + _M_last = _M_first + difference_type(_S_buffer_size()); + } + + _GLIBCXX_NODISCARD + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_cur == __y._M_cur; } + + // Note: we also provide overloads whose operands are of the same type in + // order to avoid ambiguous overload resolution when std::rel_ops + // operators are in scope (for additional details, see libstdc++/3628) + template + _GLIBCXX_NODISCARD + friend bool + operator==(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return __x._M_cur == __y._M_cur; } + +#if __cpp_lib_three_way_comparison + [[nodiscard]] + friend strong_ordering + operator<=>(const _Self& __x, const _Self& __y) noexcept + { + if (const auto __cmp = __x._M_node <=> __y._M_node; __cmp != 0) + return __cmp; + return __x._M_cur <=> __y._M_cur; + } +#else + _GLIBCXX_NODISCARD + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__x == __y); } + + template + _GLIBCXX_NODISCARD + friend bool + operator!=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__x == __y); } + + _GLIBCXX_NODISCARD + friend bool + operator<(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { + return (__x._M_node == __y._M_node) + ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + template + _GLIBCXX_NODISCARD + friend bool + operator<(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { + return (__x._M_node == __y._M_node) + ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + _GLIBCXX_NODISCARD + friend bool + operator>(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __y < __x; } + + template + _GLIBCXX_NODISCARD + friend bool + operator>(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return __y < __x; } + + _GLIBCXX_NODISCARD + friend bool + operator<=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__y < __x); } + + template + _GLIBCXX_NODISCARD + friend bool + operator<=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__y < __x); } + + _GLIBCXX_NODISCARD + friend bool + operator>=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__x < __y); } + + template + _GLIBCXX_NODISCARD + friend bool + operator>=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__x < __y); } +#endif // three-way comparison + + _GLIBCXX_NODISCARD + friend difference_type + operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - bool(__x._M_node)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template + _GLIBCXX_NODISCARD + friend difference_type + operator-(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - bool(__x._M_node)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + + _GLIBCXX_NODISCARD + friend _Self + operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _Self __tmp = __x; + __tmp += __n; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend _Self + operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _Self __tmp = __x; + __tmp -= __n; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend _Self + operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT + { return __x + __n; } + }; + + /** + * Deque base class. This class provides the unified face for %deque's + * allocation. This class's constructor and destructor allocate and + * deallocate (but do not initialize) storage. This makes %exception + * safety easier. + * + * Nothing in this class ever constructs or destroys an actual Tp element. + * (Deque handles that itself.) Only/All memory management is performed + * here. + */ + template + class _Deque_base + { + protected: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; + +#if __cplusplus < 201103L + typedef _Tp* _Ptr; + typedef const _Tp* _Ptr_const; +#else + typedef typename _Alloc_traits::pointer _Ptr; + typedef typename _Alloc_traits::const_pointer _Ptr_const; +#endif + + typedef typename _Alloc_traits::template rebind<_Ptr>::other + _Map_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits; + + typedef _Alloc allocator_type; + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Tp_allocator()); } + + typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator; + typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator; + + _Deque_base() + : _M_impl() + { _M_initialize_map(0); } + + _Deque_base(size_t __num_elements) + : _M_impl() + { _M_initialize_map(__num_elements); } + + _Deque_base(const allocator_type& __a, size_t __num_elements) + : _M_impl(__a) + { _M_initialize_map(__num_elements); } + + _Deque_base(const allocator_type& __a) + : _M_impl(__a) + { /* Caller must initialize map. */ } + +#if __cplusplus >= 201103L + _Deque_base(_Deque_base&& __x) + : _M_impl(std::move(__x._M_get_Tp_allocator())) + { + _M_initialize_map(0); + if (__x._M_impl._M_map) + this->_M_impl._M_swap_data(__x._M_impl); + } + + _Deque_base(_Deque_base&& __x, const allocator_type& __a) + : _M_impl(std::move(__x._M_impl), _Tp_alloc_type(__a)) + { __x._M_initialize_map(0); } + + _Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n) + : _M_impl(__a) + { + if (__x.get_allocator() == __a) + { + if (__x._M_impl._M_map) + { + _M_initialize_map(0); + this->_M_impl._M_swap_data(__x._M_impl); + } + } + else + { + _M_initialize_map(__n); + } + } +#endif + + ~_Deque_base() _GLIBCXX_NOEXCEPT; + + typedef typename iterator::_Map_pointer _Map_pointer; + + struct _Deque_impl_data + { + _Map_pointer _M_map; + size_t _M_map_size; + iterator _M_start; + iterator _M_finish; + + _Deque_impl_data() _GLIBCXX_NOEXCEPT + : _M_map(), _M_map_size(), _M_start(), _M_finish() + { } + +#if __cplusplus >= 201103L + _Deque_impl_data(const _Deque_impl_data&) = default; + _Deque_impl_data& + operator=(const _Deque_impl_data&) = default; + + _Deque_impl_data(_Deque_impl_data&& __x) noexcept + : _Deque_impl_data(__x) + { __x = _Deque_impl_data(); } +#endif + + void + _M_swap_data(_Deque_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + std::swap(*this, __x); + } + }; + + // This struct encapsulates the implementation of the std::deque + // standard container and at the same time makes use of the EBO + // for empty allocators. + struct _Deque_impl + : public _Tp_alloc_type, public _Deque_impl_data + { + _Deque_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Tp_alloc_type>::value) + : _Tp_alloc_type() + { } + + _Deque_impl(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Tp_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + _Deque_impl(_Deque_impl&&) = default; + + _Deque_impl(_Tp_alloc_type&& __a) noexcept + : _Tp_alloc_type(std::move(__a)) + { } + + _Deque_impl(_Deque_impl&& __d, _Tp_alloc_type&& __a) + : _Tp_alloc_type(std::move(__a)), _Deque_impl_data(std::move(__d)) + { } +#endif + }; + + _Tp_alloc_type& + _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Tp_alloc_type& + _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _Map_alloc_type + _M_get_map_allocator() const _GLIBCXX_NOEXCEPT + { return _Map_alloc_type(_M_get_Tp_allocator()); } + + _Ptr + _M_allocate_node() + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; + return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp))); + } + + void + _M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; + _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp))); + } + + _Map_pointer + _M_allocate_map(size_t __n) + { + _Map_alloc_type __map_alloc = _M_get_map_allocator(); + return _Map_alloc_traits::allocate(__map_alloc, __n); + } + + void + _M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT + { + _Map_alloc_type __map_alloc = _M_get_map_allocator(); + _Map_alloc_traits::deallocate(__map_alloc, __p, __n); + } + + void _M_initialize_map(size_t); + void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish); + void _M_destroy_nodes(_Map_pointer __nstart, + _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT; + enum { _S_initial_map_size = 8 }; + + _Deque_impl _M_impl; + }; + + template + _Deque_base<_Tp, _Alloc>:: + ~_Deque_base() _GLIBCXX_NOEXCEPT + { + if (this->_M_impl._M_map) + { + _M_destroy_nodes(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1); + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + } + } + + /** + * @brief Layout storage. + * @param __num_elements The count of T's for which to allocate space + * at first. + * @return Nothing. + * + * The initial underlying memory layout is a bit complicated... + */ + template + void + _Deque_base<_Tp, _Alloc>:: + _M_initialize_map(size_t __num_elements) + { + const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp)) + + 1); + + this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size, + size_t(__num_nodes + 2)); + this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); + + // For "small" maps (needing less than _M_map_size nodes), allocation + // starts in the middle elements and grows outwards. So nstart may be + // the beginning of _M_map, but for small maps it may be as far in as + // _M_map+3. + + _Map_pointer __nstart = (this->_M_impl._M_map + + (this->_M_impl._M_map_size - __num_nodes) / 2); + _Map_pointer __nfinish = __nstart + __num_nodes; + + __try + { _M_create_nodes(__nstart, __nfinish); } + __catch(...) + { + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + this->_M_impl._M_map = _Map_pointer(); + this->_M_impl._M_map_size = 0; + __throw_exception_again; + } + + this->_M_impl._M_start._M_set_node(__nstart); + this->_M_impl._M_finish._M_set_node(__nfinish - 1); + this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first; + this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first + + __num_elements + % __deque_buf_size(sizeof(_Tp))); + } + + template + void + _Deque_base<_Tp, _Alloc>:: + _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) + { + _Map_pointer __cur; + __try + { + for (__cur = __nstart; __cur < __nfinish; ++__cur) + *__cur = this->_M_allocate_node(); + } + __catch(...) + { + _M_destroy_nodes(__nstart, __cur); + __throw_exception_again; + } + } + + template + void + _Deque_base<_Tp, _Alloc>:: + _M_destroy_nodes(_Map_pointer __nstart, + _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT + { + for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n) + _M_deallocate_node(*__n); + } + + /** + * @brief A standard container using fixed-size memory allocation and + * constant-time manipulation of elements at either end. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements. + * + * In previous HP/SGI versions of deque, there was an extra template + * parameter so users could control the node size. This extension turned + * out to violate the C++ standard (it can be detected using template + * template parameters), and it was removed. + * + * Here's how a deque manages memory. Each deque has 4 members: + * + * - Tp** _M_map + * - size_t _M_map_size + * - iterator _M_start, _M_finish + * + * map_size is at least 8. %map is an array of map_size + * pointers-to-@a nodes. (The name %map has nothing to do with the + * std::map class, and @b nodes should not be confused with + * std::list's usage of @a node.) + * + * A @a node has no specific type name as such, but it is referred + * to as @a node in this file. It is a simple array-of-Tp. If Tp + * is very large, there will be one Tp element per node (i.e., an + * @a array of one). For non-huge Tp's, node size is inversely + * related to Tp size: the larger the Tp, the fewer Tp's will fit + * in a node. The goal here is to keep the total size of a node + * relatively small and constant over different Tp's, to improve + * allocator efficiency. + * + * Not every pointer in the %map array will point to a node. If + * the initial number of elements in the deque is small, the + * /middle/ %map pointers will be valid, and the ones at the edges + * will be unused. This same situation will arise as the %map + * grows: available %map pointers, if any, will be on the ends. As + * new nodes are created, only a subset of the %map's pointers need + * to be copied @a outward. + * + * Class invariants: + * - For any nonsingular iterator i: + * - i.node points to a member of the %map array. (Yes, you read that + * correctly: i.node does not actually point to a node.) The member of + * the %map array is what actually points to the node. + * - i.first == *(i.node) (This points to the node (first Tp element).) + * - i.last == i.first + node_size + * - i.cur is a pointer in the range [i.first, i.last). NOTE: + * the implication of this is that i.cur is always a dereferenceable + * pointer, even if i is a past-the-end iterator. + * - Start and Finish are always nonsingular iterators. NOTE: this + * means that an empty deque must have one node, a deque with > + class deque : protected _Deque_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::deque must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::deque must have the same value_type as its allocator"); +# endif +#endif + + typedef _Deque_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef typename _Base::_Alloc_traits _Alloc_traits; + typedef typename _Base::_Map_pointer _Map_pointer; + + public: + typedef _Tp value_type; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + private: + static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT + { return __deque_buf_size(sizeof(_Tp)); } + + // Functions controlling memory layout, and nothing else. + using _Base::_M_initialize_map; + using _Base::_M_create_nodes; + using _Base::_M_destroy_nodes; + using _Base::_M_allocate_node; + using _Base::_M_deallocate_node; + using _Base::_M_allocate_map; + using _Base::_M_deallocate_map; + using _Base::_M_get_Tp_allocator; + + /** + * A total of four data members accumulated down the hierarchy. + * May be accessed via _M_impl.* + */ + using _Base::_M_impl; + + public: + // [23.2.1.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %deque with no elements. + */ +#if __cplusplus >= 201103L + deque() = default; +#else + deque() { } +#endif + + /** + * @brief Creates a %deque with no elements. + * @param __a An allocator object. + */ + explicit + deque(const allocator_type& __a) + : _Base(__a, 0) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %deque with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator. + * + * This constructor fills the %deque with @a n default + * constructed elements. + */ + explicit + deque(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_default_initialize(); } + + /** + * @brief Creates a %deque with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %deque with @a __n copies of @a __value. + */ + deque(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_fill_initialize(__value); } +#else + /** + * @brief Creates a %deque with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %deque with @a __n copies of @a __value. + */ + explicit + deque(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_fill_initialize(__value); } +#endif + + /** + * @brief %Deque copy constructor. + * @param __x A %deque of identical element and allocator types. + * + * The newly-created %deque uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + deque(const deque& __x) + : _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()), + __x.size()) + { std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief %Deque move constructor. + * + * The newly-created %deque contains the exact contents of the + * moved instance. + * The contents of the moved instance are a valid, but unspecified + * %deque. + */ + deque(deque&&) = default; + + /// Copy constructor with alternative allocator + deque(const deque& __x, const __type_identity_t& __a) + : _Base(__a, __x.size()) + { std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } + + /// Move constructor with alternative allocator + deque(deque&& __x, const __type_identity_t& __a) + : deque(std::move(__x), __a, typename _Alloc_traits::is_always_equal{}) + { } + + private: + deque(deque&& __x, const allocator_type& __a, true_type) + : _Base(std::move(__x), __a) + { } + + deque(deque&& __x, const allocator_type& __a, false_type) + : _Base(std::move(__x), __a, __x.size()) + { + if (__x.get_allocator() != __a && !__x.empty()) + { + std::__uninitialized_move_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + __x.clear(); + } + } + + public: + /** + * @brief Builds a %deque from an initializer list. + * @param __l An initializer_list. + * @param __a An allocator object. + * + * Create a %deque consisting of copies of the elements in the + * initializer_list @a __l. + * + * This will call the element type's copy constructor N times + * (where N is __l.size()) and do no memory reallocation. + */ + deque(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /** + * @brief Builds a %deque from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator object. + * + * Create a %deque consisting of copies of the elements from [__first, + * __last). + * + * If the iterators are forward, bidirectional, or random-access, then + * this will call the elements' copy constructor N times (where N is + * distance(__first,__last)) and do no memory reallocation. But if only + * input iterators are used, then this will do at most 2N calls to the + * copy constructor, and logN memory reallocations. + */ +#if __cplusplus >= 201103L + template> + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#else + template + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~deque() + { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); } + + /** + * @brief %Deque assignment operator. + * @param __x A %deque of identical element and allocator types. + * + * All the elements of @a x are copied. + * + * The newly-created %deque uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + deque& + operator=(const deque& __x); + +#if __cplusplus >= 201103L + /** + * @brief %Deque move assignment operator. + * @param __x A %deque of identical element and allocator types. + * + * The contents of @a __x are moved into this deque (without copying, + * if the allocators permit it). + * @a __x is a valid, but unspecified %deque. + */ + deque& + operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal()) + { + using __always_equal = typename _Alloc_traits::is_always_equal; + _M_move_assign1(std::move(__x), __always_equal{}); + return *this; + } + + /** + * @brief Assigns an initializer list to a %deque. + * @param __l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a __l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ + deque& + operator=(initializer_list __l) + { + _M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %deque. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %deque with @a n copies of the given + * value. Note that the assignment completely changes the + * %deque and that the resulting %deque's size is the same as + * the number of elements assigned. + */ + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %deque with copies of the elements in the + * range [__first,__last). + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer list to a %deque. + * @param __l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a __l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ + void + assign(initializer_list __l) + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } +#endif + + /// Get a copy of the memory allocation object. + _GLIBCXX_NODISCARD + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _Base::get_allocator(); } + + // iterators + /** + * Returns a read/write iterator that points to the first element in the + * %deque. Iteration is done in ordinary element order. + */ + _GLIBCXX_NODISCARD + iterator + begin() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_start; } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %deque. Iteration is done in ordinary element order. + */ + _GLIBCXX_NODISCARD + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_start; } + + /** + * Returns a read/write iterator that points one past the last + * element in the %deque. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD + iterator + end() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %deque. Iteration is done in + * ordinary element order. + */ + _GLIBCXX_NODISCARD + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + /** + * Returns a read/write reverse iterator that points to the + * last element in the %deque. Iteration is done in reverse + * element order. + */ + _GLIBCXX_NODISCARD + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %deque. Iteration is done in + * reverse element order. + */ + _GLIBCXX_NODISCARD + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %deque. Iteration is done + * in reverse element order. + */ + _GLIBCXX_NODISCARD + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %deque. Iteration is + * done in reverse element order. + */ + _GLIBCXX_NODISCARD + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->_M_impl._M_start); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %deque. Iteration is done in ordinary element order. + */ + [[__nodiscard__]] + const_iterator + cbegin() const noexcept + { return this->_M_impl._M_start; } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %deque. Iteration is done in + * ordinary element order. + */ + [[__nodiscard__]] + const_iterator + cend() const noexcept + { return this->_M_impl._M_finish; } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %deque. Iteration is done in + * reverse element order. + */ + [[__nodiscard__]] + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %deque. Iteration is + * done in reverse element order. + */ + [[__nodiscard__]] + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(this->_M_impl._M_start); } +#endif + + // [23.2.1.2] capacity + /** Returns the number of elements in the %deque. */ + _GLIBCXX_NODISCARD + size_type + size() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish - this->_M_impl._M_start; } + + /** Returns the size() of the largest possible %deque. */ + _GLIBCXX_NODISCARD + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _S_max_size(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise + * default constructed elements are appended. + */ + void + resize(size_type __new_size) + { + const size_type __len = size(); + if (__new_size > __len) + _M_default_append(__new_size - __len); + else if (__new_size < __len) + _M_erase_at_end(this->_M_impl._M_start + + difference_type(__new_size)); + } + + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise the + * %deque is extended and new elements are populated with given + * data. + */ + void + resize(size_type __new_size, const value_type& __x) +#else + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise the + * %deque is extended and new elements are populated with given + * data. + */ + void + resize(size_type __new_size, value_type __x = value_type()) +#endif + { + const size_type __len = size(); + if (__new_size > __len) + _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); + else if (__new_size < __len) + _M_erase_at_end(this->_M_impl._M_start + + difference_type(__new_size)); + } + +#if __cplusplus >= 201103L + /** A non-binding request to reduce memory use. */ + void + shrink_to_fit() noexcept + { _M_shrink_to_fit(); } +#endif + + /** + * Returns true if the %deque is empty. (Thus begin() would + * equal end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish == this->_M_impl._M_start; } + + // element access + /** + * @brief Subscript access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX_NODISCARD + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } + + /** + * @brief Subscript access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX_NODISCARD + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } + + protected: + /// Safety check used only from at(). + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("deque::_M_range_check: __n " + "(which is %zu)>= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + /** + * @brief Provides access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the deque. The + * function throws out_of_range if the check fails. + */ + reference + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * @brief Provides access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter is first + * checked that it is in the range of the deque. The function throws + * out_of_range if the check fails. + */ + const_reference + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * Returns a read/write reference to the data at the first + * element of the %deque. + */ + _GLIBCXX_NODISCARD + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %deque. + */ + _GLIBCXX_NODISCARD + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read/write reference to the data at the last element of the + * %deque. + */ + _GLIBCXX_NODISCARD + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %deque. + */ + _GLIBCXX_NODISCARD + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + const_iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + // [23.2.1.2] modifiers + /** + * @brief Add data to the front of the %deque. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %deque and assigns the given + * data to it. Due to the nature of a %deque this operation + * can be done in constant time. + */ + void + push_front(const value_type& __x) + { + if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur - 1, + __x); + --this->_M_impl._M_start._M_cur; + } + else + _M_push_front_aux(__x); + } + +#if __cplusplus >= 201103L + void + push_front(value_type&& __x) + { emplace_front(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args); +#endif + + /** + * @brief Add data to the end of the %deque. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %deque and assigns the given data + * to it. Due to the nature of a %deque this operation can be + * done in constant time. + */ + void + push_back(const value_type& __x) + { + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_last - 1) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, __x); + ++this->_M_impl._M_finish._M_cur; + } + else + _M_push_back_aux(__x); + } + +#if __cplusplus >= 201103L + void + push_back(value_type&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args); +#endif + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %deque by one. + * + * Note that no data is returned, and if the first element's data is + * needed, it should be retrieved before pop_front() is called. + */ + void + pop_front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + if (this->_M_impl._M_start._M_cur + != this->_M_impl._M_start._M_last - 1) + { + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_start._M_cur); + ++this->_M_impl._M_start._M_cur; + } + else + _M_pop_front_aux(); + } + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %deque by one. + * + * Note that no data is returned, and if the last element's data is + * needed, it should be retrieved before pop_back() is called. + */ + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_first) + { + --this->_M_impl._M_finish._M_cur; + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_finish._M_cur); + } + else + _M_pop_back_aux(); + } + +#if __cplusplus >= 201103L + /** + * @brief Inserts an object in %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified location. + */ + template + iterator + emplace(const_iterator __position, _Args&&... __args); + + /** + * @brief Inserts given value into %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before the + * specified location. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %deque before specified iterator. + * @param __position An iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before the + * specified location. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before the + * specified location. + */ + iterator + insert(const_iterator __position, value_type&& __x) + { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer list into the %deque. + * @param __p An iterator into the %deque. + * @param __l An initializer_list. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the + * initializer_list @a __l into the %deque before the location + * specified by @a __p. This is known as list insert. + */ + iterator + insert(const_iterator __p, initializer_list __l) + { + auto __offset = __p - cbegin(); + _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } + + /** + * @brief Inserts a number of copies of given data into the %deque. + * @param __position A const_iterator into the %deque. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a specified number of copies of the given + * data before the location specified by @a __position. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(__position._M_const_cast(), __n, __x); + return begin() + __offset; + } +#else + /** + * @brief Inserts a number of copies of given data into the %deque. + * @param __position An iterator into the %deque. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of the given + * data before the location specified by @a __position. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %deque. + * @param __position A const_iterator into the %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %deque before the location specified + * by @a __position. This is known as range insert. + */ + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_range_insert_aux(__position._M_const_cast(), __first, __last, + std::__iterator_category(__first)); + return begin() + __offset; + } +#else + /** + * @brief Inserts a range into the %deque. + * @param __position An iterator into the %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %deque before the location specified + * by @a __position. This is known as range insert. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %deque by one. + * + * The user is cautioned that + * this function only erases the element, and that if the element is + * itself a pointer, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { return _M_erase(__position._M_const_cast()); } + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a last + * prior to erasing (or end()). + * + * This function will erase the elements in the range + * [__first,__last) and shorten the %deque accordingly. + * + * The user is cautioned that + * this function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } + + /** + * @brief Swaps data with another %deque. + * @param __x A %deque of the same element and allocator types. + * + * This exchanges the elements between two deques in constant time. + * (Four pointers, so it should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(d1,d2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(deque& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif + _M_impl._M_swap_data(__x._M_impl); + _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(begin()); } + + protected: + // Internal constructor functions follow. + +#if __cplusplus < 201103L + // called by the range constructor to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { + _M_initialize_map(_S_check_init_len(static_cast(__n), + _M_get_Tp_allocator())); + _M_fill_initialize(__x); + } + + // called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#endif + + static size_t + _S_check_init_len(size_t __n, const allocator_type& __a) + { + if (__n > _S_max_size(__a)) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + return __n; + } + + static size_type + _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + { + const size_t __diffmax = __gnu_cxx::__numeric_traits::__max; + const size_t __allocmax = _Alloc_traits::max_size(__a); + return (std::min)(__diffmax, __allocmax); + } + + // called by the second initialize_dispatch above + ///@{ + /** + * @brief Fills the deque with whatever is in [first,last). + * @param __first An input iterator. + * @param __last An input iterator. + * @return Nothing. + * + * If the iterators are actually forward iterators (or better), then the + * memory layout can be done all at once. Else we move forward using + * push_back on each value from the iterator. + */ + template + void + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // called by the second initialize_dispatch above + template + void + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag); + ///@} + + /** + * @brief Fills the %deque with copies of value. + * @param __value Initial value. + * @return Nothing. + * @pre _M_start and _M_finish have already been initialized, + * but none of the %deque's elements have yet been constructed. + * + * This function is called only when the user provides an explicit size + * (with or without an explicit exemplar value). + */ + void + _M_fill_initialize(const value_type& __value); + +#if __cplusplus >= 201103L + // called by deque(n). + void + _M_default_initialize(); +#endif + + // Internal assign functions follow. The *_aux functions do the actual + // assignment work for the range versions. + +#if __cplusplus < 201103L + // called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // called by the range assign to implement [23.1.1]/9 + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#endif + + // called by the second assign_dispatch above + template + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // called by the second assign_dispatch above + template + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + if (__len > size()) + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, begin()); + _M_range_insert_aux(end(), __mid, __last, + std::__iterator_category(__first)); + } + else + _M_erase_at_end(std::copy(__first, __last, begin())); + } + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + void + _M_fill_assign(size_type __n, const value_type& __val) + { + if (__n > size()) + { + std::fill(begin(), end(), __val); + _M_fill_insert(end(), __n - size(), __val); + } + else + { + _M_erase_at_end(begin() + difference_type(__n)); + std::fill(begin(), end(), __val); + } + } + + ///@{ + /// Helper functions for push_* and pop_*. +#if __cplusplus < 201103L + void _M_push_back_aux(const value_type&); + + void _M_push_front_aux(const value_type&); +#else + template + void _M_push_back_aux(_Args&&... __args); + + template + void _M_push_front_aux(_Args&&... __args); +#endif + + void _M_pop_back_aux(); + + void _M_pop_front_aux(); + ///@} + + // Internal insert functions follow. The *_aux functions do the actual + // insertion work when all shortcuts fail. + +#if __cplusplus < 201103L + // called by the range insert to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_insert_dispatch(iterator __pos, + _Integer __n, _Integer __x, __true_type) + { _M_fill_insert(__pos, __n, __x); } + + // called by the range insert to implement [23.1.1]/9 + template + void + _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_insert_aux(__pos, __first, __last, + std::__iterator_category(__first)); + } +#endif + + // called by the second insert_dispatch above + template + void + _M_range_insert_aux(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag); + + // called by the second insert_dispatch above + template + void + _M_range_insert_aux(iterator __pos, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + // Called by insert(p,n,x), and the range insert when it turns out to be + // the same thing. Can use fill functions in optimal situations, + // otherwise passes off to insert_aux(p,n,x). + void + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + + // called by insert(p,x) +#if __cplusplus < 201103L + iterator + _M_insert_aux(iterator __pos, const value_type& __x); +#else + template + iterator + _M_insert_aux(iterator __pos, _Args&&... __args); +#endif + + // called by insert(p,n,x) via fill_insert + void + _M_insert_aux(iterator __pos, size_type __n, const value_type& __x); + + // called by range_insert_aux for forward iterators + template + void + _M_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n); + + + // Internal erase functions follow. + + void + _M_destroy_data_aux(iterator __first, iterator __last); + + // Called by ~deque(). + // NB: Doesn't deallocate the nodes. + template + void + _M_destroy_data(iterator __first, iterator __last, const _Alloc1&) + { _M_destroy_data_aux(__first, __last); } + + void + _M_destroy_data(iterator __first, iterator __last, + const std::allocator<_Tp>&) + { + if (!__has_trivial_destructor(value_type)) + _M_destroy_data_aux(__first, __last); + } + + // Called by erase(q1, q2). + void + _M_erase_at_begin(iterator __pos) + { + _M_destroy_data(begin(), __pos, _M_get_Tp_allocator()); + _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node); + this->_M_impl._M_start = __pos; + } + + // Called by erase(q1, q2), resize(), clear(), _M_assign_aux, + // _M_fill_assign, operator=. + void + _M_erase_at_end(iterator __pos) + { + _M_destroy_data(__pos, end(), _M_get_Tp_allocator()); + _M_destroy_nodes(__pos._M_node + 1, + this->_M_impl._M_finish._M_node + 1); + this->_M_impl._M_finish = __pos; + } + + iterator + _M_erase(iterator __pos); + + iterator + _M_erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + // Called by resize(sz). + void + _M_default_append(size_type __n); + + bool + _M_shrink_to_fit(); +#endif + + ///@{ + /// Memory-handling helpers for the previous internal insert functions. + iterator + _M_reserve_elements_at_front(size_type __n) + { + const size_type __vacancies = this->_M_impl._M_start._M_cur + - this->_M_impl._M_start._M_first; + if (__n > __vacancies) + _M_new_elements_at_front(__n - __vacancies); + return this->_M_impl._M_start - difference_type(__n); + } + + iterator + _M_reserve_elements_at_back(size_type __n) + { + const size_type __vacancies = (this->_M_impl._M_finish._M_last + - this->_M_impl._M_finish._M_cur) - 1; + if (__n > __vacancies) + _M_new_elements_at_back(__n - __vacancies); + return this->_M_impl._M_finish + difference_type(__n); + } + + void + _M_new_elements_at_front(size_type __new_elements); + + void + _M_new_elements_at_back(size_type __new_elements); + ///@} + + + ///@{ + /** + * @brief Memory-handling helpers for the major %map. + * + * Makes sure the _M_map has space for new nodes. Does not + * actually add the nodes. Can invalidate _M_map pointers. + * (And consequently, %deque iterators.) + */ + void + _M_reserve_map_at_back(size_type __nodes_to_add = 1) + { + if (__nodes_to_add + 1 > this->_M_impl._M_map_size + - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map)) + _M_reallocate_map(__nodes_to_add, false); + } + + void + _M_reserve_map_at_front(size_type __nodes_to_add = 1) + { + if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node + - this->_M_impl._M_map)) + _M_reallocate_map(__nodes_to_add, true); + } + + void + _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); + ///@} + +#if __cplusplus >= 201103L + // Constant-time, nothrow move assignment when source object's memory + // can be moved because the allocators are equal. + void + _M_move_assign1(deque&& __x, /* always equal: */ true_type) noexcept + { + this->_M_impl._M_swap_data(__x._M_impl); + __x.clear(); + std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); + } + + // When the allocators are not equal the operation could throw, because + // we might need to allocate a new map for __x after moving from it + // or we might need to allocate new elements for *this. + void + _M_move_assign1(deque&& __x, /* always equal: */ false_type) + { + if (_M_get_Tp_allocator() == __x._M_get_Tp_allocator()) + return _M_move_assign1(std::move(__x), true_type()); + + constexpr bool __move_storage = + _Alloc_traits::_S_propagate_on_move_assign(); + _M_move_assign2(std::move(__x), __bool_constant<__move_storage>()); + } + + // Destroy all elements and deallocate all memory, then replace + // with elements created from __args. + template + void + _M_replace_map(_Args&&... __args) + { + // Create new data first, so if allocation fails there are no effects. + deque __newobj(std::forward<_Args>(__args)...); + // Free existing storage using existing allocator. + clear(); + _M_deallocate_node(*begin()._M_node); // one node left after clear() + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + this->_M_impl._M_map = nullptr; + this->_M_impl._M_map_size = 0; + // Take ownership of replacement memory. + this->_M_impl._M_swap_data(__newobj._M_impl); + } + + // Do move assignment when the allocator propagates. + void + _M_move_assign2(deque&& __x, /* propagate: */ true_type) + { + // Make a copy of the original allocator state. + auto __alloc = __x._M_get_Tp_allocator(); + // The allocator propagates so storage can be moved from __x, + // leaving __x in a valid empty state with a moved-from allocator. + _M_replace_map(std::move(__x)); + // Move the corresponding allocator state too. + _M_get_Tp_allocator() = std::move(__alloc); + } + + // Do move assignment when it may not be possible to move source + // object's memory, resulting in a linear-time operation. + void + _M_move_assign2(deque&& __x, /* propagate: */ false_type) + { + if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) + { + // The allocators are equal so storage can be moved from __x, + // leaving __x in a valid empty state with its current allocator. + _M_replace_map(std::move(__x), __x.get_allocator()); + } + else + { + // The rvalue's allocator cannot be moved and is not equal, + // so we need to individually move each element. + _M_assign_aux(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + std::random_access_iterator_tag()); + __x.clear(); + } + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + deque(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> deque<_ValT, _Allocator>; +#endif + + /** + * @brief Deque equality comparison. + * @param __x A %deque. + * @param __y A %deque of the same type as @a __x. + * @return True iff the size and elements of the deques are equal. + * + * This is an equivalence relation. It is linear in the size of the + * deques. Deques are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return __x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin()); } + +#if __cpp_lib_three_way_comparison + /** + * @brief Deque ordering relation. + * @param __x A `deque`. + * @param __y A `deque` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + [[nodiscard]] + inline __detail::__synth3way_t<_Tp> + operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Deque ordering relation. + * @param __x A %deque. + * @param __y A %deque of the same type as @a __x. + * @return True iff @a x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * deques. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator<=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::deque::swap(). + template + inline void + swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +#undef _GLIBCXX_DEQUE_BUF_SIZE + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus >= 201103L + // std::allocator is safe, but it is not the only allocator + // for which this is valid. + template + struct __is_bitwise_relocatable<_GLIBCXX_STD_C::deque<_Tp>> + : true_type { }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_DEQUE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3a637f30dfca27c31dd318edf3bef93e36c3bf0d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_deque.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h new file mode 100644 index 0000000000000000000000000000000000000000..fee07b27c275e096891df92c2213f974489daa69 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h @@ -0,0 +1,1441 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_function.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _STL_FUNCTION_H +#define _STL_FUNCTION_H 1 + +#if __cplusplus > 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 20.3.1 base classes + /** @defgroup functors Function Objects + * @ingroup utilities + * + * Function objects, or _functors_, are objects with an `operator()` + * defined and accessible. They can be passed as arguments to algorithm + * templates and used in place of a function pointer. Not only is the + * resulting expressiveness of the library increased, but the generated + * code can be more efficient than what you might write by hand. When we + * refer to _functors_, then, generally we include function pointers in + * the description as well. + * + * Often, functors are only created as temporaries passed to algorithm + * calls, rather than being created as named variables. + * + * Two examples taken from the standard itself follow. To perform a + * by-element addition of two vectors `a` and `b` containing `double`, + * and put the result in `a`, use + * \code + * transform (a.begin(), a.end(), b.begin(), a.begin(), plus()); + * \endcode + * To negate every element in `a`, use + * \code + * transform(a.begin(), a.end(), a.begin(), negate()); + * \endcode + * The addition and negation functions will usually be inlined directly. + * + * An _adaptable function object_ is one which provides nested typedefs + * `result_type` and either `argument_type` (for a unary function) or + * `first_argument_type` and `second_argument_type` (for a binary function). + * Those typedefs are used by function object adaptors such as `bind2nd`. + * The standard library provides two class templates, `unary_function` and + * `binary_function`, which define those typedefs and so can be used as + * base classes of adaptable function objects. + * + * Since C++11 the use of function object adaptors has been superseded by + * more powerful tools such as lambda expressions, `function<>`, and more + * powerful type deduction (using `auto` and `decltype`). The helpers for + * defining adaptable function objects are deprecated since C++11, and no + * longer part of the standard library since C++17. However, they are still + * defined and used by libstdc++ after C++17, as a conforming extension. + * + * @{ + */ + + /** + * Helper for defining adaptable unary function objects. + * @deprecated Deprecated in C++11, no longer in the standard since C++17. + */ + template + struct unary_function + { + /// @c argument_type is the type of the argument + typedef _Arg argument_type; + + /// @c result_type is the return type + typedef _Result result_type; + } _GLIBCXX11_DEPRECATED; + + /** + * Helper for defining adaptable binary function objects. + * @deprecated Deprecated in C++11, no longer in the standard since C++17. + */ + template + struct binary_function + { + /// @c first_argument_type is the type of the first argument + typedef _Arg1 first_argument_type; + + /// @c second_argument_type is the type of the second argument + typedef _Arg2 second_argument_type; + + /// @c result_type is the return type + typedef _Result result_type; + } _GLIBCXX11_DEPRECATED; + /** @} */ + + // 20.3.2 arithmetic + + /** @defgroup arithmetic_functors Arithmetic Function Object Classes + * @ingroup functors + * + * The library provides function objects for basic arithmetic operations. + * See the documentation for @link functors function objects @endlink + * for examples of their use. + * + * @{ + */ + +#if __cplusplus > 201103L + struct __is_transparent; // undefined + + template + struct plus; + + template + struct minus; + + template + struct multiplies; + + template + struct divides; + + template + struct modulus; + + template + struct negate; +#endif + +// Ignore warnings about unary_function and binary_function. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct plus : public binary_function<_Tp, _Tp, _Tp> + { + /// Returns the sum + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x + __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct minus : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x - __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct multiplies : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x * __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct divides : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x / __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct modulus : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x % __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct negate : public unary_function<_Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x) const + { return -__x; } + }; +#pragma GCC diagnostic pop + +#if __cplusplus > 201103L + +#define __cpp_lib_transparent_operators 201510L + + template<> + struct plus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct minus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct multiplies + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct divides + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct modulus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct negate + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(-std::forward<_Tp>(__t))) + -> decltype(-std::forward<_Tp>(__t)) + { return -std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif + /** @} */ + + // 20.3.3 comparisons + /** @defgroup comparison_functors Comparison Classes + * @ingroup functors + * + * The library provides six wrapper functors for all the basic comparisons + * in C++, like @c <. + * + * @{ + */ +#if __cplusplus > 201103L + template + struct equal_to; + + template + struct not_equal_to; + + template + struct greater; + + template + struct less; + + template + struct greater_equal; + + template + struct less_equal; +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct equal_to : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x == __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct not_equal_to : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x != __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct greater : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x > __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct less : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x < __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct greater_equal : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x >= __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct less_equal : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x <= __y; } + }; + + // Partial specialization of std::greater for pointers. + template + struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L + if (std::__is_constant_evaluated()) + return __x > __y; +#endif + return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::less for pointers. + template + struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L + if (std::__is_constant_evaluated()) + return __x < __y; +#endif + return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::greater_equal for pointers. + template + struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L + if (std::__is_constant_evaluated()) + return __x >= __y; +#endif + return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::less_equal for pointers. + template + struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L + if (std::__is_constant_evaluated()) + return __x <= __y; +#endif + return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y; + } + }; +#pragma GCC diagnostic pop + +#if __cplusplus >= 201402L + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct equal_to + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct not_equal_to + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct greater + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return greater>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return greater{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator> member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator>(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator> for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator>(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct less + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return less>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return less{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator< member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator<(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator< for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator<(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct greater_equal + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return greater_equal>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return greater_equal{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator>= member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator>=(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator>= for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator>=(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct less_equal + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return less_equal>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return less_equal{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator<= member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator<=(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator<= for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator<=(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; +#endif // C++14 + /** @} */ + + // 20.3.4 logical operations + /** @defgroup logical_functors Boolean Operations Classes + * @ingroup functors + * + * The library provides function objects for the logical operations: + * `&&`, `||`, and `!`. + * + * @{ + */ +#if __cplusplus > 201103L + template + struct logical_and; + + template + struct logical_or; + + template + struct logical_not; +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_and : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x && __y; } + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_or : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x || __y; } + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_not : public unary_function<_Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x) const + { return !__x; } + }; +#pragma GCC diagnostic pop + +#if __cplusplus > 201103L + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_and + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_or + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_not + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(!std::forward<_Tp>(__t))) + -> decltype(!std::forward<_Tp>(__t)) + { return !std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif + /** @} */ + +#if __cplusplus > 201103L + template + struct bit_and; + + template + struct bit_or; + + template + struct bit_xor; + + template + struct bit_not; +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 660. Missing Bitwise Operations. + template + struct bit_and : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x & __y; } + }; + + template + struct bit_or : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x | __y; } + }; + + template + struct bit_xor : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x ^ __y; } + }; + + template + struct bit_not : public unary_function<_Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x) const + { return ~__x; } + }; +#pragma GCC diagnostic pop + +#if __cplusplus > 201103L + template <> + struct bit_and + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_or + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_xor + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_not + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(~std::forward<_Tp>(__t))) + -> decltype(~std::forward<_Tp>(__t)) + { return ~std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif // C++14 + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + // 20.3.5 negators + /** @defgroup negators Negators + * @ingroup functors + * + * The function templates `not1` and `not2` are function object adaptors, + * which each take a predicate functor and wrap it in an instance of + * `unary_negate` or `binary_negate`, respectively. Those classes are + * functors whose `operator()` evaluates the wrapped predicate function + * and then returns the negation of the result. + * + * For example, given a vector of integers and a trivial predicate, + * \code + * struct IntGreaterThanThree + * : public std::unary_function + * { + * bool operator() (int x) const { return x > 3; } + * }; + * + * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); + * \endcode + * The call to `find_if` will locate the first index (i) of `v` for which + * `!(v[i] > 3)` is true. + * + * The not1/unary_negate combination works on predicates taking a single + * argument. The not2/binary_negate combination works on predicates taking + * two arguments. + * + * @deprecated Deprecated in C++17, no longer in the standard since C++20. + * Use `not_fn` instead. + * + * @{ + */ + /// One of the @link negators negation functors@endlink. + template + class _GLIBCXX17_DEPRECATED unary_negate + : public unary_function + { + protected: + _Predicate _M_pred; + + public: + _GLIBCXX14_CONSTEXPR + explicit + unary_negate(const _Predicate& __x) : _M_pred(__x) { } + + _GLIBCXX14_CONSTEXPR + bool + operator()(const typename _Predicate::argument_type& __x) const + { return !_M_pred(__x); } + }; + + /// One of the @link negators negation functors@endlink. + template + _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn") + _GLIBCXX14_CONSTEXPR + inline unary_negate<_Predicate> + not1(const _Predicate& __pred) + { return unary_negate<_Predicate>(__pred); } + + /// One of the @link negators negation functors@endlink. + template + class _GLIBCXX17_DEPRECATED binary_negate + : public binary_function + { + protected: + _Predicate _M_pred; + + public: + _GLIBCXX14_CONSTEXPR + explicit + binary_negate(const _Predicate& __x) : _M_pred(__x) { } + + _GLIBCXX14_CONSTEXPR + bool + operator()(const typename _Predicate::first_argument_type& __x, + const typename _Predicate::second_argument_type& __y) const + { return !_M_pred(__x, __y); } + }; + + /// One of the @link negators negation functors@endlink. + template + _GLIBCXX17_DEPRECATED_SUGGEST("std::not_fn") + _GLIBCXX14_CONSTEXPR + inline binary_negate<_Predicate> + not2(const _Predicate& __pred) + { return binary_negate<_Predicate>(__pred); } + /** @} */ + + // 20.3.7 adaptors pointers functions + /** @defgroup pointer_adaptors Adaptors for pointers to functions + * @ingroup functors + * + * The advantage of function objects over pointers to functions is that + * the objects in the standard library declare nested typedefs describing + * their argument and result types with uniform names (e.g., `result_type` + * from the base classes `unary_function` and `binary_function`). + * Sometimes those typedefs are required, not just optional. + * + * Adaptors are provided to turn pointers to unary (single-argument) and + * binary (double-argument) functions into function objects. The + * long-winded functor `pointer_to_unary_function` is constructed with a + * function pointer `f`, and its `operator()` called with argument `x` + * returns `f(x)`. The functor `pointer_to_binary_function` does the same + * thing, but with a double-argument `f` and `operator()`. + * + * The function `ptr_fun` takes a pointer-to-function `f` and constructs + * an instance of the appropriate functor. + * + * @deprecated Deprecated in C++11, no longer in the standard since C++17. + * + * @{ + */ + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + 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); } + } _GLIBCXX11_DEPRECATED; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::function") + inline pointer_to_unary_function<_Arg, _Result> + ptr_fun(_Result (*__x)(_Arg)) + { return pointer_to_unary_function<_Arg, _Result>(__x); } + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + 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); } + } _GLIBCXX11_DEPRECATED; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::function") + inline pointer_to_binary_function<_Arg1, _Arg2, _Result> + ptr_fun(_Result (*__x)(_Arg1, _Arg2)) + { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } + /** @} */ + + template + struct _Identity + : public unary_function<_Tp, _Tp> + { + _Tp& + operator()(_Tp& __x) const + { return __x; } + + const _Tp& + operator()(const _Tp& __x) const + { return __x; } + }; + + // Partial specialization, avoids confusing errors in e.g. std::set. + template struct _Identity : _Identity<_Tp> { }; + + template + struct _Select1st + : public unary_function<_Pair, typename _Pair::first_type> + { + typename _Pair::first_type& + operator()(_Pair& __x) const + { return __x.first; } + + const typename _Pair::first_type& + operator()(const _Pair& __x) const + { return __x.first; } + +#if __cplusplus >= 201103L + template + typename _Pair2::first_type& + operator()(_Pair2& __x) const + { return __x.first; } + + template + const typename _Pair2::first_type& + operator()(const _Pair2& __x) const + { return __x.first; } +#endif + }; + + template + struct _Select2nd + : public unary_function<_Pair, typename _Pair::second_type> + { + typename _Pair::second_type& + operator()(_Pair& __x) const + { return __x.second; } + + const typename _Pair::second_type& + operator()(const _Pair& __x) const + { return __x.second; } + }; + + // 20.3.8 adaptors pointers members + /** @defgroup ptrmem_adaptors Adaptors for pointers to members + * @ingroup functors + * + * There are a total of 8 = 2^3 function objects in this family. + * (1) Member functions taking no arguments vs member functions taking + * one argument. + * (2) Call through pointer vs call through reference. + * (3) Const vs non-const member function. + * + * All of this complexity is in the function objects themselves. You can + * ignore it by using the helper function `mem_fun` and `mem_fun_ref`, + * which create whichever type of adaptor is appropriate. + * + * @deprecated Deprecated in C++11, no longer in the standard since C++17. + * Use `mem_fn` instead. + * + * @{ + */ + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class mem_fun_t : public unary_function<_Tp*, _Ret> + { + public: + explicit + mem_fun_t(_Ret (_Tp::*__pf)()) + : _M_f(__pf) { } + + _Ret + operator()(_Tp* __p) const + { return (__p->*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)(); + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class const_mem_fun_t : public unary_function + { + public: + explicit + const_mem_fun_t(_Ret (_Tp::*__pf)() const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp* __p) const + { return (__p->*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)() const; + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class mem_fun_ref_t : public unary_function<_Tp, _Ret> + { + public: + explicit + mem_fun_ref_t(_Ret (_Tp::*__pf)()) + : _M_f(__pf) { } + + _Ret + operator()(_Tp& __r) const + { return (__r.*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)(); + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> + { + public: + explicit + const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp& __r) const + { return (__r.*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)() const; + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> + { + public: + explicit + mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) + : _M_f(__pf) { } + + _Ret + operator()(_Tp* __p, _Arg __x) const + { return (__p->*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg); + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class const_mem_fun1_t : public binary_function + { + public: + explicit + const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp* __p, _Arg __x) const + { return (__p->*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg) const; + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> + { + public: + explicit + mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) + : _M_f(__pf) { } + + _Ret + operator()(_Tp& __r, _Arg __x) const + { return (__r.*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg); + } _GLIBCXX11_DEPRECATED; + + /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. + template + class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> + { + public: + explicit + const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp& __r, _Arg __x) const + { return (__r.*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg) const; + } _GLIBCXX11_DEPRECATED; + + // Mem_fun adaptor helper functions. There are only two: + // mem_fun and mem_fun_ref. + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + inline mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)()) + { return mem_fun_t<_Ret, _Tp>(__f); } + + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + inline const_mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)() const) + { return const_mem_fun_t<_Ret, _Tp>(__f); } + + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + inline mem_fun_ref_t<_Ret, _Tp> + mem_fun_ref(_Ret (_Tp::*__f)()) + { return mem_fun_ref_t<_Ret, _Tp>(__f); } + + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + 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 + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + inline mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + 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 + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + 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 + _GLIBCXX11_DEPRECATED_SUGGEST("std::mem_fn") + 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); } +#pragma GCC diagnostic pop + + /** @} */ + +#if __cplusplus >= 201402L + template> + struct __has_is_transparent + { }; + + template + struct __has_is_transparent<_Func, _SfinaeType, + __void_t> + { typedef void type; }; + + template + using __has_is_transparent_t + = typename __has_is_transparent<_Func, _SfinaeType>::type; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED +# include +#endif + +#endif /* _STL_FUNCTION_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4612cd0faa92aa3503e3a52d42f4be6236dabc1f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_function.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h new file mode 100644 index 0000000000000000000000000000000000000000..eee946c3818bf84736faa95ca09b8731449894c1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h @@ -0,0 +1,584 @@ +// Heap implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_heap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{queue} + */ + +#ifndef _STL_HEAP_H +#define _STL_HEAP_H 1 + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup heap_algorithms Heap + * @ingroup sorting_algorithms + */ + + template + _GLIBCXX20_CONSTEXPR + _Distance + __is_heap_until(_RandomAccessIterator __first, _Distance __n, + _Compare& __comp) + { + _Distance __parent = 0; + for (_Distance __child = 1; __child < __n; ++__child) + { + if (__comp(__first + __parent, __first + __child)) + return __child; + if ((__child & 1) == 0) + ++__parent; + } + return __n; + } + + // __is_heap, a predicate testing whether or not a range is a heap. + // This function is an extension, not part of the C++ standard. + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _Distance __n) + { + __gnu_cxx::__ops::_Iter_less_iter __comp; + return std::__is_heap_until(__first, __n, __comp) == __n; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n) + { + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return std::__is_heap_until(__first, __n, __cmp) == __n; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::__is_heap(__first, std::distance(__first, __last)); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + return std::__is_heap(__first, _GLIBCXX_MOVE(__comp), + std::distance(__first, __last)); + } + + // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap, + // + is_heap and is_heap_until in C++0x. + + template + _GLIBCXX20_CONSTEXPR + void + __push_heap(_RandomAccessIterator __first, + _Distance __holeIndex, _Distance __topIndex, _Tp __value, + _Compare& __comp) + { + _Distance __parent = (__holeIndex - 1) / 2; + while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) + { + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __parent)); + __holeIndex = __parent; + __parent = (__holeIndex - 1) / 2; + } + *(__first + __holeIndex) = _GLIBCXX_MOVE(__value); + } + + /** + * @brief Push an element onto a heap. + * @param __first Start of heap. + * @param __last End of heap + element. + * @ingroup heap_algorithms + * + * This operation pushes the element at last-1 onto the valid heap + * over the range [__first,__last-1). After completion, + * [__first,__last) is a valid heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last - 1); + + __gnu_cxx::__ops::_Iter_less_val __comp; + _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); + std::__push_heap(__first, _DistanceType((__last - __first) - 1), + _DistanceType(0), _GLIBCXX_MOVE(__value), __comp); + } + + /** + * @brief Push an element onto a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap + element. + * @param __comp Comparison functor. + * @ingroup heap_algorithms + * + * This operation pushes the element at __last-1 onto the valid + * heap over the range [__first,__last-1). After completion, + * [__first,__last) is a valid heap. Compare operations are + * performed using comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_heap_pred(__first, __last - 1, __comp); + + __decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp))) + __cmp(_GLIBCXX_MOVE(__comp)); + _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); + std::__push_heap(__first, _DistanceType((__last - __first) - 1), + _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __value, _Compare __comp) + { + const _Distance __topIndex = __holeIndex; + _Distance __secondChild = __holeIndex; + while (__secondChild < (__len - 1) / 2) + { + __secondChild = 2 * (__secondChild + 1); + if (__comp(__first + __secondChild, + __first + (__secondChild - 1))) + __secondChild--; + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild)); + __holeIndex = __secondChild; + } + if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2) + { + __secondChild = 2 * (__secondChild + 1); + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + + (__secondChild - 1))); + __holeIndex = __secondChild - 1; + } + __decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp))) + __cmp(_GLIBCXX_MOVE(__comp)); + std::__push_heap(__first, __holeIndex, __topIndex, + _GLIBCXX_MOVE(__value), __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _RandomAccessIterator __result, _Compare& __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + _ValueType __value = _GLIBCXX_MOVE(*__result); + *__result = _GLIBCXX_MOVE(*__first); + std::__adjust_heap(__first, _DistanceType(0), + _DistanceType(__last - __first), + _GLIBCXX_MOVE(__value), __comp); + } + + /** + * @brief Pop an element off a heap. + * @param __first Start of heap. + * @param __last End of heap. + * @pre [__first, __last) is a valid, non-empty range. + * @ingroup heap_algorithms + * + * This operation pops the top of the heap. The elements __first + * and __last-1 are swapped and [__first,__last-1) is made into a + * heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_non_empty_range(__first, __last); + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last); + + if (__last - __first > 1) + { + --__last; + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__pop_heap(__first, __last, __last, __comp); + } + } + + /** + * @brief Pop an element off a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation pops the top of the heap. The elements __first + * and __last-1 are swapped and [__first,__last-1) is made into a + * heap. Comparisons are made using comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_non_empty_range(__first, __last); + __glibcxx_requires_heap_pred(__first, __last, __comp); + + if (__last - __first > 1) + { + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + --__last; + std::__pop_heap(__first, __last, __last, __cmp); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare& __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + if (__last - __first < 2) + return; + + const _DistanceType __len = __last - __first; + _DistanceType __parent = (__len - 2) / 2; + while (true) + { + _ValueType __value = _GLIBCXX_MOVE(*(__first + __parent)); + std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), + __comp); + if (__parent == 0) + return; + __parent--; + } + } + + /** + * @brief Construct a heap over a range. + * @param __first Start of heap. + * @param __last End of heap. + * @ingroup heap_algorithms + * + * This operation makes the elements in [__first,__last) into a heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__make_heap(__first, __last, __comp); + } + + /** + * @brief Construct a heap over a range using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation makes the elements in [__first,__last) into a heap. + * Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + std::__make_heap(__first, __last, __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare& __comp) + { + while (__last - __first > 1) + { + --__last; + std::__pop_heap(__first, __last, __last, __comp); + } + } + + /** + * @brief Sort a heap. + * @param __first Start of heap. + * @param __last End of heap. + * @ingroup heap_algorithms + * + * This operation sorts the valid heap in the range [__first,__last). + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__sort_heap(__first, __last, __comp); + } + + /** + * @brief Sort a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation sorts the valid heap in the range [__first,__last). + * Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_heap_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + std::__sort_heap(__first, __last, __cmp); + } + +#if __cplusplus >= 201103L + /** + * @brief Search the end of a heap. + * @param __first Start of range. + * @param __last End of range. + * @return An iterator pointing to the first element not in the heap. + * @ingroup heap_algorithms + * + * This operation returns the last iterator i in [__first, __last) for which + * the range [__first, i) is a heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + return __first + + std::__is_heap_until(__first, std::distance(__first, __last), __comp); + } + + /** + * @brief Search the end of a heap using comparison functor. + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor to use. + * @return An iterator pointing to the first element not in the heap. + * @ingroup heap_algorithms + * + * This operation returns the last iterator i in [__first, __last) for which + * the range [__first, i) is a heap. Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return __first + + std::__is_heap_until(__first, std::distance(__first, __last), __cmp); + } + + /** + * @brief Determines whether a range is a heap. + * @param __first Start of range. + * @param __last End of range. + * @return True if range is a heap, false otherwise. + * @ingroup heap_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::is_heap_until(__first, __last) == __last; } + + /** + * @brief Determines whether a range is a heap using comparison functor. + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor to use. + * @return True if range is a heap, false otherwise. + * @ingroup heap_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + const auto __dist = std::distance(__first, __last); + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return std::__is_heap_until(__first, __dist, __cmp) == __dist; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_HEAP_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..065602a330ff17dffc45cfca9508d43013ac5095 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_heap.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..15b9affc4b9004901f4fef4547451391f7fd277e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h @@ -0,0 +1,2608 @@ +// Iterators -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file implements reverse_iterator, back_insert_iterator, + * front_insert_iterator, insert_iterator, __normal_iterator, and their + * supporting functions and overloaded operators. + */ + +#ifndef _STL_ITERATOR_H +#define _STL_ITERATOR_H 1 + +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +# include +#endif + +#if __cplusplus > 201703L +# define __cpp_lib_array_constexpr 201811L +# define __cpp_lib_constexpr_iterator 201811L +#elif __cplusplus == 201703L +# define __cpp_lib_array_constexpr 201803L +#endif + +#if __cplusplus >= 202002L +# include +# include +# include +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + +#if __cpp_lib_concepts + namespace __detail + { + // Weaken iterator_category _Cat to _Limit if it is derived from that, + // otherwise use _Otherwise. + template + using __clamp_iter_cat + = __conditional_t, _Limit, _Otherwise>; + } +#endif + +// Ignore warnings about std::iterator. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + // 24.4.1 Reverse iterators + /** + * Bidirectional and random access iterators have corresponding reverse + * %iterator adaptors that iterate through the data structure in the + * opposite direction. They have the same signatures as the corresponding + * iterators. The fundamental relation between a reverse %iterator and its + * corresponding %iterator @c i is established by the identity: + * @code + * &*(reverse_iterator(i)) == &*(i - 1) + * @endcode + * + * This mapping is dictated by the fact that while there is always a + * pointer past the end of an array, there might not be a valid pointer + * before the beginning of an array. [24.4.1]/1,2 + * + * Reverse iterators can be tricky and surprising at first. Their + * semantics make sense, however, and the trickiness is a side effect of + * the requirement that the iterators must be safe. + */ + template + class reverse_iterator + : public 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> + { + template + friend class reverse_iterator; + +#if __cpp_lib_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3435. three_way_comparable_with, [...]> + template + static constexpr bool __convertible = !is_same_v<_Iter, _Iterator> + && convertible_to; +#endif + + protected: + _Iterator current; + + typedef iterator_traits<_Iterator> __traits_type; + + public: + typedef _Iterator iterator_type; + typedef typename __traits_type::pointer pointer; +#if ! __cpp_lib_concepts + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::reference reference; +#else + using iterator_concept + = __conditional_t, + random_access_iterator_tag, + bidirectional_iterator_tag>; + using iterator_category + = __detail::__clamp_iter_cat; + using value_type = iter_value_t<_Iterator>; + using difference_type = iter_difference_t<_Iterator>; + using reference = iter_reference_t<_Iterator>; +#endif + + /** + * The default constructor value-initializes member @p current. + * If it is a pointer, that means it is zero-initialized. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 235 No specification of default ctor for reverse_iterator + // 1012. reverse_iterator default ctor should value initialize + _GLIBCXX17_CONSTEXPR + reverse_iterator() + _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator())) + : current() + { } + + /** + * This %iterator will move in the opposite direction that @p x does. + */ + explicit _GLIBCXX17_CONSTEXPR + reverse_iterator(iterator_type __x) + _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x))) + : current(__x) + { } + + /** + * The copy constructor is normal. + */ + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator& __x) + _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x.current))) + : current(__x.current) + { } + +#if __cplusplus >= 201103L + reverse_iterator& operator=(const reverse_iterator&) = default; +#endif + + /** + * A %reverse_iterator across other types can be copied if the + * underlying %iterator can be converted to the type of @c current. + */ + template +#if __cpp_lib_concepts + requires __convertible<_Iter> +#endif + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator<_Iter>& __x) + _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x.current))) + : current(__x.current) + { } + +#if __cplusplus >= 201103L + template +#if __cpp_lib_concepts + requires __convertible<_Iter> + && assignable_from<_Iterator&, const _Iter&> +#endif + _GLIBCXX17_CONSTEXPR + reverse_iterator& + operator=(const reverse_iterator<_Iter>& __x) + _GLIBCXX_NOEXCEPT_IF(noexcept(current = __x.current)) + { + current = __x.current; + return *this; + } +#endif + + /** + * @return @c current, the %iterator used for underlying work. + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR iterator_type + base() const + _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(current))) + { return current; } + + /** + * @return A reference to the value at @c --current + * + * This requires that @c --current is dereferenceable. + * + * @warning This implementation requires that for an iterator of the + * underlying iterator type, @c x, a reference obtained by + * @c *x remains valid after @c x has been modified or + * destroyed. This is a bug: http://gcc.gnu.org/PR51823 + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR reference + operator*() const + { + _Iterator __tmp = current; + return *--__tmp; + } + + /** + * @return A pointer to the value at @c --current + * + * This requires that @c --current is dereferenceable. + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR pointer + operator->() const +#if __cplusplus > 201703L && __cpp_concepts >= 201907L + requires is_pointer_v<_Iterator> + || requires(const _Iterator __i) { __i.operator->(); } +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 1052. operator-> should also support smart pointers + _Iterator __tmp = current; + --__tmp; + return _S_to_pointer(__tmp); + } + + /** + * @return @c *this + * + * Decrements the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator++() + { + --current; + return *this; + } + + /** + * @return The original value of @c *this + * + * Decrements the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator++(int) + { + reverse_iterator __tmp = *this; + --current; + return __tmp; + } + + /** + * @return @c *this + * + * Increments the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator--() + { + ++current; + return *this; + } + + /** + * @return A reverse_iterator with the previous value of @c *this + * + * Increments the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator--(int) + { + reverse_iterator __tmp = *this; + ++current; + return __tmp; + } + + /** + * @return A reverse_iterator that refers to @c current - @a __n + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR reverse_iterator + operator+(difference_type __n) const + { return reverse_iterator(current - __n); } + + /** + * @return *this + * + * Moves the underlying iterator backwards @a __n steps. + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator+=(difference_type __n) + { + current -= __n; + return *this; + } + + /** + * @return A reverse_iterator that refers to @c current - @a __n + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR reverse_iterator + operator-(difference_type __n) const + { return reverse_iterator(current + __n); } + + /** + * @return *this + * + * Moves the underlying iterator forwards @a __n steps. + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator-=(difference_type __n) + { + current += __n; + return *this; + } + + /** + * @return The value at @c current - @a __n - 1 + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX_NODISCARD + _GLIBCXX17_CONSTEXPR reference + operator[](difference_type __n) const + { return *(*this + __n); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + [[nodiscard]] + friend constexpr iter_rvalue_reference_t<_Iterator> + iter_move(const reverse_iterator& __i) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(ranges::iter_move(--std::declval<_Iterator&>()))) + { + auto __tmp = __i.base(); + return ranges::iter_move(--__tmp); + } + + template _Iter2> + friend constexpr void + iter_swap(const reverse_iterator& __x, + const reverse_iterator<_Iter2>& __y) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && is_nothrow_copy_constructible_v<_Iter2> + && noexcept(ranges::iter_swap(--std::declval<_Iterator&>(), + --std::declval<_Iter2&>()))) + { + auto __xtmp = __x.base(); + auto __ytmp = __y.base(); + ranges::iter_swap(--__xtmp, --__ytmp); + } +#endif + + private: + template + static _GLIBCXX17_CONSTEXPR _Tp* + _S_to_pointer(_Tp* __p) + { return __p; } + + template + static _GLIBCXX17_CONSTEXPR pointer + _S_to_pointer(_Tp __t) + { return __t.operator->(); } + }; + + ///@{ + /** + * @param __x A %reverse_iterator. + * @param __y A %reverse_iterator. + * @return A simple bool. + * + * Reverse iterators forward comparisons to their underlying base() + * iterators. + * + */ +#if __cplusplus <= 201703L || ! defined __cpp_lib_concepts + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator<(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() < __x.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y < __x; } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__x < __y); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 280. Comparison of reverse_iterator to const reverse_iterator. + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator==(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() == __y.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator<(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() > __y.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() != __y.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() < __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() >= __y.base(); } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() <= __y.base(); } +#else // C++20 + template + [[nodiscard]] + constexpr bool + operator==(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() == __y.base() } -> convertible_to; } + { return __x.base() == __y.base(); } + + template + [[nodiscard]] + constexpr bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() != __y.base() } -> convertible_to; } + { return __x.base() != __y.base(); } + + template + [[nodiscard]] + constexpr bool + operator<(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() > __y.base() } -> convertible_to; } + { return __x.base() > __y.base(); } + + template + [[nodiscard]] + constexpr bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() < __y.base() } -> convertible_to; } + { return __x.base() < __y.base(); } + + template + [[nodiscard]] + constexpr bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() >= __y.base() } -> convertible_to; } + { return __x.base() >= __y.base(); } + + template + [[nodiscard]] + constexpr bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() <= __y.base() } -> convertible_to; } + { return __x.base() <= __y.base(); } + + template _IteratorR> + [[nodiscard]] + constexpr compare_three_way_result_t<_IteratorL, _IteratorR> + operator<=>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() <=> __x.base(); } + + // Additional, non-standard overloads to avoid ambiguities with greedy, + // unconstrained overloads in associated namespaces. + + template + [[nodiscard]] + constexpr bool + operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + requires requires { { __x.base() == __y.base() } -> convertible_to; } + { return __x.base() == __y.base(); } + + template + [[nodiscard]] + constexpr compare_three_way_result_t<_Iterator, _Iterator> + operator<=>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() <=> __x.base(); } +#endif // C++20 + ///@} + +#if __cplusplus < 201103L + template + inline typename reverse_iterator<_Iterator>::difference_type + operator-(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() - __x.base(); } + + template + inline typename reverse_iterator<_IteratorL>::difference_type + operator-(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() - __x.base(); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 685. reverse_iterator/move_iterator difference has invalid signatures + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + operator-(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + -> decltype(__y.base() - __x.base()) + { return __y.base() - __x.base(); } +#endif + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + operator+(typename reverse_iterator<_Iterator>::difference_type __n, + const reverse_iterator<_Iterator>& __x) + { return reverse_iterator<_Iterator>(__x.base() - __n); } + +#if __cplusplus >= 201103L + // Same as C++14 make_reverse_iterator but used in C++11 mode too. + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + __make_reverse_iterator(_Iterator __i) + { return reverse_iterator<_Iterator>(__i); } + +# if __cplusplus >= 201402L +# define __cpp_lib_make_reverse_iterator 201402L + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 2285. make_reverse_iterator + /// Generator function for reverse_iterator. + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + make_reverse_iterator(_Iterator __i) + { return reverse_iterator<_Iterator>(__i); } + +# if __cplusplus > 201703L && defined __cpp_lib_concepts + template + requires (!sized_sentinel_for<_Iterator1, _Iterator2>) + inline constexpr bool + disable_sized_sentinel_for, + reverse_iterator<_Iterator2>> = true; +# endif // C++20 +# endif // C++14 + + template + _GLIBCXX20_CONSTEXPR + auto + __niter_base(reverse_iterator<_Iterator> __it) + -> decltype(__make_reverse_iterator(__niter_base(__it.base()))) + { return __make_reverse_iterator(__niter_base(__it.base())); } + + template + struct __is_move_iterator > + : __is_move_iterator<_Iterator> + { }; + + template + _GLIBCXX20_CONSTEXPR + auto + __miter_base(reverse_iterator<_Iterator> __it) + -> decltype(__make_reverse_iterator(__miter_base(__it.base()))) + { return __make_reverse_iterator(__miter_base(__it.base())); } +#endif // C++11 + + // 24.4.2.2.1 back_insert_iterator + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator appends it to the container using + * push_back. + * + * Tip: Using the back_inserter function to create these iterators can + * save typing. + */ + template + class back_insert_iterator + : public iterator + { + protected: + _Container* container; + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + + /// The only way to create this %iterator is with a container. + explicit _GLIBCXX20_CONSTEXPR + back_insert_iterator(_Container& __x) + : container(std::__addressof(__x)) { } + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator doesn't really have a @a position in the + * container (you can think of the position as being permanently at + * the end, if you like). Assigning a value to the %iterator will + * always append the value to the end of the container. + */ +#if __cplusplus < 201103L + back_insert_iterator& + operator=(typename _Container::const_reference __value) + { + container->push_back(__value); + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator=(const typename _Container::value_type& __value) + { + container->push_back(__value); + return *this; + } + + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator=(typename _Container::value_type&& __value) + { + container->push_back(std::move(__value)); + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + back_insert_iterator + operator++(int) + { return *this; } + }; + + /** + * @param __x A container of arbitrary type. + * @return An instance of back_insert_iterator working on @p __x. + * + * This wrapper function helps in creating back_insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline back_insert_iterator<_Container> + back_inserter(_Container& __x) + { return back_insert_iterator<_Container>(__x); } + + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator prepends it to the container using + * push_front. + * + * Tip: Using the front_inserter function to create these iterators can + * save typing. + */ + template + class front_insert_iterator + : public iterator + { + protected: + _Container* container; + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + + /// The only way to create this %iterator is with a container. + explicit _GLIBCXX20_CONSTEXPR + front_insert_iterator(_Container& __x) + : container(std::__addressof(__x)) { } + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator doesn't really have a @a position in the + * container (you can think of the position as being permanently at + * the front, if you like). Assigning a value to the %iterator will + * always prepend the value to the front of the container. + */ +#if __cplusplus < 201103L + front_insert_iterator& + operator=(typename _Container::const_reference __value) + { + container->push_front(__value); + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator=(const typename _Container::value_type& __value) + { + container->push_front(__value); + return *this; + } + + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator=(typename _Container::value_type&& __value) + { + container->push_front(std::move(__value)); + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + front_insert_iterator + operator++(int) + { return *this; } + }; + + /** + * @param __x A container of arbitrary type. + * @return An instance of front_insert_iterator working on @p x. + * + * This wrapper function helps in creating front_insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline front_insert_iterator<_Container> + front_inserter(_Container& __x) + { return front_insert_iterator<_Container>(__x); } + + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator inserts it in the container at the + * %iterator's position, rather than overwriting the value at that + * position. + * + * (Sequences will actually insert a @e copy of the value before the + * %iterator's position.) + * + * Tip: Using the inserter function to create these iterators can + * save typing. + */ + template + class insert_iterator + : public iterator + { +#if __cplusplus > 201703L && defined __cpp_lib_concepts + using _Iter = std::__detail::__range_iter_t<_Container>; +#else + typedef typename _Container::iterator _Iter; +#endif + protected: + _Container* container; + _Iter iter; + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; + +#if __cplusplus > 201703L && defined __cpp_lib_concepts + using difference_type = ptrdiff_t; +#endif + + /** + * The only way to create this %iterator is with a container and an + * initial position (a normal %iterator into the container). + */ + _GLIBCXX20_CONSTEXPR + insert_iterator(_Container& __x, _Iter __i) + : container(std::__addressof(__x)), iter(__i) {} + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator maintains its own position in the + * container. Assigning a value to the %iterator will insert the + * value into the container at the place before the %iterator. + * + * The position is maintained such that subsequent assignments will + * insert values immediately after one another. For example, + * @code + * // vector v contains A and Z + * + * insert_iterator i (v, ++v.begin()); + * i = 1; + * i = 2; + * i = 3; + * + * // vector v contains A, 1, 2, 3, and Z + * @endcode + */ +#if __cplusplus < 201103L + insert_iterator& + operator=(typename _Container::const_reference __value) + { + iter = container->insert(iter, __value); + ++iter; + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator=(const typename _Container::value_type& __value) + { + iter = container->insert(iter, __value); + ++iter; + return *this; + } + + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator=(typename _Container::value_type&& __value) + { + iter = container->insert(iter, std::move(__value)); + ++iter; + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator++(int) + { return *this; } + }; + +#pragma GCC diagnostic pop + + /** + * @param __x A container of arbitrary type. + * @param __i An iterator into the container. + * @return An instance of insert_iterator working on @p __x. + * + * This wrapper function helps in creating insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ +#if __cplusplus > 201703L && defined __cpp_lib_concepts + template + [[nodiscard]] + constexpr insert_iterator<_Container> + inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i) + { return insert_iterator<_Container>(__x, __i); } +#else + template + _GLIBCXX_NODISCARD + inline insert_iterator<_Container> + inserter(_Container& __x, typename _Container::iterator __i) + { return insert_iterator<_Container>(__x, __i); } +#endif + + /// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // This iterator adapter is @a normal in the sense that it does not + // change the semantics of any of the operators of its iterator + // parameter. Its primary purpose is to convert an iterator that is + // not a class, e.g. a pointer, into an iterator that is a class. + // The _Container parameter exists solely so that different containers + // using this template can instantiate different types, even if the + // _Iterator parameter is the same. + template + class __normal_iterator + { + protected: + _Iterator _M_current; + + typedef std::iterator_traits<_Iterator> __traits_type; + +#if __cplusplus >= 201103L + template + using __convertible_from + = std::__enable_if_t::value>; +#endif + + public: + typedef _Iterator iterator_type; + typedef typename __traits_type::iterator_category iterator_category; + typedef typename __traits_type::value_type value_type; + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::reference reference; + typedef typename __traits_type::pointer pointer; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = std::__detail::__iter_concept<_Iterator>; +#endif + + _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT + : _M_current(_Iterator()) { } + + explicit _GLIBCXX20_CONSTEXPR + __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT + : _M_current(__i) { } + + // Allow iterator to const_iterator conversion +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + __normal_iterator(const __normal_iterator<_Iter, _Container>& __i) + noexcept +#else + // N.B. _Container::pointer is not actually in container requirements, + // but is present in std::vector and std::basic_string. + template + __normal_iterator(const __normal_iterator<_Iter, + typename __enable_if< + (std::__are_same<_Iter, typename _Container::pointer>::__value), + _Container>::__type>& __i) +#endif + : _M_current(__i.base()) { } + + // Forward iterator requirements + _GLIBCXX20_CONSTEXPR + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *_M_current; } + + _GLIBCXX20_CONSTEXPR + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return _M_current; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator++() _GLIBCXX_NOEXCEPT + { + ++_M_current; + return *this; + } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator++(int) _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current++); } + + // Bidirectional iterator requirements + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator--() _GLIBCXX_NOEXCEPT + { + --_M_current; + return *this; + } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator--(int) _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current--); } + + // Random access iterator requirements + _GLIBCXX20_CONSTEXPR + reference + operator[](difference_type __n) const _GLIBCXX_NOEXCEPT + { return _M_current[__n]; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator+=(difference_type __n) _GLIBCXX_NOEXCEPT + { _M_current += __n; return *this; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator+(difference_type __n) const _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current + __n); } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator-=(difference_type __n) _GLIBCXX_NOEXCEPT + { _M_current -= __n; return *this; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator-(difference_type __n) const _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current - __n); } + + _GLIBCXX20_CONSTEXPR + const _Iterator& + base() const _GLIBCXX_NOEXCEPT + { return _M_current; } + }; + + // Note: In what follows, the left- and right-hand-side iterators are + // allowed to vary in types (conceptually in cv-qualification) so that + // comparison between cv-qualified and non-cv-qualified iterators be + // valid. However, the greedy and unfriendly operators in std::rel_ops + // will make overload resolution ambiguous (when in scope) if we don't + // provide overloads whose operands are of the same type. Can someone + // remind me what generic programming is about? -- Gaby + +#if __cpp_lib_three_way_comparison + template + [[nodiscard]] + constexpr bool + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + noexcept(noexcept(__lhs.base() == __rhs.base())) + requires requires { + { __lhs.base() == __rhs.base() } -> std::convertible_to; + } + { return __lhs.base() == __rhs.base(); } + + template + [[nodiscard]] + constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL> + operator<=>(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base()))) + { return std::__detail::__synth3way(__lhs.base(), __rhs.base()); } + + template + [[nodiscard]] + constexpr bool + operator==(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + noexcept(noexcept(__lhs.base() == __rhs.base())) + requires requires { + { __lhs.base() == __rhs.base() } -> std::convertible_to; + } + { return __lhs.base() == __rhs.base(); } + + template + [[nodiscard]] + constexpr std::__detail::__synth3way_t<_Iterator> + operator<=>(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base()))) + { return std::__detail::__synth3way(__lhs.base(), __rhs.base()); } +#else + // Forward iterator requirements + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() == __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator==(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() == __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() != __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() != __rhs.base(); } + + // Random access iterator requirements + template + _GLIBCXX_NODISCARD + inline bool + operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() < __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator<(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() < __rhs.base(); } + + template + _GLIBCXX_NODISCARD + inline bool + operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() > __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator>(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() > __rhs.base(); } + + template + _GLIBCXX_NODISCARD + inline bool + operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() <= __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() <= __rhs.base(); } + + template + _GLIBCXX_NODISCARD + inline bool + operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() >= __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline bool + operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() >= __rhs.base(); } +#endif // three-way comparison + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template +#if __cplusplus >= 201103L + // DR 685. + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + inline auto + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept + -> decltype(__lhs.base() - __rhs.base()) +#else + inline typename __normal_iterator<_IteratorL, _Container>::difference_type + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) +#endif + { return __lhs.base() - __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline typename __normal_iterator<_Iterator, _Container>::difference_type + operator-(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() - __rhs.base(); } + + template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + inline __normal_iterator<_Iterator, _Container> + operator+(typename __normal_iterator<_Iterator, _Container>::difference_type + __n, const __normal_iterator<_Iterator, _Container>& __i) + _GLIBCXX_NOEXCEPT + { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + _GLIBCXX20_CONSTEXPR + _Iterator + __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it) + _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) + { return __it.base(); } + +#if __cplusplus >= 201103L + +#if __cplusplus <= 201703L + // Need to overload __to_address because the pointer_traits primary template + // will deduce element_type of __normal_iterator as T* rather than T. + template + constexpr auto + __to_address(const __gnu_cxx::__normal_iterator<_Iterator, + _Container>& __it) noexcept + -> decltype(std::__to_address(__it.base())) + { return std::__to_address(__it.base()); } +#endif + + /** + * @addtogroup iterators + * @{ + */ + +#if __cplusplus > 201703L && __cpp_lib_concepts + template + class move_sentinel + { + public: + constexpr + move_sentinel() + noexcept(is_nothrow_default_constructible_v<_Sent>) + : _M_last() { } + + constexpr explicit + move_sentinel(_Sent __s) + noexcept(is_nothrow_move_constructible_v<_Sent>) + : _M_last(std::move(__s)) { } + + template requires convertible_to + constexpr + move_sentinel(const move_sentinel<_S2>& __s) + noexcept(is_nothrow_constructible_v<_Sent, const _S2&>) + : _M_last(__s.base()) + { } + + template requires assignable_from<_Sent&, const _S2&> + constexpr move_sentinel& + operator=(const move_sentinel<_S2>& __s) + noexcept(is_nothrow_assignable_v<_Sent, const _S2&>) + { + _M_last = __s.base(); + return *this; + } + + [[nodiscard]] + constexpr _Sent + base() const + noexcept(is_nothrow_copy_constructible_v<_Sent>) + { return _M_last; } + + private: + _Sent _M_last; + }; +#endif // C++20 + + namespace __detail + { +#if __cplusplus > 201703L && __cpp_lib_concepts + template + struct __move_iter_cat + { }; + + template + requires requires { typename iterator_traits<_Iterator>::iterator_category; } + struct __move_iter_cat<_Iterator> + { + using iterator_category + = __clamp_iter_cat::iterator_category, + random_access_iterator_tag>; + }; +#endif + } + + // 24.4.3 Move iterators + /** + * Class template move_iterator is an iterator adapter with the same + * behavior as the underlying iterator except that its dereference + * operator implicitly converts the value returned by the underlying + * iterator's dereference operator to an rvalue reference. Some + * generic algorithms can be called with move iterators to replace + * copying with moving. + */ + template + class move_iterator +#if __cplusplus > 201703L && __cpp_lib_concepts + : public __detail::__move_iter_cat<_Iterator> +#endif + { + _Iterator _M_current; + + using __traits_type = iterator_traits<_Iterator>; +#if ! (__cplusplus > 201703L && __cpp_lib_concepts) + using __base_ref = typename __traits_type::reference; +#endif + + template + friend class move_iterator; + +#if __cpp_lib_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3435. three_way_comparable_with, [...]> + template + static constexpr bool __convertible = !is_same_v<_Iter2, _Iterator> + && convertible_to; +#endif + + public: + using iterator_type = _Iterator; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = input_iterator_tag; + // iterator_category defined in __move_iter_cat + using value_type = iter_value_t<_Iterator>; + using difference_type = iter_difference_t<_Iterator>; + using pointer = _Iterator; + using reference = iter_rvalue_reference_t<_Iterator>; +#else + typedef typename __traits_type::iterator_category iterator_category; + typedef typename __traits_type::value_type value_type; + typedef typename __traits_type::difference_type difference_type; + // NB: DR 680. + typedef _Iterator pointer; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2106. move_iterator wrapping iterators returning prvalues + using reference + = __conditional_t::value, + typename remove_reference<__base_ref>::type&&, + __base_ref>; +#endif + + _GLIBCXX17_CONSTEXPR + move_iterator() + : _M_current() { } + + explicit _GLIBCXX17_CONSTEXPR + move_iterator(iterator_type __i) + : _M_current(std::move(__i)) { } + + template +#if __cpp_lib_concepts + requires __convertible<_Iter> +#endif + _GLIBCXX17_CONSTEXPR + move_iterator(const move_iterator<_Iter>& __i) + : _M_current(__i._M_current) { } + + template +#if __cpp_lib_concepts + requires __convertible<_Iter> + && assignable_from<_Iterator&, const _Iter&> +#endif + _GLIBCXX17_CONSTEXPR + move_iterator& operator=(const move_iterator<_Iter>& __i) + { + _M_current = __i._M_current; + return *this; + } + +#if __cplusplus <= 201703L + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR iterator_type + base() const + { return _M_current; } +#else + [[nodiscard]] + constexpr const iterator_type& + base() const & noexcept + { return _M_current; } + + [[nodiscard]] + constexpr iterator_type + base() && + { return std::move(_M_current); } +#endif + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR reference + operator*() const +#if __cplusplus > 201703L && __cpp_lib_concepts + { return ranges::iter_move(_M_current); } +#else + { return static_cast(*_M_current); } +#endif + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR pointer + operator->() const + { return _M_current; } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator++() + { + ++_M_current; + return *this; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator++(int) + { + move_iterator __tmp = *this; + ++_M_current; + return __tmp; + } + +#if __cpp_lib_concepts + constexpr void + operator++(int) requires (!forward_iterator<_Iterator>) + { ++_M_current; } +#endif + + _GLIBCXX17_CONSTEXPR move_iterator& + operator--() + { + --_M_current; + return *this; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator--(int) + { + move_iterator __tmp = *this; + --_M_current; + return __tmp; + } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR move_iterator + operator+(difference_type __n) const + { return move_iterator(_M_current + __n); } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator+=(difference_type __n) + { + _M_current += __n; + return *this; + } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR move_iterator + operator-(difference_type __n) const + { return move_iterator(_M_current - __n); } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator-=(difference_type __n) + { + _M_current -= __n; + return *this; + } + + [[__nodiscard__]] + _GLIBCXX17_CONSTEXPR reference + operator[](difference_type __n) const +#if __cplusplus > 201703L && __cpp_lib_concepts + { return ranges::iter_move(_M_current + __n); } +#else + { return std::move(_M_current[__n]); } +#endif + +#if __cplusplus > 201703L && __cpp_lib_concepts + template _Sent> + [[nodiscard]] + friend constexpr bool + operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() == __y.base(); } + + template _Sent> + [[nodiscard]] + friend constexpr iter_difference_t<_Iterator> + operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y) + { return __x.base() - __y.base(); } + + template _Sent> + [[nodiscard]] + friend constexpr iter_difference_t<_Iterator> + operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() - __y.base(); } + + [[nodiscard]] + friend constexpr iter_rvalue_reference_t<_Iterator> + iter_move(const move_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + { return ranges::iter_move(__i._M_current); } + + template _Iter2> + friend constexpr void + iter_swap(const move_iterator& __x, const move_iterator<_Iter2>& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + { return ranges::iter_swap(__x._M_current, __y._M_current); } +#endif // C++20 + }; + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator==(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() == __y.base() } -> convertible_to; } +#endif + { return __x.base() == __y.base(); } + +#if __cpp_lib_three_way_comparison + template _IteratorR> + [[__nodiscard__]] + constexpr compare_three_way_result_t<_IteratorL, _IteratorR> + operator<=>(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __x.base() <=> __y.base(); } +#else + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__x == __y); } +#endif + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator<(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() < __y.base() } -> convertible_to; } +#endif + { return __x.base() < __y.base(); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __y.base() < __x.base() } -> convertible_to; } +#endif + { return !(__y < __x); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator>(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __y.base() < __x.base() } -> convertible_to; } +#endif + { return __y < __x; } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() < __y.base() } -> convertible_to; } +#endif + { return !(__x < __y); } + + // Note: See __normal_iterator operators note from Gaby to understand + // why we have these extra overloads for some move_iterator operators. + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator==(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + +#if __cpp_lib_three_way_comparison + template + [[__nodiscard__]] + constexpr compare_three_way_result_t<_Iterator> + operator<=>(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() <=> __y.base(); } +#else + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator<(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() < __y.base(); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator>(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __y < __x; } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x < __y); } +#endif // ! C++20 + + // DR 685. + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR auto + operator-(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + -> decltype(__x.base() - __y.base()) + { return __x.base() - __y.base(); } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> + operator+(typename move_iterator<_Iterator>::difference_type __n, + const move_iterator<_Iterator>& __x) + { return __x + __n; } + + template + [[__nodiscard__]] + inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> + make_move_iterator(_Iterator __i) + { return move_iterator<_Iterator>(std::move(__i)); } + + template::value_type>::value, + _Iterator, move_iterator<_Iterator>>> + inline _GLIBCXX17_CONSTEXPR _ReturnType + __make_move_if_noexcept_iterator(_Iterator __i) + { return _ReturnType(__i); } + + // Overload for pointers that matches std::move_if_noexcept more closely, + // returning a constant iterator when we don't want to move. + template::value, + const _Tp*, move_iterator<_Tp*>>> + inline _GLIBCXX17_CONSTEXPR _ReturnType + __make_move_if_noexcept_iterator(_Tp* __i) + { return _ReturnType(__i); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + // [iterators.common] Common iterators + + namespace __detail + { + template + concept __common_iter_has_arrow = indirectly_readable + && (requires(const _It& __it) { __it.operator->(); } + || is_reference_v> + || constructible_from, iter_reference_t<_It>>); + + template + concept __common_iter_use_postfix_proxy + = (!requires (_It& __i) { { *__i++ } -> __can_reference; }) + && constructible_from, iter_reference_t<_It>> + && move_constructible>; + } // namespace __detail + + /// An iterator/sentinel adaptor for representing a non-common range. + template _Sent> + requires (!same_as<_It, _Sent>) && copyable<_It> + class common_iterator + { + template + static constexpr bool + _S_noexcept1() + { + if constexpr (is_trivially_default_constructible_v<_Tp>) + return is_nothrow_assignable_v<_Tp&, _Up>; + else + return is_nothrow_constructible_v<_Tp, _Up>; + } + + template + static constexpr bool + _S_noexcept() + { return _S_noexcept1<_It, _It2>() && _S_noexcept1<_Sent, _Sent2>(); } + + class __arrow_proxy + { + iter_value_t<_It> _M_keep; + + constexpr + __arrow_proxy(iter_reference_t<_It>&& __x) + : _M_keep(std::move(__x)) { } + + friend class common_iterator; + + public: + constexpr const iter_value_t<_It>* + operator->() const noexcept + { return std::__addressof(_M_keep); } + }; + + class __postfix_proxy + { + iter_value_t<_It> _M_keep; + + constexpr + __postfix_proxy(iter_reference_t<_It>&& __x) + : _M_keep(std::forward>(__x)) { } + + friend class common_iterator; + + public: + constexpr const iter_value_t<_It>& + operator*() const noexcept + { return _M_keep; } + }; + + public: + constexpr + common_iterator() + noexcept(is_nothrow_default_constructible_v<_It>) + requires default_initializable<_It> + : _M_it(), _M_index(0) + { } + + constexpr + common_iterator(_It __i) + noexcept(is_nothrow_move_constructible_v<_It>) + : _M_it(std::move(__i)), _M_index(0) + { } + + constexpr + common_iterator(_Sent __s) + noexcept(is_nothrow_move_constructible_v<_Sent>) + : _M_sent(std::move(__s)), _M_index(1) + { } + + template + requires convertible_to + && convertible_to + constexpr + common_iterator(const common_iterator<_It2, _Sent2>& __x) + noexcept(_S_noexcept()) + : _M_valueless(), _M_index(__x._M_index) + { + __glibcxx_assert(__x._M_has_value()); + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = std::move(__x._M_it); + else + std::construct_at(std::__addressof(_M_it), __x._M_it); + } + else if (_M_index == 1) + { + if constexpr (is_trivially_default_constructible_v<_Sent>) + _M_sent = std::move(__x._M_sent); + else + std::construct_at(std::__addressof(_M_sent), __x._M_sent); + } + } + + constexpr + common_iterator(const common_iterator& __x) + noexcept(_S_noexcept()) + : _M_valueless(), _M_index(__x._M_index) + { + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = __x._M_it; + else + std::construct_at(std::__addressof(_M_it), __x._M_it); + } + else if (_M_index == 1) + { + if constexpr (is_trivially_default_constructible_v<_Sent>) + _M_sent = __x._M_sent; + else + std::construct_at(std::__addressof(_M_sent), __x._M_sent); + } + } + + constexpr + common_iterator(common_iterator&& __x) + noexcept(_S_noexcept<_It, _Sent>()) + : _M_valueless(), _M_index(__x._M_index) + { + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = std::move(__x._M_it); + else + std::construct_at(std::__addressof(_M_it), std::move(__x._M_it)); + } + else if (_M_index == 1) + { + if constexpr (is_trivially_default_constructible_v<_Sent>) + _M_sent = std::move(__x._M_sent); + else + std::construct_at(std::__addressof(_M_sent), + std::move(__x._M_sent)); + } + } + + constexpr common_iterator& + operator=(const common_iterator&) = default; + + constexpr common_iterator& + operator=(const common_iterator& __x) + noexcept(is_nothrow_copy_assignable_v<_It> + && is_nothrow_copy_assignable_v<_Sent> + && is_nothrow_copy_constructible_v<_It> + && is_nothrow_copy_constructible_v<_Sent>) + requires (!is_trivially_copy_assignable_v<_It> + || !is_trivially_copy_assignable_v<_Sent>) + { + _M_assign(__x); + return *this; + } + + constexpr common_iterator& + operator=(common_iterator&&) = default; + + constexpr common_iterator& + operator=(common_iterator&& __x) + noexcept(is_nothrow_move_assignable_v<_It> + && is_nothrow_move_assignable_v<_Sent> + && is_nothrow_move_constructible_v<_It> + && is_nothrow_move_constructible_v<_Sent>) + requires (!is_trivially_move_assignable_v<_It> + || !is_trivially_move_assignable_v<_Sent>) + { + _M_assign(std::move(__x)); + return *this; + } + + template + requires convertible_to + && convertible_to + && assignable_from<_It&, const _It2&> + && assignable_from<_Sent&, const _Sent2&> + constexpr common_iterator& + operator=(const common_iterator<_It2, _Sent2>& __x) + noexcept(is_nothrow_constructible_v<_It, const _It2&> + && is_nothrow_constructible_v<_Sent, const _Sent2&> + && is_nothrow_assignable_v<_It&, const _It2&> + && is_nothrow_assignable_v<_Sent&, const _Sent2&>) + { + __glibcxx_assert(__x._M_has_value()); + _M_assign(__x); + return *this; + } + + constexpr + ~common_iterator() + { + if (_M_index == 0) + _M_it.~_It(); + else if (_M_index == 1) + _M_sent.~_Sent(); + } + + [[nodiscard]] + constexpr decltype(auto) + operator*() + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + [[nodiscard]] + constexpr decltype(auto) + operator*() const requires __detail::__dereferenceable + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + [[nodiscard]] + constexpr auto + operator->() const requires __detail::__common_iter_has_arrow<_It> + { + __glibcxx_assert(_M_index == 0); + if constexpr (is_pointer_v<_It> || requires { _M_it.operator->(); }) + return _M_it; + else if constexpr (is_reference_v>) + { + auto&& __tmp = *_M_it; + return std::__addressof(__tmp); + } + else + return __arrow_proxy{*_M_it}; + } + + constexpr common_iterator& + operator++() + { + __glibcxx_assert(_M_index == 0); + ++_M_it; + return *this; + } + + constexpr decltype(auto) + operator++(int) + { + __glibcxx_assert(_M_index == 0); + if constexpr (forward_iterator<_It>) + { + common_iterator __tmp = *this; + ++*this; + return __tmp; + } + else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>) + return _M_it++; + else + { + __postfix_proxy __p(**this); + ++*this; + return __p; + } + } + + template _Sent2> + requires sentinel_for<_Sent, _It2> + friend constexpr bool + operator== [[nodiscard]] (const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0000: + case 0b0101: + return true; + case 0b0001: + return __x._M_it == __y._M_sent; + case 0b0100: + return __x._M_sent == __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + template _Sent2> + requires sentinel_for<_Sent, _It2> && equality_comparable_with<_It, _It2> + friend constexpr bool + operator== [[nodiscard]] (const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0101: + return true; + case 0b0000: + return __x._M_it == __y._M_it; + case 0b0001: + return __x._M_it == __y._M_sent; + case 0b0100: + return __x._M_sent == __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + template _It2, sized_sentinel_for<_It> _Sent2> + requires sized_sentinel_for<_Sent, _It2> + friend constexpr iter_difference_t<_It2> + operator- [[nodiscard]] (const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0101: + return 0; + case 0b0000: + return __x._M_it - __y._M_it; + case 0b0001: + return __x._M_it - __y._M_sent; + case 0b0100: + return __x._M_sent - __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + [[nodiscard]] + friend constexpr iter_rvalue_reference_t<_It> + iter_move(const common_iterator& __i) + noexcept(noexcept(ranges::iter_move(std::declval()))) + requires input_iterator<_It> + { + __glibcxx_assert(__i._M_index == 0); + return ranges::iter_move(__i._M_it); + } + + template _It2, typename _Sent2> + friend constexpr void + iter_swap(const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + noexcept(noexcept(ranges::iter_swap(std::declval(), + std::declval()))) + { + __glibcxx_assert(__x._M_index == 0); + __glibcxx_assert(__y._M_index == 0); + return ranges::iter_swap(__x._M_it, __y._M_it); + } + + private: + template _Sent2> + requires (!same_as<_It2, _Sent2>) && copyable<_It2> + friend class common_iterator; + + constexpr bool + _M_has_value() const noexcept { return _M_index != _S_valueless; } + + template + constexpr void + _M_assign(_CIt&& __x) + { + if (_M_index == __x._M_index) + { + if (_M_index == 0) + _M_it = std::forward<_CIt>(__x)._M_it; + else if (_M_index == 1) + _M_sent = std::forward<_CIt>(__x)._M_sent; + } + else + { + if (_M_index == 0) + _M_it.~_It(); + else if (_M_index == 1) + _M_sent.~_Sent(); + _M_index = _S_valueless; + + if (__x._M_index == 0) + std::construct_at(std::__addressof(_M_it), + std::forward<_CIt>(__x)._M_it); + else if (__x._M_index == 1) + std::construct_at(std::__addressof(_M_sent), + std::forward<_CIt>(__x)._M_sent); + _M_index = __x._M_index; + } + } + + union + { + _It _M_it; + _Sent _M_sent; + unsigned char _M_valueless; + }; + unsigned char _M_index; // 0 == _M_it, 1 == _M_sent, 2 == valueless + + static constexpr unsigned char _S_valueless{2}; + }; + + template + struct incrementable_traits> + { + using difference_type = iter_difference_t<_It>; + }; + + template + struct iterator_traits> + { + private: + template + struct __ptr + { + using type = void; + }; + + template + requires __detail::__common_iter_has_arrow<_Iter> + struct __ptr<_Iter> + { + using _CIter = common_iterator<_Iter, _Sent>; + using type = decltype(std::declval().operator->()); + }; + + static auto + _S_iter_cat() + { + using _Traits = iterator_traits<_It>; + if constexpr (requires { requires derived_from; }) + return forward_iterator_tag{}; + else + return input_iterator_tag{}; + } + + public: + using iterator_concept = __conditional_t, + forward_iterator_tag, + input_iterator_tag>; + using iterator_category = decltype(_S_iter_cat()); + using value_type = iter_value_t<_It>; + using difference_type = iter_difference_t<_It>; + using pointer = typename __ptr<_It>::type; + using reference = iter_reference_t<_It>; + }; + + // [iterators.counted] Counted iterators + + namespace __detail + { + template + struct __counted_iter_value_type + { }; + + template + struct __counted_iter_value_type<_It> + { using value_type = iter_value_t<_It>; }; + + template + struct __counted_iter_concept + { }; + + template + requires requires { typename _It::iterator_concept; } + struct __counted_iter_concept<_It> + { using iterator_concept = typename _It::iterator_concept; }; + + template + struct __counted_iter_cat + { }; + + template + requires requires { typename _It::iterator_category; } + struct __counted_iter_cat<_It> + { using iterator_category = typename _It::iterator_category; }; + } + + /// An iterator adaptor that keeps track of the distance to the end. + template + class counted_iterator + : public __detail::__counted_iter_value_type<_It>, + public __detail::__counted_iter_concept<_It>, + public __detail::__counted_iter_cat<_It> + { + public: + using iterator_type = _It; + // value_type defined in __counted_iter_value_type + using difference_type = iter_difference_t<_It>; + // iterator_concept defined in __counted_iter_concept + // iterator_category defined in __counted_iter_cat + + constexpr counted_iterator() requires default_initializable<_It> = default; + + constexpr + counted_iterator(_It __i, iter_difference_t<_It> __n) + : _M_current(std::move(__i)), _M_length(__n) + { __glibcxx_assert(__n >= 0); } + + template + requires convertible_to + constexpr + counted_iterator(const counted_iterator<_It2>& __x) + : _M_current(__x._M_current), _M_length(__x._M_length) + { } + + template + requires assignable_from<_It&, const _It2&> + constexpr counted_iterator& + operator=(const counted_iterator<_It2>& __x) + { + _M_current = __x._M_current; + _M_length = __x._M_length; + return *this; + } + + [[nodiscard]] + constexpr const _It& + base() const & noexcept + { return _M_current; } + + [[nodiscard]] + constexpr _It + base() && + noexcept(is_nothrow_move_constructible_v<_It>) + { return std::move(_M_current); } + + [[nodiscard]] + constexpr iter_difference_t<_It> + count() const noexcept { return _M_length; } + + [[nodiscard]] + constexpr decltype(auto) + operator*() + noexcept(noexcept(*_M_current)) + { + __glibcxx_assert( _M_length > 0 ); + return *_M_current; + } + + [[nodiscard]] + constexpr decltype(auto) + operator*() const + noexcept(noexcept(*_M_current)) + requires __detail::__dereferenceable + { + __glibcxx_assert( _M_length > 0 ); + return *_M_current; + } + + [[nodiscard]] + constexpr auto + operator->() const noexcept + requires contiguous_iterator<_It> + { return std::to_address(_M_current); } + + constexpr counted_iterator& + operator++() + { + __glibcxx_assert(_M_length > 0); + ++_M_current; + --_M_length; + return *this; + } + + constexpr decltype(auto) + operator++(int) + { + __glibcxx_assert(_M_length > 0); + --_M_length; + __try + { + return _M_current++; + } __catch(...) { + ++_M_length; + __throw_exception_again; + } + } + + constexpr counted_iterator + operator++(int) requires forward_iterator<_It> + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr counted_iterator& + operator--() requires bidirectional_iterator<_It> + { + --_M_current; + ++_M_length; + return *this; + } + + constexpr counted_iterator + operator--(int) requires bidirectional_iterator<_It> + { + auto __tmp = *this; + --*this; + return __tmp; + } + + [[nodiscard]] + constexpr counted_iterator + operator+(iter_difference_t<_It> __n) const + requires random_access_iterator<_It> + { return counted_iterator(_M_current + __n, _M_length - __n); } + + [[nodiscard]] + friend constexpr counted_iterator + operator+(iter_difference_t<_It> __n, const counted_iterator& __x) + requires random_access_iterator<_It> + { return __x + __n; } + + constexpr counted_iterator& + operator+=(iter_difference_t<_It> __n) + requires random_access_iterator<_It> + { + __glibcxx_assert(__n <= _M_length); + _M_current += __n; + _M_length -= __n; + return *this; + } + + [[nodiscard]] + constexpr counted_iterator + operator-(iter_difference_t<_It> __n) const + requires random_access_iterator<_It> + { return counted_iterator(_M_current - __n, _M_length + __n); } + + template _It2> + [[nodiscard]] + friend constexpr iter_difference_t<_It2> + operator-(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length - __x._M_length; } + + [[nodiscard]] + friend constexpr iter_difference_t<_It> + operator-(const counted_iterator& __x, default_sentinel_t) + { return -__x._M_length; } + + [[nodiscard]] + friend constexpr iter_difference_t<_It> + operator-(default_sentinel_t, const counted_iterator& __y) + { return __y._M_length; } + + constexpr counted_iterator& + operator-=(iter_difference_t<_It> __n) + requires random_access_iterator<_It> + { + __glibcxx_assert(-__n <= _M_length); + _M_current -= __n; + _M_length += __n; + return *this; + } + + [[nodiscard]] + constexpr decltype(auto) + operator[](iter_difference_t<_It> __n) const + noexcept(noexcept(_M_current[__n])) + requires random_access_iterator<_It> + { + __glibcxx_assert(__n < _M_length); + return _M_current[__n]; + } + + template _It2> + [[nodiscard]] + friend constexpr bool + operator==(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __x._M_length == __y._M_length; } + + [[nodiscard]] + friend constexpr bool + operator==(const counted_iterator& __x, default_sentinel_t) + { return __x._M_length == 0; } + + template _It2> + [[nodiscard]] + friend constexpr strong_ordering + operator<=>(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length <=> __x._M_length; } + + [[nodiscard]] + friend constexpr iter_rvalue_reference_t<_It> + iter_move(const counted_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + requires input_iterator<_It> + { + __glibcxx_assert( __i._M_length > 0 ); + return ranges::iter_move(__i._M_current); + } + + template _It2> + friend constexpr void + iter_swap(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + { + __glibcxx_assert( __x._M_length > 0 && __y._M_length > 0 ); + ranges::iter_swap(__x._M_current, __y._M_current); + } + + private: + template friend class counted_iterator; + + _It _M_current = _It(); + iter_difference_t<_It> _M_length = 0; + }; + + template + requires same_as<__detail::__iter_traits<_It>, iterator_traits<_It>> + struct iterator_traits> : iterator_traits<_It> + { + using pointer = __conditional_t, + add_pointer_t>, + void>; + }; +#endif // C++20 + + /// @} group iterators + + template + _GLIBCXX20_CONSTEXPR + auto + __niter_base(move_iterator<_Iterator> __it) + -> decltype(make_move_iterator(__niter_base(__it.base()))) + { return make_move_iterator(__niter_base(__it.base())); } + + template + struct __is_move_iterator > + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template + _GLIBCXX20_CONSTEXPR + auto + __miter_base(move_iterator<_Iterator> __it) + -> decltype(__miter_base(__it.base())) + { return __miter_base(__it.base()); } + +#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) +#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ + std::__make_move_if_noexcept_iterator(_Iter) +#else +#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) +#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) +#endif // C++11 + +#if __cpp_deduction_guides >= 201606 + // These helper traits are used for deduction guides + // of associative containers. + template + using __iter_key_t = remove_const_t< + typename iterator_traits<_InputIterator>::value_type::first_type>; + + template + using __iter_val_t = + typename iterator_traits<_InputIterator>::value_type::second_type; + + template + struct pair; + + template + using __iter_to_alloc_t = + pair>, + __iter_val_t<_InputIterator>>; +#endif // __cpp_deduction_guides + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ee188941e68bcb3803d22729c142fee51a940e77 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h new file mode 100644 index 0000000000000000000000000000000000000000..1551b226ff4adab3580b3d95eb8b7ead1075ce88 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h @@ -0,0 +1,257 @@ +// Functions used by iterators -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator_base_funcs.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file contains all of the general iterator-related utility + * functions, such as distance() and advance(). + */ + +#ifndef _STL_ITERATOR_BASE_FUNCS_H +#define _STL_ITERATOR_BASE_FUNCS_H 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + // Forward declaration for the overloads of __distance. + template struct _List_iterator; + template struct _List_const_iterator; +_GLIBCXX_END_NAMESPACE_CONTAINER + + template + inline _GLIBCXX14_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + __distance(_InputIterator __first, _InputIterator __last, + input_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + + typename iterator_traits<_InputIterator>::difference_type __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } + + template + inline _GLIBCXX14_CONSTEXPR + typename iterator_traits<_RandomAccessIterator>::difference_type + __distance(_RandomAccessIterator __first, _RandomAccessIterator __last, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + return __last - __first; + } + +#if _GLIBCXX_USE_CXX11_ABI + // Forward declaration because of the qualified call in distance. + template + ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>, + _GLIBCXX_STD_C::_List_iterator<_Tp>, + input_iterator_tag); + + template + ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>, + _GLIBCXX_STD_C::_List_const_iterator<_Tp>, + input_iterator_tag); +#endif + +#if __cplusplus >= 201103L + // Give better error if std::distance called with a non-Cpp17InputIterator. + template + void + __distance(_OutputIterator, _OutputIterator, output_iterator_tag) = delete; +#endif + + /** + * @brief A generalization of pointer arithmetic. + * @param __first An input iterator. + * @param __last An input iterator. + * @return The distance between them. + * + * Returns @c n such that __first + n == __last. This requires + * that @p __last must be reachable from @p __first. Note that @c + * n may be negative. + * + * For random access iterators, this uses their @c + and @c - operations + * and are constant time. For other %iterator classes they are linear time. + */ + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + distance(_InputIterator __first, _InputIterator __last) + { + // concept requirements -- taken care of in __distance + return std::__distance(__first, __last, + std::__iterator_category(__first)); + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_InputIterator& __i, _Distance __n, input_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_assert(__n >= 0); + while (__n--) + ++__i; + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_BidirectionalIterator& __i, _Distance __n, + bidirectional_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + if (__n > 0) + while (__n--) + ++__i; + else + while (__n++) + --__i; + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_RandomAccessIterator& __i, _Distance __n, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + if (__builtin_constant_p(__n) && __n == 1) + ++__i; + else if (__builtin_constant_p(__n) && __n == -1) + --__i; + else + __i += __n; + } + +#if __cplusplus >= 201103L + // Give better error if std::advance called with a non-Cpp17InputIterator. + template + void + __advance(_OutputIterator&, _Distance, output_iterator_tag) = delete; +#endif + + /** + * @brief A generalization of pointer arithmetic. + * @param __i An input iterator. + * @param __n The @a delta by which to change @p __i. + * @return Nothing. + * + * This increments @p i by @p n. For bidirectional and random access + * iterators, @p __n may be negative, in which case @p __i is decremented. + * + * For random access iterators, this uses their @c + and @c - operations + * and are constant time. For other %iterator classes they are linear time. + */ + template + inline _GLIBCXX17_CONSTEXPR void + advance(_InputIterator& __i, _Distance __n) + { + // concept requirements -- taken care of in __advance + typename iterator_traits<_InputIterator>::difference_type __d = __n; + std::__advance(__i, __d, std::__iterator_category(__i)); + } + +#if __cplusplus >= 201103L + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR _InputIterator + next(_InputIterator __x, typename + iterator_traits<_InputIterator>::difference_type __n = 1) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + std::advance(__x, __n); + return __x; + } + + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator + prev(_BidirectionalIterator __x, typename + iterator_traits<_BidirectionalIterator>::difference_type __n = 1) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + std::advance(__x, -__n); + return __x; + } + +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_ITERATOR_BASE_FUNCS_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4aaf913878cebd4203efa810efb89784d948be1c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_funcs.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h new file mode 100644 index 0000000000000000000000000000000000000000..9eecd1dd855c5728f1b7bcc0e6f5af681ab1a059 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h @@ -0,0 +1,271 @@ +// Types used in iterator implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator_base_types.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file contains all of the general iterator-related utility types, + * such as iterator_traits and struct iterator. + */ + +#ifndef _STL_ITERATOR_BASE_TYPES_H +#define _STL_ITERATOR_BASE_TYPES_H 1 + +#pragma GCC system_header + +#include + +#if __cplusplus >= 201103L +# include // For __void_t, is_convertible +#endif + +#if __cplusplus > 201703L && __cpp_concepts >= 201907L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup iterators Iterators + * Abstractions for uniform iterating through various underlying types. + */ + ///@{ + + /** + * @defgroup iterator_tags Iterator Tags + * These are empty types, used to distinguish different iterators. The + * distinction is not made by what they contain, but simply by what they + * are. Different underlying algorithms can then be used based on the + * different operations supported by different iterator types. + */ + ///@{ + /// Marking input iterators. + struct input_iterator_tag { }; + + /// Marking output iterators. + struct output_iterator_tag { }; + + /// Forward iterators support a superset of input iterator operations. + struct forward_iterator_tag : public input_iterator_tag { }; + + /// Bidirectional iterators support a superset of forward iterator + /// operations. + struct bidirectional_iterator_tag : public forward_iterator_tag { }; + + /// Random-access iterators support a superset of bidirectional + /// iterator operations. + struct random_access_iterator_tag : public bidirectional_iterator_tag { }; + +#if __cplusplus > 201703L + /// Contiguous iterators point to objects stored contiguously in memory. + struct contiguous_iterator_tag : public random_access_iterator_tag { }; +#endif + ///@} + + /** + * @brief Common %iterator class. + * + * This class does nothing but define nested typedefs. %Iterator classes + * can inherit from this class to save some work. The typedefs are then + * used in specializations and overloading. + * + * In particular, there are no default implementations of requirements + * such as @c operator++ and the like. (How could there be?) + */ + template + struct _GLIBCXX17_DEPRECATED iterator + { + /// One of the @link iterator_tags tag types@endlink. + typedef _Category iterator_category; + /// The type "pointed to" by the iterator. + typedef _Tp value_type; + /// Distance between iterators is represented as this type. + typedef _Distance difference_type; + /// This type represents a pointer-to-value_type. + typedef _Pointer pointer; + /// This type represents a reference-to-value_type. + typedef _Reference reference; + }; + + /** + * @brief Traits class for iterators. + * + * This class does nothing but define nested typedefs. The general + * version simply @a forwards the nested typedefs from the Iterator + * argument. Specialized versions for pointers and pointers-to-const + * provide tighter, more correct semantics. + */ + template + struct iterator_traits; + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2408. SFINAE-friendly common_type/iterator_traits is missing in C++14 + template> + struct __iterator_traits { }; + +#if ! __cpp_lib_concepts + + template + struct __iterator_traits<_Iterator, + __void_t> + { + 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; + }; +#endif // ! concepts + + template + struct iterator_traits + : public __iterator_traits<_Iterator> { }; + +#else // ! C++11 + template + 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; + }; +#endif // C++11 + +#if __cplusplus > 201703L + /// Partial specialization for object pointer types. + template +#if __cpp_concepts >= 201907L + requires is_object_v<_Tp> +#endif + struct iterator_traits<_Tp*> + { + using iterator_concept = contiguous_iterator_tag; + using iterator_category = random_access_iterator_tag; + using value_type = remove_cv_t<_Tp>; + using difference_type = ptrdiff_t; + using pointer = _Tp*; + using reference = _Tp&; + }; +#else + /// Partial specialization for pointer types. + template + 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; + }; + + /// Partial specialization for const pointer types. + template + struct iterator_traits + { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + }; +#endif + + /** + * This function is not a part of the C++ standard but is syntactic + * sugar for internal library use only. + */ + template + inline _GLIBCXX_CONSTEXPR + typename iterator_traits<_Iter>::iterator_category + __iterator_category(const _Iter&) + { return typename iterator_traits<_Iter>::iterator_category(); } + + ///@} + +#if __cplusplus >= 201103L + template + using __iterator_category_t + = typename iterator_traits<_Iter>::iterator_category; + + template + using _RequireInputIter = + __enable_if_t, + input_iterator_tag>::value>; + + template> + struct __is_random_access_iter + : is_base_of + { + typedef is_base_of _Base; + enum { __value = _Base::value }; + }; +#else + template, + typename _Cat = typename _Traits::iterator_category> + struct __is_random_access_iter + { enum { __value = __is_base_of(random_access_iterator_tag, _Cat) }; }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_ITERATOR_BASE_TYPES_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9f9cfc4525e9d29fbc7dd57535106ad78c1f79e8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_iterator_base_types.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h new file mode 100644 index 0000000000000000000000000000000000000000..b8bd46191fce852f8ea639c3d670230ff3ad5767 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h @@ -0,0 +1,2262 @@ +// List implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// Copyright The GNU Toolchain Authors. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_list.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{list} + */ + +#ifndef _STL_LIST_H +#define _STL_LIST_H 1 + +#include +#include +#if __cplusplus >= 201103L +#include +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail + { + // Supporting structures are split into common and templated + // types; the latter publicly inherits from the former in an + // effort to reduce code duplication. This results in some + // "needless" static_cast'ing later on, but it's all safe + // downcasting. + + /// Common part of a node in the %list. + struct _List_node_base + { + _List_node_base* _M_next; + _List_node_base* _M_prev; + + static void + swap(_List_node_base& __x, _List_node_base& __y) _GLIBCXX_USE_NOEXCEPT; + + void + _M_transfer(_List_node_base* const __first, + _List_node_base* const __last) _GLIBCXX_USE_NOEXCEPT; + + void + _M_reverse() _GLIBCXX_USE_NOEXCEPT; + + void + _M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT; + + void + _M_unhook() _GLIBCXX_USE_NOEXCEPT; + }; + + /// The %list node header. + struct _List_node_header : public _List_node_base + { +#if _GLIBCXX_USE_CXX11_ABI + std::size_t _M_size; +#endif + + _List_node_header() _GLIBCXX_NOEXCEPT + { _M_init(); } + +#if __cplusplus >= 201103L + _List_node_header(_List_node_header&& __x) noexcept + : _List_node_base{ __x._M_next, __x._M_prev } +# if _GLIBCXX_USE_CXX11_ABI + , _M_size(__x._M_size) +# endif + { + if (__x._M_base()->_M_next == __x._M_base()) + this->_M_next = this->_M_prev = this; + else + { + this->_M_next->_M_prev = this->_M_prev->_M_next = this->_M_base(); + __x._M_init(); + } + } + + void + _M_move_nodes(_List_node_header&& __x) + { + _List_node_base* const __xnode = __x._M_base(); + if (__xnode->_M_next == __xnode) + _M_init(); + else + { + _List_node_base* const __node = this->_M_base(); + __node->_M_next = __xnode->_M_next; + __node->_M_prev = __xnode->_M_prev; + __node->_M_next->_M_prev = __node->_M_prev->_M_next = __node; +# if _GLIBCXX_USE_CXX11_ABI + _M_size = __x._M_size; +# endif + __x._M_init(); + } + } +#endif + + void + _M_init() _GLIBCXX_NOEXCEPT + { + this->_M_next = this->_M_prev = this; +#if _GLIBCXX_USE_CXX11_ABI + this->_M_size = 0; +#endif + } + + private: + _List_node_base* _M_base() { return this; } + }; + + // Used by list::sort to hold nodes being sorted. + struct _Scratch_list : _List_node_base + { + _Scratch_list() { _M_next = _M_prev = this; } + + bool empty() const { return _M_next == this; } + + void swap(_List_node_base& __l) { _List_node_base::swap(*this, __l); } + + template + struct _Ptr_cmp + { + _Cmp _M_cmp; + + bool + operator()(__detail::_List_node_base* __lhs, + __detail::_List_node_base* __rhs) /* not const */ + { return _M_cmp(*_Iter(__lhs), *_Iter(__rhs)); } + }; + + template + struct _Ptr_cmp<_Iter, void> + { + bool + operator()(__detail::_List_node_base* __lhs, + __detail::_List_node_base* __rhs) const + { return *_Iter(__lhs) < *_Iter(__rhs); } + }; + + // Merge nodes from __x into *this. Both lists must be sorted wrt _Cmp. + template + void + merge(_List_node_base& __x, _Cmp __comp) + { + _List_node_base* __first1 = _M_next; + _List_node_base* const __last1 = this; + _List_node_base* __first2 = __x._M_next; + _List_node_base* const __last2 = std::__addressof(__x); + + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + _List_node_base* __next = __first2->_M_next; + __first1->_M_transfer(__first2, __next); + __first2 = __next; + } + else + __first1 = __first1->_M_next; + } + if (__first2 != __last2) + this->_M_transfer(__first2, __last2); + } + + // Splice the node at __i into *this. + void _M_take_one(_List_node_base* __i) + { this->_M_transfer(__i, __i->_M_next); } + + // Splice all nodes from *this after __i. + void _M_put_all(_List_node_base* __i) + { + if (!empty()) + __i->_M_transfer(_M_next, this); + } + }; + + } // namespace detail + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// An actual node in the %list. + template + struct _List_node : public __detail::_List_node_base + { +#if __cplusplus >= 201103L + __gnu_cxx::__aligned_membuf<_Tp> _M_storage; + _Tp* _M_valptr() { return _M_storage._M_ptr(); } + _Tp const* _M_valptr() const { return _M_storage._M_ptr(); } +#else + _Tp _M_data; + _Tp* _M_valptr() { return std::__addressof(_M_data); } + _Tp const* _M_valptr() const { return std::__addressof(_M_data); } +#endif + }; + + /** + * @brief A list::iterator. + * + * All the functions are op overloads. + */ + template + struct _List_iterator + { + typedef _List_iterator<_Tp> _Self; + typedef _List_node<_Tp> _Node; + + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + + _List_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _Self + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return *this; } + + // Must downcast from _List_node_base to _List_node to get to value. + _GLIBCXX_NODISCARD + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Node*>(_M_node)->_M_valptr(); } + + _GLIBCXX_NODISCARD + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Node*>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_next; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_prev; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_prev; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + _GLIBCXX_NODISCARD + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + // The only member points to the %list element. + __detail::_List_node_base* _M_node; + }; + + /** + * @brief A list::const_iterator. + * + * All the functions are op overloads. + */ + template + struct _List_const_iterator + { + typedef _List_const_iterator<_Tp> _Self; + typedef const _List_node<_Tp> _Node; + typedef _List_iterator<_Tp> iterator; + + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + _List_const_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _List_const_iterator(const __detail::_List_node_base* __x) + _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _List_const_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT + : _M_node(__x._M_node) { } + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(const_cast<__detail::_List_node_base*>(_M_node)); } + + // Must downcast from List_node_base to _List_node to get to value. + _GLIBCXX_NODISCARD + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Node*>(_M_node)->_M_valptr(); } + + _GLIBCXX_NODISCARD + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Node*>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_next; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_prev; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_prev; + return __tmp; + } + + _GLIBCXX_NODISCARD + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + _GLIBCXX_NODISCARD + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + // The only member points to the %list element. + const __detail::_List_node_base* _M_node; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + /// See bits/stl_deque.h's _Deque_base for an explanation. + template + class _List_base + { + protected: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tp_alloc_traits; + typedef typename _Tp_alloc_traits::template + rebind<_List_node<_Tp> >::other _Node_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; + +#if !_GLIBCXX_INLINE_VERSION + static size_t + _S_distance(const __detail::_List_node_base* __first, + const __detail::_List_node_base* __last) + { + size_t __n = 0; + while (__first != __last) + { + __first = __first->_M_next; + ++__n; + } + return __n; + } +#endif + + struct _List_impl + : public _Node_alloc_type + { + __detail::_List_node_header _M_node; + + _List_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Node_alloc_type>::value) + : _Node_alloc_type() + { } + + _List_impl(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Node_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + _List_impl(_List_impl&&) = default; + + _List_impl(_Node_alloc_type&& __a, _List_impl&& __x) + : _Node_alloc_type(std::move(__a)), _M_node(std::move(__x._M_node)) + { } + + _List_impl(_Node_alloc_type&& __a) noexcept + : _Node_alloc_type(std::move(__a)) + { } +#endif + }; + + _List_impl _M_impl; + +#if _GLIBCXX_USE_CXX11_ABI + size_t _M_get_size() const { return _M_impl._M_node._M_size; } + + void _M_set_size(size_t __n) { _M_impl._M_node._M_size = __n; } + + void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; } + + void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; } + +# if !_GLIBCXX_INLINE_VERSION + size_t + _M_distance(const __detail::_List_node_base* __first, + const __detail::_List_node_base* __last) const + { return _S_distance(__first, __last); } + + // return the stored size + size_t _M_node_count() const { return _M_get_size(); } +# endif +#else + // dummy implementations used when the size is not stored + size_t _M_get_size() const { return 0; } + void _M_set_size(size_t) { } + void _M_inc_size(size_t) { } + void _M_dec_size(size_t) { } + +# if !_GLIBCXX_INLINE_VERSION + size_t _M_distance(const void*, const void*) const { return 0; } + + // count the number of nodes + size_t _M_node_count() const + { + return _S_distance(_M_impl._M_node._M_next, + std::__addressof(_M_impl._M_node)); + } +# endif +#endif + + typename _Node_alloc_traits::pointer + _M_get_node() + { return _Node_alloc_traits::allocate(_M_impl, 1); } + + void + _M_put_node(typename _Node_alloc_traits::pointer __p) _GLIBCXX_NOEXCEPT + { _Node_alloc_traits::deallocate(_M_impl, __p, 1); } + + public: + typedef _Alloc allocator_type; + + _Node_alloc_type& + _M_get_Node_allocator() _GLIBCXX_NOEXCEPT + { return _M_impl; } + + const _Node_alloc_type& + _M_get_Node_allocator() const _GLIBCXX_NOEXCEPT + { return _M_impl; } + +#if __cplusplus >= 201103L + _List_base() = default; +#else + _List_base() { } +#endif + + _List_base(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _M_impl(__a) + { } + +#if __cplusplus >= 201103L + _List_base(_List_base&&) = default; + +# if !_GLIBCXX_INLINE_VERSION + _List_base(_List_base&& __x, _Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { + if (__x._M_get_Node_allocator() == _M_get_Node_allocator()) + _M_move_nodes(std::move(__x)); + // else caller must move individual elements. + } +# endif + + // Used when allocator is_always_equal. + _List_base(_Node_alloc_type&& __a, _List_base&& __x) + : _M_impl(std::move(__a), std::move(__x._M_impl)) + { } + + // Used when allocator !is_always_equal. + _List_base(_Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { } + + void + _M_move_nodes(_List_base&& __x) + { _M_impl._M_node._M_move_nodes(std::move(__x._M_impl._M_node)); } +#endif + + // This is what actually destroys the list. + ~_List_base() _GLIBCXX_NOEXCEPT + { _M_clear(); } + + void + _M_clear() _GLIBCXX_NOEXCEPT; + + void + _M_init() _GLIBCXX_NOEXCEPT + { this->_M_impl._M_node._M_init(); } + }; + + /** + * @brief A standard container with linear time access to elements, + * and fixed time insertion/deletion at any point in the sequence. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements with the + * %exception of @c at and @c operator[]. + * + * This is a @e doubly @e linked %list. Traversal up and down the + * %list requires linear time, but adding and removing elements (or + * @e nodes) is done in constant time, regardless of where the + * change takes place. Unlike std::vector and std::deque, + * random-access iterators are not provided, so subscripting ( @c + * [] ) access is not allowed. For algorithms which only need + * sequential access, this lack makes no difference. + * + * Also unlike the other standard containers, std::list provides + * specialized algorithms %unique to linked lists, such as + * splicing, sorting, and in-place reversal. + * + * A couple points on memory allocation for list: + * + * First, we never actually allocate a Tp, we allocate + * List_node's and trust [20.1.5]/4 to DTRT. This is to ensure + * that after elements from %list are spliced into + * %list, destroying the memory of the second %list is a + * valid operation, i.e., Alloc1 giveth and Alloc2 taketh away. + * + * Second, a %list conceptually represented as + * @code + * A <---> B <---> C <---> D + * @endcode + * is actually circular; a link exists between A and D. The %list + * class holds (as its only data member) a private list::iterator + * pointing to @e D, not to @e A! To get to the head of the %list, + * we start at the tail and move forward by one. When this member + * iterator's next/previous pointers refer to itself, the %list is + * %empty. + */ + template > + class list : protected _List_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::list must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::list must have the same value_type as its allocator"); +# endif +#endif + + typedef _List_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits; + typedef typename _Base::_Node_alloc_type _Node_alloc_type; + typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; + + public: + typedef _Tp value_type; + typedef typename _Tp_alloc_traits::pointer pointer; + typedef typename _Tp_alloc_traits::const_pointer const_pointer; + typedef typename _Tp_alloc_traits::reference reference; + typedef typename _Tp_alloc_traits::const_reference const_reference; + typedef _List_iterator<_Tp> iterator; + typedef _List_const_iterator<_Tp> const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + protected: + // Note that pointers-to-_Node's can be ctor-converted to + // iterator types. + typedef _List_node<_Tp> _Node; + + using _Base::_M_impl; + using _Base::_M_put_node; + using _Base::_M_get_node; + using _Base::_M_get_Node_allocator; + + /** + * @param __args An instance of user data. + * + * Allocates space for a new node and constructs a copy of + * @a __args in it. + */ +#if __cplusplus < 201103L + _Node* + _M_create_node(const value_type& __x) + { + _Node* __p = this->_M_get_node(); + __try + { + _Tp_alloc_type __alloc(_M_get_Node_allocator()); + __alloc.construct(__p->_M_valptr(), __x); + } + __catch(...) + { + _M_put_node(__p); + __throw_exception_again; + } + return __p; + } +#else + template + _Node* + _M_create_node(_Args&&... __args) + { + auto __p = this->_M_get_node(); + auto& __alloc = _M_get_Node_allocator(); + __allocated_ptr<_Node_alloc_type> __guard{__alloc, __p}; + _Node_alloc_traits::construct(__alloc, __p->_M_valptr(), + std::forward<_Args>(__args)...); + __guard = nullptr; + return __p; + } +#endif + +#if _GLIBCXX_USE_CXX11_ABI + static size_t + _S_distance(const_iterator __first, const_iterator __last) + { return std::distance(__first, __last); } + + // return the stored size + size_t + _M_node_count() const + { return this->_M_get_size(); } +#else + // dummy implementations used when the size is not stored + static size_t + _S_distance(const_iterator, const_iterator) + { return 0; } + + // count the number of nodes + size_t + _M_node_count() const + { return std::distance(begin(), end()); } +#endif + + public: + // [23.2.2.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %list with no elements. + */ +#if __cplusplus >= 201103L + list() = default; +#else + list() { } +#endif + + /** + * @brief Creates a %list with no elements. + * @param __a An allocator object. + */ + explicit + list(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _Base(_Node_alloc_type(__a)) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %list with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n default + * constructed elements. + */ + explicit + list(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n copies of @a __value. + */ + list(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_fill_initialize(__n, __value); } +#else + /** + * @brief Creates a %list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n copies of @a __value. + */ + explicit + list(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_fill_initialize(__n, __value); } +#endif + + /** + * @brief %List copy constructor. + * @param __x A %list of identical element and allocator types. + * + * The newly-created %list uses a copy of the allocation object used + * by @a __x (unless the allocator traits dictate a different object). + */ + list(const list& __x) + : _Base(_Node_alloc_traits:: + _S_select_on_copy(__x._M_get_Node_allocator())) + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } + +#if __cplusplus >= 201103L + /** + * @brief %List move constructor. + * + * The newly-created %list contains the exact contents of the moved + * instance. The contents of the moved instance are a valid, but + * unspecified %list. + */ + list(list&&) = default; + + /** + * @brief Builds a %list from an initializer_list + * @param __l An initializer_list of value_type. + * @param __a An allocator object. + * + * Create a %list consisting of copies of the elements in the + * initializer_list @a __l. This is linear in __l.size(). + */ + list(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); } + + list(const list& __x, const __type_identity_t& __a) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } + + private: + list(list&& __x, const allocator_type& __a, true_type) noexcept + : _Base(_Node_alloc_type(__a), std::move(__x)) + { } + + list(list&& __x, const allocator_type& __a, false_type) + : _Base(_Node_alloc_type(__a)) + { + if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) + this->_M_move_nodes(std::move(__x)); + else + insert(begin(), std::__make_move_if_noexcept_iterator(__x.begin()), + std::__make_move_if_noexcept_iterator(__x.end())); + } + + public: + list(list&& __x, const __type_identity_t& __a) + noexcept(_Node_alloc_traits::_S_always_equal()) + : list(std::move(__x), __a, + typename _Node_alloc_traits::is_always_equal{}) + { } +#endif + + /** + * @brief Builds a %list from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator object. + * + * Create a %list consisting of copies of the elements from + * [@a __first,@a __last). This is linear in N (where N is + * distance(@a __first,@a __last)). + */ +#if __cplusplus >= 201103L + template> + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__first, __last, __false_type()); } +#else + template + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * No explicit dtor needed as the _Base dtor takes care of + * things. The _Base dtor only erases the elements, and note + * that if the elements themselves are pointers, the pointed-to + * memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + ~list() = default; +#endif + + /** + * @brief %List assignment operator. + * @param __x A %list of identical element and allocator types. + * + * All the elements of @a __x are copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + list& + operator=(const list& __x); + +#if __cplusplus >= 201103L + /** + * @brief %List move assignment operator. + * @param __x A %list of identical element and allocator types. + * + * The contents of @a __x are moved into this %list (without copying). + * + * Afterwards @a __x is a valid, but unspecified %list + * + * Whether the allocator is moved depends on the allocator traits. + */ + list& + operator=(list&& __x) + noexcept(_Node_alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Node_alloc_traits::_S_propagate_on_move_assign() + || _Node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief %List initializer list assignment operator. + * @param __l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a __l. This is linear in l.size(). + */ + list& + operator=(initializer_list __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %list. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %list with @a __n copies of the given + * value. Note that the assignment completely changes the %list + * and that the resulting %list's size is the same as the number + * of elements assigned. + */ + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %list with copies of the elements in the + * range [@a __first,@a __last). + * + * Note that the assignment completely changes the %list and + * that the resulting %list's size is the same as the number of + * elements assigned. + */ +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_dispatch(__first, __last, __false_type()); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer_list to a %list. + * @param __l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a __l. This is linear in __l.size(). + */ + void + assign(initializer_list __l) + { this->_M_assign_dispatch(__l.begin(), __l.end(), __false_type()); } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_Base::_M_get_Node_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first element in the + * %list. Iteration is done in ordinary element order. + */ + _GLIBCXX_NODISCARD + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %list. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %list. Iteration is done in ordinary element + * order. + */ + _GLIBCXX_NODISCARD + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(&this->_M_impl._M_node); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %list. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(&this->_M_impl._M_node); } + + /** + * Returns a read/write reverse iterator that points to the last + * element in the %list. Iteration is done in reverse element + * order. + */ + _GLIBCXX_NODISCARD + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points to + * the last element in the %list. Iteration is done in reverse + * element order. + */ + _GLIBCXX_NODISCARD + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %list. Iteration is done in + * reverse element order. + */ + _GLIBCXX_NODISCARD + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first element in the %list. Iteration is done in reverse + * element order. + */ + _GLIBCXX_NODISCARD + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %list. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] + const_iterator + cend() const noexcept + { return const_iterator(&this->_M_impl._M_node); } + + /** + * Returns a read-only (constant) reverse iterator that points to + * the last element in the %list. Iteration is done in reverse + * element order. + */ + [[__nodiscard__]] + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first element in the %list. Iteration is done in reverse + * element order. + */ + [[__nodiscard__]] + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // [23.2.2.2] capacity + /** + * Returns true if the %list is empty. (Thus begin() would equal + * end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; } + + /** Returns the number of elements in the %list. */ + _GLIBCXX_NODISCARD + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_node_count(); } + + /** Returns the size() of the largest possible %list. */ + _GLIBCXX_NODISCARD + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Node_alloc_traits::max_size(_M_get_Node_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise default + * constructed elements are appended. + */ + void + resize(size_type __new_size); + + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise the %list is + * extended and new elements are populated with given data. + */ + void + resize(size_type __new_size, const value_type& __x); +#else + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise the %list is + * extended and new elements are populated with given data. + */ + void + resize(size_type __new_size, value_type __x = value_type()); +#endif + + // element access + /** + * Returns a read/write reference to the data at the first + * element of the %list. + */ + _GLIBCXX_NODISCARD + reference + front() _GLIBCXX_NOEXCEPT + { return *begin(); } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %list. + */ + _GLIBCXX_NODISCARD + const_reference + front() const _GLIBCXX_NOEXCEPT + { return *begin(); } + + /** + * Returns a read/write reference to the data at the last element + * of the %list. + */ + _GLIBCXX_NODISCARD + reference + back() _GLIBCXX_NOEXCEPT + { + iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %list. + */ + _GLIBCXX_NODISCARD + const_reference + back() const _GLIBCXX_NOEXCEPT + { + const_iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + // [23.2.2.3] modifiers + /** + * @brief Add data to the front of the %list. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %list and assigns the given data + * to it. Due to the nature of a %list this operation can be + * done in constant time, and does not invalidate iterators and + * references. + */ + void + push_front(const value_type& __x) + { this->_M_insert(begin(), __x); } + +#if __cplusplus >= 201103L + void + push_front(value_type&& __x) + { this->_M_insert(begin(), std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args) + { + this->_M_insert(begin(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } +#endif + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %list by + * one. Due to the nature of a %list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. + * + * Note that no data is returned, and if the first element's data + * is needed, it should be retrieved before pop_front() is + * called. + */ + void + pop_front() _GLIBCXX_NOEXCEPT + { this->_M_erase(begin()); } + + /** + * @brief Add data to the end of the %list. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %list and assigns the given data to + * it. Due to the nature of a %list this operation can be done + * in constant time, and does not invalidate iterators and + * references. + */ + void + push_back(const value_type& __x) + { this->_M_insert(end(), __x); } + +#if __cplusplus >= 201103L + void + push_back(value_type&& __x) + { this->_M_insert(end(), std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + this->_M_insert(end(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %list by + * one. Due to the nature of a %list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. + * + * Note that no data is returned, and if the last element's data + * is needed, it should be retrieved before pop_back() is called. + */ + void + pop_back() _GLIBCXX_NOEXCEPT + { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); } + +#if __cplusplus >= 201103L + /** + * @brief Constructs object in %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified + * location. Due to the nature of a %list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template + iterator + emplace(const_iterator __position, _Args&&... __args); + + /** + * @brief Inserts given value into %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %list before specified iterator. + * @param __position An iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(const_iterator __position, value_type&& __x) + { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts the contents of an initializer_list into %list + * before specified const_iterator. + * @param __p A const_iterator into the %list. + * @param __l An initializer_list of value_type. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert copies of the data in the + * initializer_list @a l into the %list before the location + * specified by @a p. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a number of copies of given data into the %list. + * @param __position A const_iterator into the %list. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert a specified number of copies of the + * given data before the location specified by @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x); +#else + /** + * @brief Inserts a number of copies of given data into the %list. + * @param __position An iterator into the %list. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of the + * given data before the location specified by @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { + list __tmp(__n, __x, get_allocator()); + splice(__position, __tmp); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %list. + * @param __position A const_iterator into the %list. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %list before the location specified by + * @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last); +#else + /** + * @brief Inserts a range into the %list. + * @param __position An iterator into the %list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %list before the location specified by + * @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + list __tmp(__first, __last, get_allocator()); + splice(__position, __tmp); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %list by one. + * + * Due to the nature of a %list this operation can be done in + * constant time, and only invalidates iterators/references to + * the element being removed. The user is also cautioned that + * this function only erases the element, and that if the element + * is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) noexcept; +#else + erase(iterator __position); +#endif + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a last + * prior to erasing (or end()). + * + * This function will erase the elements in the range @a + * [first,last) and shorten the %list accordingly. + * + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) noexcept +#else + erase(iterator __first, iterator __last) +#endif + { + while (__first != __last) + __first = erase(__first); + return __last._M_const_cast(); + } + + /** + * @brief Swaps data with another %list. + * @param __x A %list of the same element and allocator types. + * + * This exchanges the elements between two lists in constant + * time. Note that the global std::swap() function is + * specialized such that std::swap(l1,l2) will feed to this + * function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(list& __x) _GLIBCXX_NOEXCEPT + { + __detail::_List_node_base::swap(this->_M_impl._M_node, + __x._M_impl._M_node); + + size_t __xsize = __x._M_get_size(); + __x._M_set_size(this->_M_get_size()); + this->_M_set_size(__xsize); + + _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { + _Base::_M_clear(); + _Base::_M_init(); + } + + // [23.2.2.4] list operations + /** + * @brief Insert contents of another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * + * The elements of @a __x are inserted in constant time in front of + * the element referenced by @a __position. @a __x becomes an empty + * list. + * + * Requires this != @a __x. + */ + void +#if __cplusplus >= 201103L + splice(const_iterator __position, list&& __x) noexcept +#else + splice(iterator __position, list& __x) +#endif + { + if (!__x.empty()) + { + _M_check_equal_allocators(__x); + + this->_M_transfer(__position._M_const_cast(), + __x.begin(), __x.end()); + + this->_M_inc_size(__x._M_get_size()); + __x._M_set_size(0); + } + } + +#if __cplusplus >= 201103L + void + splice(const_iterator __position, list& __x) noexcept + { splice(__position, std::move(__x)); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(const_iterator __position, list&& __x, const_iterator __i) noexcept +#else + /** + * @brief Insert element from another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * @param __i Iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(iterator __position, list& __x, iterator __i) +#endif + { + iterator __j = __i._M_const_cast(); + ++__j; + if (__position == __i || __position == __j) + return; + + if (this != std::__addressof(__x)) + _M_check_equal_allocators(__x); + + this->_M_transfer(__position._M_const_cast(), + __i._M_const_cast(), __j); + + this->_M_inc_size(1); + __x._M_dec_size(1); + } + +#if __cplusplus >= 201103L + /** + * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(const_iterator __position, list& __x, const_iterator __i) noexcept + { splice(__position, std::move(__x), __i); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) noexcept +#else + /** + * @brief Insert range from another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * @param __first Iterator referencing the start of range in x. + * @param __last Iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(iterator __position, list& __x, iterator __first, + iterator __last) +#endif + { + if (__first != __last) + { + if (this != std::__addressof(__x)) + _M_check_equal_allocators(__x); + + size_t __n = _S_distance(__first, __last); + this->_M_inc_size(__n); + __x._M_dec_size(__n); + + this->_M_transfer(__position._M_const_cast(), + __first._M_const_cast(), + __last._M_const_cast()); + } + } + +#if __cplusplus >= 201103L + /** + * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(const_iterator __position, list& __x, const_iterator __first, + const_iterator __last) noexcept + { splice(__position, std::move(__x), __first, __last); } +#endif + + private: +#if __cplusplus > 201703L +# define __cpp_lib_list_remove_return_type 201806L + typedef size_type __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +#else + typedef void __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG +#endif + public: + + /** + * @brief Remove all elements equal to value. + * @param __value The value to remove. + * + * Removes every element in the list equal to @a value. + * Remaining elements stay in list order. Note that this + * function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __value); + + /** + * @brief Remove all elements satisfying a predicate. + * @tparam _Predicate Unary predicate function or object. + * + * Removes every element in the list for which the predicate + * returns true. Remaining elements stay in list order. Note + * that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + template + __remove_return_type + remove_if(_Predicate); + + /** + * @brief Remove consecutive duplicate elements. + * + * For each consecutive set of elements with the same value, + * remove all but the first one. Remaining elements stay in + * list order. Note that this function only erases the + * elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique(); + + /** + * @brief Remove consecutive elements satisfying a predicate. + * @tparam _BinaryPredicate Binary predicate function or object. + * + * For each consecutive set of elements [first,last) that + * satisfy predicate(first,i) where i is an iterator in + * [first,last), remove all but the first one. Remaining + * elements stay in list order. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + template + __remove_return_type + unique(_BinaryPredicate); + +#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + + /** + * @brief Merge sorted lists. + * @param __x Sorted list to merge. + * + * Assumes that both @a __x and this list are sorted according to + * operator<(). Merges elements of @a __x into this list in + * sorted order, leaving @a __x empty when complete. Elements in + * this list precede elements in @a __x that are equal. + */ +#if __cplusplus >= 201103L + void + merge(list&& __x); + + void + merge(list& __x) + { merge(std::move(__x)); } +#else + void + merge(list& __x); +#endif + + /** + * @brief Merge sorted lists according to comparison function. + * @tparam _StrictWeakOrdering Comparison function defining + * sort order. + * @param __x Sorted list to merge. + * @param __comp Comparison functor. + * + * Assumes that both @a __x and this list are sorted according to + * StrictWeakOrdering. Merges elements of @a __x into this list + * in sorted order, leaving @a __x empty when complete. Elements + * in this list precede elements in @a __x that are equivalent + * according to StrictWeakOrdering(). + */ +#if __cplusplus >= 201103L + template + void + merge(list&& __x, _StrictWeakOrdering __comp); + + template + void + merge(list& __x, _StrictWeakOrdering __comp) + { merge(std::move(__x), __comp); } +#else + template + void + merge(list& __x, _StrictWeakOrdering __comp); +#endif + + /** + * @brief Reverse the elements in list. + * + * Reverse the order of elements in the list in linear time. + */ + void + reverse() _GLIBCXX_NOEXCEPT + { this->_M_impl._M_node._M_reverse(); } + + /** + * @brief Sort the elements. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + void + sort(); + + /** + * @brief Sort the elements according to comparison function. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + template + void + sort(_StrictWeakOrdering); + + protected: + // Internal constructor functions follow. + + // Called by the range constructor to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { _M_fill_initialize(static_cast(__n), __x); } + + // Called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } + + // Called by list(n,v,a), and the range constructor when it turns out + // to be the same thing. + void + _M_fill_initialize(size_type __n, const value_type& __x) + { + for (; __n; --__n) + push_back(__x); + } + +#if __cplusplus >= 201103L + // Called by list(n). + void + _M_default_initialize(size_type __n) + { + for (; __n; --__n) + emplace_back(); + } + + // Called by resize(sz). + void + _M_default_append(size_type __n); +#endif + + // Internal assign functions follow. + + // Called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // Called by the range assign to implement [23.1.1]/9 + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type); + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + void + _M_fill_assign(size_type __n, const value_type& __val); + + + // Moves the elements from [first,last) before position. + void + _M_transfer(iterator __position, iterator __first, iterator __last) + { __position._M_node->_M_transfer(__first._M_node, __last._M_node); } + + // Inserts new element at position given and with value given. +#if __cplusplus < 201103L + void + _M_insert(iterator __position, const value_type& __x) + { + _Node* __tmp = _M_create_node(__x); + __tmp->_M_hook(__position._M_node); + this->_M_inc_size(1); + } +#else + template + void + _M_insert(iterator __position, _Args&&... __args) + { + _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); + __tmp->_M_hook(__position._M_node); + this->_M_inc_size(1); + } +#endif + + // Erases element at position given. + void + _M_erase(iterator __position) _GLIBCXX_NOEXCEPT + { + this->_M_dec_size(1); + __position._M_node->_M_unhook(); + _Node* __n = static_cast<_Node*>(__position._M_node); +#if __cplusplus >= 201103L + _Node_alloc_traits::destroy(_M_get_Node_allocator(), __n->_M_valptr()); +#else + _Tp_alloc_type(_M_get_Node_allocator()).destroy(__n->_M_valptr()); +#endif + + _M_put_node(__n); + } + + // To implement the splice (and merge) bits of N1599. + void + _M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT + { + if (std::__alloc_neq:: + _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator())) + __builtin_abort(); + } + + // Used to implement resize. + const_iterator + _M_resize_pos(size_type& __new_size) const; + +#if __cplusplus >= 201103L + void + _M_move_assign(list&& __x, true_type) noexcept + { + this->clear(); + this->_M_move_nodes(std::move(__x)); + std::__alloc_on_move(this->_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + void + _M_move_assign(list&& __x, false_type) + { + if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) + _M_move_assign(std::move(__x), true_type{}); + else + // The rvalue's allocator cannot be moved, or is not equal, + // so we need to individually move each element. + _M_assign_dispatch(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + __false_type{}); + } +#endif + +#if _GLIBCXX_USE_CXX11_ABI + // Update _M_size members after merging (some of) __src into __dest. + struct _Finalize_merge + { + explicit + _Finalize_merge(list& __dest, list& __src, const iterator& __src_next) + : _M_dest(__dest), _M_src(__src), _M_next(__src_next) + { } + + ~_Finalize_merge() + { + // For the common case, _M_next == _M_sec.end() and the std::distance + // call is fast. But if any *iter1 < *iter2 comparison throws then we + // have to count how many elements remain in _M_src. + const size_t __num_unmerged = std::distance(_M_next, _M_src.end()); + const size_t __orig_size = _M_src._M_get_size(); + _M_dest._M_inc_size(__orig_size - __num_unmerged); + _M_src._M_set_size(__num_unmerged); + } + + list& _M_dest; + list& _M_src; + const iterator& _M_next; + +#if __cplusplus >= 201103L + _Finalize_merge(const _Finalize_merge&) = delete; +#endif + }; +#else + struct _Finalize_merge + { explicit _Finalize_merge(list&, list&, const iterator&) { } }; +#endif + + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> list<_ValT, _Allocator>; +#endif + +_GLIBCXX_END_NAMESPACE_CXX11 + + /** + * @brief List equality comparison. + * @param __x A %list. + * @param __y A %list of the same type as @a __x. + * @return True iff the size and elements of the lists are equal. + * + * This is an equivalence relation. It is linear in the size of + * the lists. Lists are considered equivalent if their sizes are + * equal, and if corresponding elements compare equal. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { +#if _GLIBCXX_USE_CXX11_ABI + if (__x.size() != __y.size()) + return false; +#endif + + typedef typename list<_Tp, _Alloc>::const_iterator const_iterator; + const_iterator __end1 = __x.end(); + const_iterator __end2 = __y.end(); + + const_iterator __i1 = __x.begin(); + const_iterator __i2 = __y.begin(); + while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) + { + ++__i1; + ++__i2; + } + return __i1 == __end1 && __i2 == __end2; + } + +#if __cpp_lib_three_way_comparison +/** + * @brief List ordering relation. + * @param __x A `list`. + * @param __y A `list` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + [[nodiscard]] + inline __detail::__synth3way_t<_Tp> + operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief List ordering relation. + * @param __x A %list. + * @param __y A %list of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * lists. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::list::swap(). + template + inline void + swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if _GLIBCXX_USE_CXX11_ABI + + // Detect when distance is used to compute the size of the whole list. + template + inline ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_iterator<_Tp> __first, + _GLIBCXX_STD_C::_List_iterator<_Tp> __last, + input_iterator_tag __tag) + { + typedef _GLIBCXX_STD_C::_List_const_iterator<_Tp> _CIter; + return std::__distance(_CIter(__first), _CIter(__last), __tag); + } + + template + inline ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp> __first, + _GLIBCXX_STD_C::_List_const_iterator<_Tp> __last, + input_iterator_tag) + { + typedef __detail::_List_node_header _Sentinel; + _GLIBCXX_STD_C::_List_const_iterator<_Tp> __beyond = __last; + ++__beyond; + const bool __whole = __first == __beyond; + if (__builtin_constant_p (__whole) && __whole) + return static_cast(__last._M_node)->_M_size; + + ptrdiff_t __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_LIST_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a3f465bc69b71f7fb33f159d8547f52535b2edae Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_list.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h new file mode 100644 index 0000000000000000000000000000000000000000..9c2b0745673431b4b396ba27982170478838137e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h @@ -0,0 +1,1616 @@ +// Map implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_map.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map} + */ + +#ifndef _STL_MAP_H +#define _STL_MAP_H 1 + +#include +#include +#if __cplusplus >= 201103L +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class multimap; + + /** + * @brief A standard container made up of (key,value) pairs, which can be + * retrieved based on a key, in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to + * allocator. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using unique keys). + * For a @c map the key_type is Key, the mapped_type is T, and the + * value_type is std::pair. + * + * Maps support bidirectional iterators. + * + * The private tree data is declared exactly the same way for map and + * multimap; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator > > + class map + { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::map must have the same value_type as its allocator"); +#endif +#endif + + public: +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + class value_compare + : public std::binary_function + { + friend class map<_Key, _Tp, _Compare, _Alloc>; + protected: + _Compare comp; + + value_compare(_Compare __c) + : comp(__c) { } + + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; +#pragma GCC diagnostic pop + + private: + /// This turns a red-black tree into a [multi]map. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; + + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; + +#if __cplusplus >= 201703L + template> + static constexpr bool __usable_key + = __or_v, + __and_, is_scalar<_Key>>>; +#endif + + public: + // many of these are specified differently in ISO, but the following are + // "functionally equivalent" + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; + using insert_return_type = typename _Rep_type::insert_return_type; +#endif + + // [23.3.1.1] construct/copy/destroy + // (get_allocator() is also listed in this section) + + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + map() : _M_t() { } +#else + map() = default; +#endif + + /** + * @brief Creates a %map with no elements. + * @param __comp A comparison object. + * @param __a An allocator object. + */ + explicit + map(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) { } + + /** + * @brief %Map copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + map(const map& __x) + : _M_t(__x._M_t) { } +#else + map(const map&) = default; + + /** + * @brief %Map move constructor. + * + * The newly-created %map contains the exact contents of the moved + * instance. The moved instance is a valid, but unspecified, %map. + */ + map(map&&) = default; + + /** + * @brief Builds a %map from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison object. + * @param __a An allocator object. + * + * Create a %map consisting of copies of the elements in the + * initializer_list @a __l. + * This is linear in N if the range is already sorted, and NlogN + * otherwise (where N is @a __l.size()). + */ + map(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + map(const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + map(const map& __m, const __type_identity_t& __a) + : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + map(map&& __m, const __type_identity_t& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + map(initializer_list __l, const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + map(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } +#endif + + /** + * @brief Builds a %map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %map consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + map(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief Builds a %map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %map consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + map(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus >= 201103L + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~map() = default; +#endif + + /** + * @brief %Map assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + map& + operator=(const map& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + map& + operator=(const map&) = default; + + /// Move assignment operator. + map& + operator=(map&&) = default; + + /** + * @brief %Map list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %map with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %map and + * that the resulting %map's size is the same as the number + * of elements assigned. + */ + map& + operator=(initializer_list __l) + { + _M_t._M_assign_unique(__l.begin(), __l.end()); + return *this; + } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first pair in the + * %map. + * Iteration is done in ascending order according to the keys. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %map. Iteration is done in ascending order according to the + * keys. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read/write iterator that points one past the last + * pair in the %map. Iteration is done in ascending order + * according to the keys. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %map. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read/write reverse iterator that points to the last pair in + * the %map. Iteration is done in descending order according to the + * keys. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %map. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first pair in the %map. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %map. Iteration is done in descending + * order according to the keys. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %map. Iteration is done in ascending order according to the + * keys. + */ + const_iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %map. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %map. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %map. Iteration is done in descending + * order according to the keys. + */ + const_reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + // capacity + /** Returns true if the %map is empty. (Thus begin() would equal + * end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /** Returns the size of the %map. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /** Returns the maximum size of the %map. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + // [23.3.1.2] element access + /** + * @brief Subscript ( @c [] ) access to %map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data of the (key,data) %pair. + * + * Allows for easy lookup with the subscript ( @c [] ) + * operator. Returns data associated with the key specified in + * subscript. If the key does not exist, a pair with that key + * is created using default values, which is then returned. + * + * Lookup requires logarithmic time. + */ + mapped_type& + operator[](const key_type& __k) + { + // concept requirements + __glibcxx_function_requires(_DefaultConstructibleConcept) + + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) +#if __cplusplus >= 201103L + __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, + std::tuple(__k), + std::tuple<>()); +#else + __i = insert(__i, value_type(__k, mapped_type())); +#endif + return (*__i).second; + } + +#if __cplusplus >= 201103L + mapped_type& + operator[](key_type&& __k) + { + // concept requirements + __glibcxx_function_requires(_DefaultConstructibleConcept) + + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) + __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::tuple<>()); + return (*__i).second; + } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + /** + * @brief Access to %map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data whose key is equivalent to @a __k, if + * such a data is present in the %map. + * @throw std::out_of_range If no such data is present. + */ + mapped_type& + at(const key_type& __k) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + + const mapped_type& + at(const key_type& __k) const + { + const_iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + + // modifiers +#if __cplusplus >= 201103L + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * + * Insertion requires logarithmic time. + */ + template + std::pair + emplace(_Args&&... __args) + { +#if __cplusplus >= 201703L + if constexpr (sizeof...(_Args) == 2) + if constexpr (is_same_v>) + { + auto&& [__a, __v] = pair<_Args&...>(__args...); + if constexpr (__usable_key) + { + const key_type& __k = __a; + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::forward<_Args>(__args)...); + return {__i, true}; + } + return {__i, false}; + } + } +#endif + return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); + } + + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_unique(__pos, + std::forward<_Args>(__args)...); + } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_unique(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus > 201402L +#define __cpp_lib_map_try_emplace 201411L + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __args Arguments used to generate the .second for a new pair + * instance. + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If a %pair is not inserted, this function has no effect. + * + * Insertion requires logarithmic time. + */ + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + return {__i, true}; + } + return {__i, false}; + } + + // move-capable overload + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + return {__i, true}; + } + return {__i, false}; + } + + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __args Arguments used to generate the .second for a new pair + * instance. + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument + * try_emplace() does. However, if insertion did not take place, + * this function has no effect. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + __i = emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + else + __i = iterator(__true_hint.first); + return __i; + } + + // move-capable overload + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + __i = emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + else + __i = iterator(__true_hint.first); + return __i; + } +#endif + + /** + * @brief Attempts to insert a std::pair into the %map. + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * + * Insertion requires logarithmic time. + * @{ + */ + std::pair + insert(const value_type& __x) + { return _M_t._M_insert_unique(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { return _M_t._M_insert_unique(std::move(__x)); } + + template + __enable_if_t::value, + pair> + insert(_Pair&& __x) + { +#if __cplusplus >= 201703L + using _P2 = remove_reference_t<_Pair>; + if constexpr (__is_pair<_P2>) + if constexpr (is_same_v>) + if constexpr (__usable_key) + { + const key_type& __k = __x.first; + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::forward<_Pair>(__x)); + return {__i, true}; + } + return {__i, false}; + } +#endif + return _M_t._M_emplace_unique(std::forward<_Pair>(__x)); + } +#endif + /// @} + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of std::pairs into the %map. + * @param __list A std::initializer_list of pairs to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(std::initializer_list __list) + { insert(__list.begin(), __list.end()); } +#endif + + /** + * @brief Attempts to insert a std::pair into the %map. + * @param __position An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + + * This function is not concerned about whether the insertion + * took place, and thus does not return a boolean like the + * single-argument insert() does. Note that the first + * parameter is only a hint and can potentially improve the + * performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + * @{ + */ + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { return _M_t._M_insert_unique_(__position, __x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_unique_(__position, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __position, _Pair&& __x) + { + return _M_t._M_emplace_hint_unique(__position, + std::forward<_Pair>(__x)); + } +#endif + /// @} + + /** + * @brief Template function that attempts to insert a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus > 201402L + /** + * @brief Attempts to insert or assign a std::pair into the %map. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If the %pair was already in the %map, the .second of the %pair + * is assigned from __obj. + * + * Insertion requires logarithmic time. + */ + template + pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + return {__i, true}; + } + (*__i).second = std::forward<_Obj>(__obj); + return {__i, false}; + } + + // move-capable overload + template + pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + return {__i, true}; + } + (*__i).second = std::forward<_Obj>(__obj); + return {__i, false}; + } + + /** + * @brief Attempts to insert or assign a std::pair into the %map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If the %pair was already in the %map, the .second of the %pair + * is assigned from __obj. + * + * Insertion requires logarithmic time. + */ + template + iterator + insert_or_assign(const_iterator __hint, + const key_type& __k, _Obj&& __obj) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + { + return emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + } + __i = iterator(__true_hint.first); + (*__i).second = std::forward<_Obj>(__obj); + return __i; + } + + // move-capable overload + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + { + return emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + } + __i = iterator(__true_hint.first); + (*__i).second = std::forward<_Obj>(__obj); + return __i; + } +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %map. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given + * iterator, from a %map. Note that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + * + * @{ + */ + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } + + // LWG 2059 + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return _M_t.erase(__position); } + /// @} +#else + /** + * @brief Erases an element from a %map. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given + * iterator, from a %map. Note that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [__first,__last) range of elements from a %map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %map. + * @param __x A %map of the same element and allocator types. + * + * This exchanges the elements between two maps in constant + * time. (It is only swapping a pointer, an integer, and an + * instance of the @c Compare type (which itself is often + * stateless and empty), so it should be quite fast.) Note + * that the global std::swap() function is specialized such + * that std::swap(m1,m2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(map& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + /** + * Erases all elements in a %map. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // observers + /** + * Returns the key comparison object out of which the %map was + * constructed. + */ + key_compare + key_comp() const + { return _M_t.key_comp(); } + + /** + * Returns a value comparison object, built from the key comparison + * object out of which the %map was constructed. + */ + value_compare + value_comp() const + { return value_compare(_M_t.key_comp()); } + + // [23.3.1.3] map operations + + ///@{ + /** + * @brief Tries to locate an element in a %map. + * @param __x Key of (key, value) %pair to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after %pair. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Tries to locate an element in a %map. + * @param __x Key of (key, value) %pair to be located. + * @return Read-only (constant) iterator pointing to sought-after + * element, or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns a constant + * iterator pointing to the sought after %pair. If unsuccessful it + * returns the past-the-end ( @c end() ) iterator. + */ + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of (key, value) pairs to be located. + * @return Number of elements with specified key. + * + * This function only makes sense for multimaps; for map the result will + * either be 0 (not present) or 1 (present). + */ + size_type + count(const key_type& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of (key, value) pairs to be located. + * @return True if there is an element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first element + * equal to or greater than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first iterator + * greater than key, or end(). + */ + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multimaps. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of read-only (constant) iterators that possibly points + * to the subsequence matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multimaps. + */ + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair( + _M_t._M_equal_range_tr(__x))) + { + return pair( + _M_t._M_equal_range_tr(__x)); + } +#endif + ///@} + + template + friend bool + operator==(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t> + operator<=>(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); +#else + template + friend bool + operator<(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); +#endif + }; + + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<_Key, _Tp, _Compare, _Allocator>; + + template , + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, _Allocator) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + map(initializer_list>, _Allocator) + -> map<_Key, _Tp, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Map equality comparison. + * @param __x A %map. + * @param __y A %map of the same type as @a x. + * @return True iff the size and elements of the maps are equal. + * + * This is an equivalence relation. It is linear in the size of the + * maps. Maps are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Map ordering relation. + * @param __x A `map`. + * @param __y A `map` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t> + operator<=>(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Map ordering relation. + * @param __x A %map. + * @param __y A %map of the same type as @a x. + * @return True iff @a x is lexicographically less than @a y. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Based on operator== + template + inline bool + operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::map::swap(). + template + inline void + swap(map<_Key, _Tp, _Compare, _Alloc>& __x, + map<_Key, _Tp, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::map access to internals of compatible maps. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MAP_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ee5bc494656a9df771886bb067540ce32be854e0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_map.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h new file mode 100644 index 0000000000000000000000000000000000000000..f6b08bca3f3ecd6539dae563fcbc289a7f1e5915 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h @@ -0,0 +1,1237 @@ +// Multimap implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_multimap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map} + */ + +#ifndef _STL_MULTIMAP_H +#define _STL_MULTIMAP_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class map; + + /** + * @brief A standard container made up of (key,value) pairs, which can be + * retrieved based on a key, in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to + * allocator. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using equivalent + * keys). For a @c multimap the key_type is Key, the mapped_type + * is T, and the value_type is std::pair. + * + * Multimaps support bidirectional iterators. + * + * The private tree data is declared exactly the same way for map and + * multimap; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator > > + class multimap + { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::multimap must have the same value_type as its allocator"); +#endif +#endif + + public: +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + class value_compare + : public std::binary_function + { + friend class multimap<_Key, _Tp, _Compare, _Alloc>; + protected: + _Compare comp; + + value_compare(_Compare __c) + : comp(__c) { } + + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; +#pragma GCC diagnostic pop + + private: + /// This turns a red-black tree into a [multi]map. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; + + public: + // many of these are specified differently in ISO, but the following are + // "functionally equivalent" + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; +#endif + + // [23.3.2] construct/copy/destroy + // (get_allocator() is also listed in this section) + + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + multimap() : _M_t() { } +#else + multimap() = default; +#endif + + /** + * @brief Creates a %multimap with no elements. + * @param __comp A comparison object. + * @param __a An allocator object. + */ + explicit + multimap(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) { } + + /** + * @brief %Multimap copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multimap(const multimap& __x) + : _M_t(__x._M_t) { } +#else + multimap(const multimap&) = default; + + /** + * @brief %Multimap move constructor. + * + * The newly-created %multimap contains the exact contents of the + * moved instance. The moved instance is a valid, but unspecified + * %multimap. + */ + multimap(multimap&&) = default; + + /** + * @brief Builds a %multimap from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multimap consisting of copies of the elements from + * the initializer_list. This is linear in N if the list is already + * sorted, and NlogN otherwise (where N is @a __l.size()). + */ + multimap(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + multimap(const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + multimap(const multimap& __m, + const __type_identity_t& __a) + : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + multimap(multimap&& __m, const __type_identity_t& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + multimap(initializer_list __l, const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + multimap(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } +#endif + + /** + * @brief Builds a %multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %multimap consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multimap(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief Builds a %multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multimap consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~multimap() = default; +#endif + + /** + * @brief %Multimap assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multimap& + operator=(const multimap& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + multimap& + operator=(const multimap&) = default; + + /// Move assignment operator. + multimap& + operator=(multimap&&) = default; + + /** + * @brief %Multimap list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %multimap with copies of the elements + * in the initializer list @a __l. + * + * Note that the assignment completely changes the %multimap and + * that the resulting %multimap's size is the same as the number + * of elements assigned. + */ + multimap& + operator=(initializer_list __l) + { + _M_t._M_assign_equal(__l.begin(), __l.end()); + return *this; + } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first pair in the + * %multimap. Iteration is done in ascending order according to the + * keys. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %multimap. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read/write iterator that points one past the last pair in + * the %multimap. Iteration is done in ascending order according to the + * keys. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %multimap. Iteration is done in ascending order according + * to the keys. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read/write reverse iterator that points to the last pair in + * the %multimap. Iteration is done in descending order according to the + * keys. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %multimap. Iteration is done in + * descending order according to the keys. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %multimap. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %multimap. Iteration is done in ascending order according + * to the keys. + */ + const_iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %multimap. Iteration is done in + * descending order according to the keys. + */ + const_reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + // capacity + /** Returns true if the %multimap is empty. */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /** Returns the size of the %multimap. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /** Returns the maximum size of the %multimap. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + // modifiers +#if __cplusplus >= 201103L + /** + * @brief Build and insert a std::pair into the %multimap. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return An iterator that points to the inserted (key,value) pair. + * + * This function builds and inserts a (key, value) %pair into the + * %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * + * Insertion requires logarithmic time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } + + /** + * @brief Builds and inserts a std::pair into the %multimap. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_equal(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Inserts a std::pair into the %multimap. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * + * Insertion requires logarithmic time. + * @{ + */ + iterator + insert(const value_type& __x) + { return _M_t._M_insert_equal(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(value_type&& __x) + { return _M_t._M_insert_equal(std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(_Pair&& __x) + { return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); } +#endif + /// @} + + /** + * @brief Inserts a std::pair into the %multimap. + * @param __position An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + * @{ + */ + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { return _M_t._M_insert_equal_(__position, __x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_equal_(__position, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __position, _Pair&& __x) + { + return _M_t._M_emplace_hint_equal(__position, + std::forward<_Pair>(__x)); + } +#endif + /// @} + + /** + * @brief A template function that attempts to insert a range + * of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of std::pairs into the %multimap. + * @param __l A std::initializer_list of pairs to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_equal(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %multimap. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %multimap. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + * + * @{ + */ + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } + + // LWG 2059. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return _M_t.erase(__position); } + /// @} +#else + /** + * @brief Erases an element from a %multimap. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %multimap. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all elements located by the given key from a + * %multimap. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to be + * erased . + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %multimap. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %multimap. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %multimap. + * @param __x A %multimap of the same element and allocator types. + * + * This exchanges the elements between two multimaps in constant time. + * (It is only swapping a pointer, an integer, and an instance of + * the @c Compare type (which itself is often stateless and empty), so it + * should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(multimap& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + /** + * Erases all elements in a %multimap. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // observers + /** + * Returns the key comparison object out of which the %multimap + * was constructed. + */ + key_compare + key_comp() const + { return _M_t.key_comp(); } + + /** + * Returns a value comparison object, built from the key comparison + * object out of which the %multimap was constructed. + */ + value_compare + value_comp() const + { return value_compare(_M_t.key_comp()); } + + // multimap operations + + ///@{ + /** + * @brief Tries to locate an element in a %multimap. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to sought-after element, + * or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after %pair. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Tries to locate an element in a %multimap. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to sought-after + * element, or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns a constant + * iterator pointing to the sought after %pair. If unsuccessful it + * returns the past-the-end ( @c end() ) iterator. + */ + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of (key, value) pairs to be located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_t.count(__x); } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of (key, value) pairs to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first element + * equal to or greater than key, or end(). + * + * This function returns the first element of a subsequence of + * elements that matches the given key. If unsuccessful the + * iterator will point to the next greatest element or, if no + * such greater element exists, to end(). + */ + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first iterator + * greater than key, or end(). + */ + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of read-only (constant) iterators that possibly points + * to the subsequence matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + */ + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair( + _M_t._M_equal_range_tr(__x))) + { + return pair( + _M_t._M_equal_range_tr(__x)); + } +#endif + ///@} + + template + friend bool + operator==(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t> + operator<=>(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); +#else + template + friend bool + operator<(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<_Key, _Tp, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, _Allocator) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + multimap(initializer_list>, _Allocator) + -> multimap<_Key, _Tp, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Multimap equality comparison. + * @param __x A %multimap. + * @param __y A %multimap of the same type as @a __x. + * @return True iff the size and elements of the maps are equal. + * + * This is an equivalence relation. It is linear in the size of the + * multimaps. Multimaps are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Multimap ordering relation. + * @param __x A `multimap`. + * @param __y A `multimap` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t> + operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Multimap ordering relation. + * @param __x A %multimap. + * @param __y A %multimap of the same type as @a __x. + * @return True iff @a x is lexicographically less than @a y. + * + * This is a total ordering relation. It is linear in the size of the + * multimaps. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Based on operator== + template + inline bool + operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::multimap::swap(). + template + inline void + swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, + multimap<_Key, _Tp, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::multimap access to internals of compatible maps. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MULTIMAP_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..464490e9c122870639357be150d87864f693a5da Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multimap.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h new file mode 100644 index 0000000000000000000000000000000000000000..1fbccd70c3db3d6abc666fea20feb1cb0ad99bfd --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h @@ -0,0 +1,1076 @@ +// Multiset implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_multiset.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{set} + */ + +#ifndef _STL_MULTISET_H +#define _STL_MULTISET_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class set; + + /** + * @brief A standard container made up of elements, which can be retrieved + * in logarithmic time. + * + * @ingroup associative_containers + * + * + * @tparam _Key Type of key objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using equivalent + * keys). For a @c multiset the key_type and value_type are Key. + * + * Multisets support bidirectional iterators. + * + * The private tree data is declared exactly the same way for set and + * multiset; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator<_Key> > + class multiset + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Key>::value, + "std::multiset must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::multiset must have the same value_type as its allocator"); +# endif +#endif + + public: + // typedefs: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Alloc allocator_type; + + private: + /// This turns a red-black tree into a [multi]set. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits; + + public: + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 103. set::iterator is required to be modifiable, + // but this allows modification of keys. + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; +#endif + + // allocation/deallocation + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + multiset() : _M_t() { } +#else + multiset() = default; +#endif + + /** + * @brief Creates a %multiset with no elements. + * @param __comp Comparator to use. + * @param __a An allocator object. + */ + explicit + multiset(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) { } + + /** + * @brief Builds a %multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %multiset consisting of copies of the elements from + * [first,last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multiset(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief Builds a %multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multiset consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief %Multiset copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multiset(const multiset& __x) + : _M_t(__x._M_t) { } +#else + multiset(const multiset&) = default; + + /** + * @brief %Multiset move constructor. + * + * The newly-created %multiset contains the exact contents of the + * moved instance. The moved instance is a valid, but unspecified + * %multiset. + */ + multiset(multiset&&) = default; + + /** + * @brief Builds a %multiset from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multiset consisting of copies of the elements from + * the list. This is linear in N if the list is already sorted, + * and NlogN otherwise (where N is @a __l.size()). + */ + multiset(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + multiset(const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + multiset(const multiset& __m, + const __type_identity_t& __a) + : _M_t(__m._M_t, _Key_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + multiset(multiset&& __m, const __type_identity_t& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Key_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + multiset(initializer_list __l, const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + multiset(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~multiset() = default; +#endif + + /** + * @brief %Multiset assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multiset& + operator=(const multiset& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + multiset& + operator=(const multiset&) = default; + + /// Move assignment operator. + multiset& + operator=(multiset&&) = default; + + /** + * @brief %Multiset list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %multiset with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %multiset and + * that the resulting %multiset's size is the same as the number + * of elements assigned. + */ + multiset& + operator=(initializer_list __l) + { + _M_t._M_assign_equal(__l.begin(), __l.end()); + return *this; + } +#endif + + // accessors: + + /// Returns the comparison object. + key_compare + key_comp() const + { return _M_t.key_comp(); } + /// Returns the comparison object. + value_compare + value_comp() const + { return _M_t.key_comp(); } + /// Returns the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + /// Returns true if the %set is empty. + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /// Returns the size of the %set. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /// Returns the maximum size of the %set. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + /** + * @brief Swaps data with another %multiset. + * @param __x A %multiset of the same element and allocator types. + * + * This exchanges the elements between two multisets in constant time. + * (It is only swapping a pointer, an integer, and an instance of the @c + * Compare type (which itself is often stateless and empty), so it should + * be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(multiset& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + // insert/erase +#if __cplusplus >= 201103L + /** + * @brief Builds and inserts an element into the %multiset. + * @param __args Arguments used to generate the element instance to be + * inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Insertion requires logarithmic time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } + + /** + * @brief Builds and inserts an element into the %multiset. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element instance to be + * inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_equal(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Inserts an element into the %multiset. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Insertion requires logarithmic time. + */ + iterator + insert(const value_type& __x) + { return _M_t._M_insert_equal(__x); } + +#if __cplusplus >= 201103L + iterator + insert(value_type&& __x) + { return _M_t._M_insert_equal(std::move(__x)); } +#endif + + /** + * @brief Inserts an element into the %multiset. + * @param __position An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + iterator + insert(const_iterator __position, const value_type& __x) + { return _M_t._M_insert_equal_(__position, __x); } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_equal_(__position, std::move(__x)); } +#endif + + /** + * @brief A template function that tries to insert a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of elements into the %multiset. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_equal(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(multiset<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(set<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(set<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %multiset. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %multiset. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } +#else + /** + * @brief Erases an element from a %multiset. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %multiset. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all elements located by the given key from a + * %multiset. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multiset. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a last. + * + * This function erases a sequence of elements from a %multiset. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [first,last) range of elements from a %multiset. + * @param first Iterator pointing to the start of the range to be + * erased. + * @param last Iterator pointing to the end of the range to be erased. + * + * This function erases a sequence of elements from a %multiset. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * Erases all elements in a %multiset. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // multiset operations: + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of elements to be located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_t.count(__x); } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + ///@{ + /** + * @brief Tries to locate an element in a %set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } + + template + auto + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } + + template + auto + lower_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } + + template + auto + upper_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } + + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + template + friend bool + operator==(const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t<_K1> + operator<=>(const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); +#else + template + friend bool + operator< (const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, _Allocator) + -> multiset::value_type, + less::value_type>, + _Allocator>; + + template> + multiset(initializer_list<_Key>, _Allocator) + -> multiset<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Multiset equality comparison. + * @param __x A %multiset. + * @param __y A %multiset of the same type as @a __x. + * @return True iff the size and elements of the multisets are equal. + * + * This is an equivalence relation. It is linear in the size of the + * multisets. + * Multisets are considered equivalent if their sizes are equal, and if + * corresponding elements compare equal. + */ + template + inline bool + operator==(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Multiset ordering relation. + * @param __x A `multiset`. + * @param __y A `multiset` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Key> + operator<=>(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Multiset ordering relation. + * @param __x A %multiset. + * @param __y A %multiset of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * sets. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Returns !(x == y). + template + inline bool + operator!=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Returns y < x. + template + inline bool + operator>(const multiset<_Key,_Compare,_Alloc>& __x, + const multiset<_Key,_Compare,_Alloc>& __y) + { return __y < __x; } + + /// Returns !(y < x) + template + inline bool + operator<=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Returns !(x < y) + template + inline bool + operator>=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::multiset::swap(). + template + inline void + swap(multiset<_Key, _Compare, _Alloc>& __x, + multiset<_Key, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::multiset access to internals of compatible sets. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MULTISET_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..37c5d34f801c311deaa39d32d058616ca5306714 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_multiset.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h new file mode 100644 index 0000000000000000000000000000000000000000..ea017d41e763247b713d32a2a5c48ac4b5be5a02 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h @@ -0,0 +1,413 @@ +// Numeric functions implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_numeric.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{numeric} + */ + +#ifndef _STL_NUMERIC_H +#define _STL_NUMERIC_H 1 + +#include +#include +#include // For _GLIBCXX_MOVE + + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @defgroup numeric_ops Generalized Numeric operations + * @ingroup algorithms + */ + +#if __cplusplus >= 201103L + /** + * @brief Create a range of sequentially increasing values. + * + * For each element in the range @p [first,last) assigns @p value and + * increments @p value as if by @p ++value. + * + * @param __first Start of range. + * @param __last End of range. + * @param __value Starting value. + * @return Nothing. + * @ingroup numeric_ops + */ + template + _GLIBCXX20_CONSTEXPR + void + iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + { + *__first = __value; + ++__value; + } + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + +#if __cplusplus > 201703L +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// DR 2055. std::move in std::accumulate and other algorithms +# define _GLIBCXX_MOVE_IF_20(_E) std::move(_E) +#else +# define _GLIBCXX_MOVE_IF_20(_E) _E +#endif + + /// @addtogroup numeric_ops + /// @{ + + /** + * @brief Accumulate values in a range. + * + * Accumulates the values in the range [first,last) using operator+(). The + * initial value is @a init. The values are processed in order. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @return The final sum. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + __init = _GLIBCXX_MOVE_IF_20(__init) + *__first; + return __init; + } + + /** + * @brief Accumulate values in a range with operation. + * + * Accumulates the values in the range `[first,last)` using the function + * object `__binary_op`. The initial value is `__init`. The values are + * processed in order. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @param __binary_op Function object to accumulate with. + * @return The final sum. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, + _BinaryOperation __binary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first); + return __init; + } + + /** + * @brief Compute inner product of two ranges. + * + * Starting with an initial value of @p __init, multiplies successive + * elements from the two ranges and adds each product into the accumulated + * value using operator+(). The values in the ranges are processed in + * order. + * + * @param __first1 Start of range 1. + * @param __last1 End of range 1. + * @param __first2 Start of range 2. + * @param __init Starting value to add other values to. + * @return The final inner product. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + __init = _GLIBCXX_MOVE_IF_20(__init) + (*__first1 * *__first2); + return __init; + } + + /** + * @brief Compute inner product of two ranges. + * + * Starting with an initial value of @p __init, applies @p __binary_op2 to + * successive elements from the two ranges and accumulates each result into + * the accumulated value using @p __binary_op1. The values in the ranges are + * processed in order. + * + * @param __first1 Start of range 1. + * @param __last1 End of range 1. + * @param __first2 Start of range 2. + * @param __init Starting value to add other values to. + * @param __binary_op1 Function object to accumulate with. + * @param __binary_op2 Function object to apply to pairs of input values. + * @return The final inner product. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init, + _BinaryOperation1 __binary_op1, + _BinaryOperation2 __binary_op2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + __init = __binary_op1(_GLIBCXX_MOVE_IF_20(__init), + __binary_op2(*__first1, *__first2)); + return __init; + } + + /** + * @brief Return list of partial sums + * + * Accumulates the values in the range [first,last) using the @c + operator. + * As each successive input value is added into the total, that partial sum + * is written to @p __result. Therefore, the first value in @p __result is + * the first value of the input, the second value in @p __result is the sum + * of the first and second input values, and so on. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @return Iterator pointing just beyond the values written to __result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + __value = _GLIBCXX_MOVE_IF_20(__value) + *__first; + *++__result = __value; + } + return ++__result; + } + + /** + * @brief Return list of partial sums + * + * Accumulates the values in the range [first,last) using @p __binary_op. + * As each successive input value is added into the total, that partial sum + * is written to @p __result. Therefore, the first value in @p __result is + * the first value of the input, the second value in @p __result is the sum + * of the first and second input values, and so on. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @param __binary_op Function object. + * @return Iterator pointing just beyond the values written to __result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + __value = __binary_op(_GLIBCXX_MOVE_IF_20(__value), *__first); + *++__result = __value; + } + return ++__result; + } + + /** + * @brief Return differences between adjacent values. + * + * Computes the difference between adjacent values in the range + * [first,last) using operator-() and writes the result to @p __result. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sums. + * @return Iterator pointing just beyond the values written to result. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 539. partial_sum and adjacent_difference should mention requirements + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + adjacent_difference(_InputIterator __first, + _InputIterator __last, _OutputIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __tmp - _GLIBCXX_MOVE_IF_20(__value); + __value = _GLIBCXX_MOVE(__tmp); + } + return ++__result; + } + + /** + * @brief Return differences between adjacent values. + * + * Computes the difference between adjacent values in the range + * [__first,__last) using the function object @p __binary_op and writes the + * result to @p __result. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @param __binary_op Function object. + * @return Iterator pointing just beyond the values written to result. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 539. partial_sum and adjacent_difference should mention requirements + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + adjacent_difference(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __binary_op(__tmp, _GLIBCXX_MOVE_IF_20(__value)); + __value = _GLIBCXX_MOVE(__tmp); + } + return ++__result; + } + + /// @} group numeric_ops + +#undef _GLIBCXX_MOVE_IF_20 + +_GLIBCXX_END_NAMESPACE_ALGO +} // namespace std + +#endif /* _STL_NUMERIC_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8b293b026311e415d491c2be99854e8216ed3be7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_numeric.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h new file mode 100644 index 0000000000000000000000000000000000000000..0eb78345ca455a61d5d889b92010d27aae7176f5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h @@ -0,0 +1,924 @@ +// Pair implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_pair.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + */ + +#ifndef _STL_PAIR_H +#define _STL_PAIR_H 1 + +#if __cplusplus >= 201103L +# include // for std::__decay_and_strip +# include // for std::move / std::forward, and std::swap +# include // for std::tuple_element, std::tuple_size +#endif +#if __cplusplus >= 202002L +# include +# define __cpp_lib_constexpr_utility 201811L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + +#if __cplusplus >= 201103L + /// Tag type for piecewise construction of std::pair objects. + struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; + + /// Tag for piecewise construction of std::pair objects. + _GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct = + piecewise_construct_t(); + + /// @cond undocumented + + // Forward declarations. + template + class tuple; + + template + struct _Index_tuple; + +#if ! __cpp_lib_concepts + // Concept utility functions, reused in conditionally-explicit + // constructors. + // See PR 70437, don't look at is_constructible or + // is_convertible if the types are the same to + // avoid querying those properties for incomplete types. + template + struct _PCC + { + template + static constexpr bool _ConstructiblePair() + { + return __and_, + is_constructible<_T2, const _U2&>>::value; + } + + template + static constexpr bool _ImplicitlyConvertiblePair() + { + return __and_, + is_convertible>::value; + } + + template + static constexpr bool _MoveConstructiblePair() + { + return __and_, + is_constructible<_T2, _U2&&>>::value; + } + + template + static constexpr bool _ImplicitlyMoveConvertiblePair() + { + return __and_, + is_convertible<_U2&&, _T2>>::value; + } + }; + + template + struct _PCC + { + template + static constexpr bool _ConstructiblePair() + { + return false; + } + + template + static constexpr bool _ImplicitlyConvertiblePair() + { + return false; + } + + template + static constexpr bool _MoveConstructiblePair() + { + return false; + } + + template + static constexpr bool _ImplicitlyMoveConvertiblePair() + { + return false; + } + }; +#endif // lib concepts +#endif // C++11 + + template class __pair_base + { +#if __cplusplus >= 201103L && ! __cpp_lib_concepts + template friend struct pair; + __pair_base() = default; + ~__pair_base() = default; + __pair_base(const __pair_base&) = default; + __pair_base& operator=(const __pair_base&) = delete; +#endif // C++11 + }; + + /// @endcond + + /** + * @brief Struct holding two objects of arbitrary type. + * + * @tparam _T1 Type of first object. + * @tparam _T2 Type of second object. + * + * + */ + template + struct pair + : public __pair_base<_T1, _T2> + { + typedef _T1 first_type; ///< The type of the `first` member + typedef _T2 second_type; ///< The type of the `second` member + + _T1 first; ///< The first member + _T2 second; ///< The second member + +#if __cplusplus >= 201103L + constexpr pair(const pair&) = default; ///< Copy constructor + constexpr pair(pair&&) = default; ///< Move constructor + + template + _GLIBCXX20_CONSTEXPR + pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); + + /// Swap the first members and then the second members. + _GLIBCXX20_CONSTEXPR void + swap(pair& __p) + noexcept(__and_<__is_nothrow_swappable<_T1>, + __is_nothrow_swappable<_T2>>::value) + { + using std::swap; + swap(first, __p.first); + swap(second, __p.second); + } + + private: + template + _GLIBCXX20_CONSTEXPR + pair(tuple<_Args1...>&, tuple<_Args2...>&, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); + public: + +#if __cpp_lib_concepts + // C++20 implementation using concepts, explicit(bool), fully constexpr. + + /// Default constructor + constexpr + explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>, + __is_implicitly_default_constructible<_T2>>>()) + pair() + requires is_default_constructible_v<_T1> + && is_default_constructible_v<_T2> + : first(), second() + { } + + private: + + /// @cond undocumented + template + static constexpr bool + _S_constructible() + { + if constexpr (is_constructible_v<_T1, _U1>) + return is_constructible_v<_T2, _U2>; + return false; + } + + template + static constexpr bool + _S_nothrow_constructible() + { + if constexpr (is_nothrow_constructible_v<_T1, _U1>) + return is_nothrow_constructible_v<_T2, _U2>; + return false; + } + + template + static constexpr bool + _S_convertible() + { + if constexpr (is_convertible_v<_U1, _T1>) + return is_convertible_v<_U2, _T2>; + return false; + } + /// @endcond + + public: + + /// Constructor accepting lvalues of `first_type` and `second_type` + constexpr explicit(!_S_convertible()) + pair(const _T1& __x, const _T2& __y) + noexcept(_S_nothrow_constructible()) + requires (_S_constructible()) + : first(__x), second(__y) + { } + + /// Constructor accepting two values of arbitrary types + template + requires (_S_constructible<_U1, _U2>()) + constexpr explicit(!_S_convertible<_U1, _U2>()) + pair(_U1&& __x, _U2&& __y) + noexcept(_S_nothrow_constructible<_U1, _U2>()) + : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) + { } + + /// Converting constructor from a `pair` lvalue + template + requires (_S_constructible()) + constexpr explicit(!_S_convertible()) + pair(const pair<_U1, _U2>& __p) + noexcept(_S_nothrow_constructible()) + : first(__p.first), second(__p.second) + { } + + /// Converting constructor from a `pair` rvalue + template + requires (_S_constructible<_U1, _U2>()) + constexpr explicit(!_S_convertible<_U1, _U2>()) + pair(pair<_U1, _U2>&& __p) + noexcept(_S_nothrow_constructible<_U1, _U2>()) + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) + { } + + private: + /// @cond undocumented + template + static constexpr bool + _S_assignable() + { + if constexpr (is_assignable_v<_T1&, _U1>) + return is_assignable_v<_T2&, _U2>; + return false; + } + + template + static constexpr bool + _S_nothrow_assignable() + { + if constexpr (is_nothrow_assignable_v<_T1&, _U1>) + return is_nothrow_assignable_v<_T2&, _U2>; + return false; + } + /// @endcond + + public: + + pair& operator=(const pair&) = delete; + + /// Copy assignment operator + constexpr pair& + operator=(const pair& __p) + noexcept(_S_nothrow_assignable()) + requires (_S_assignable()) + { + first = __p.first; + second = __p.second; + return *this; + } + + /// Move assignment operator + constexpr pair& + operator=(pair&& __p) + noexcept(_S_nothrow_assignable<_T1, _T2>()) + requires (_S_assignable<_T1, _T2>()) + { + first = std::forward(__p.first); + second = std::forward(__p.second); + return *this; + } + + /// Converting assignment from a `pair` lvalue + template + constexpr pair& + operator=(const pair<_U1, _U2>& __p) + noexcept(_S_nothrow_assignable()) + requires (_S_assignable()) + { + first = __p.first; + second = __p.second; + return *this; + } + + /// Converting assignment from a `pair` rvalue + template + constexpr pair& + operator=(pair<_U1, _U2>&& __p) + noexcept(_S_nothrow_assignable<_U1, _U2>()) + requires (_S_assignable<_U1, _U2>()) + { + first = std::forward<_U1>(__p.first); + second = std::forward<_U2>(__p.second); + return *this; + } +#else + // C++11/14/17 implementation using enable_if, partially constexpr. + + /** The default constructor creates @c first and @c second using their + * respective default constructors. */ + template , + __is_implicitly_default_constructible<_U2>> + ::value, bool>::type = true> + constexpr pair() + : first(), second() { } + + template , + is_default_constructible<_U2>, + __not_< + __and_<__is_implicitly_default_constructible<_U1>, + __is_implicitly_default_constructible<_U2>>>> + ::value, bool>::type = false> + explicit constexpr pair() + : first(), second() { } + + // Shortcut for constraining the templates that don't take pairs. + /// @cond undocumented + using _PCCP = _PCC; + /// @endcond + + /// Construct from two const lvalues, allowing implicit conversions. + template() + && _PCCP::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } + + /// Construct from two const lvalues, disallowing implicit conversions. + template() + && !_PCCP::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } + + // Shortcut for constraining the templates that take pairs. + /// @cond undocumented + template + using _PCCFP = _PCC::value + || !is_same<_T2, _U2>::value, + _T1, _T2>; + /// @endcond + + template::template + _ConstructiblePair<_U1, _U2>() + && _PCCFP<_U1, _U2>::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } + + template::template + _ConstructiblePair<_U1, _U2>() + && !_PCCFP<_U1, _U2>::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } + +#if _GLIBCXX_USE_DEPRECATED +#if defined(__DEPRECATED) +# define _GLIBCXX_DEPRECATED_PAIR_CTOR \ + __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \ + "initialize std::pair of move-only " \ + "type and pointer"))) +#else +# define _GLIBCXX_DEPRECATED_PAIR_CTOR +#endif + + private: + /// @cond undocumented + + // A type which can be constructed from literal zero, but not nullptr + struct __zero_as_null_pointer_constant + { + __zero_as_null_pointer_constant(int __zero_as_null_pointer_constant::*) + { } + template::value>> + __zero_as_null_pointer_constant(_Tp) = delete; + }; + /// @endcond + public: + + // Deprecated extensions to DR 811. + // These allow construction from an rvalue and a literal zero, + // in cases where the standard says the zero should be deduced as int + template>, + is_pointer<_T2>, + is_constructible<_T1, _U1>, + __not_>, + is_convertible<_U1, _T1>>::value, + bool> = true> + _GLIBCXX_DEPRECATED_PAIR_CTOR + constexpr + pair(_U1&& __x, __zero_as_null_pointer_constant, ...) + : first(std::forward<_U1>(__x)), second(nullptr) { } + + template>, + is_pointer<_T2>, + is_constructible<_T1, _U1>, + __not_>, + __not_>>::value, + bool> = false> + _GLIBCXX_DEPRECATED_PAIR_CTOR + explicit constexpr + pair(_U1&& __x, __zero_as_null_pointer_constant, ...) + : first(std::forward<_U1>(__x)), second(nullptr) { } + + template, + __not_>, + is_constructible<_T2, _U2>, + __not_>, + is_convertible<_U2, _T2>>::value, + bool> = true> + _GLIBCXX_DEPRECATED_PAIR_CTOR + constexpr + pair(__zero_as_null_pointer_constant, _U2&& __y, ...) + : first(nullptr), second(std::forward<_U2>(__y)) { } + + template, + __not_>, + is_constructible<_T2, _U2>, + __not_>, + __not_>>::value, + bool> = false> + _GLIBCXX_DEPRECATED_PAIR_CTOR + explicit constexpr + pair(__zero_as_null_pointer_constant, _U2&& __y, ...) + : first(nullptr), second(std::forward<_U2>(__y)) { } +#undef _GLIBCXX_DEPRECATED_PAIR_CTOR +#endif + + template() + && _PCCP::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(_U1&& __x, _U2&& __y) + : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } + + template() + && !_PCCP::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(_U1&& __x, _U2&& __y) + : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } + + + template::template + _MoveConstructiblePair<_U1, _U2>() + && _PCCFP<_U1, _U2>::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(pair<_U1, _U2>&& __p) + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) { } + + template::template + _MoveConstructiblePair<_U1, _U2>() + && !_PCCFP<_U1, _U2>::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(pair<_U1, _U2>&& __p) + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) { } + + pair& + operator=(__conditional_t<__and_, + is_copy_assignable<_T2>>::value, + const pair&, const __nonesuch&> __p) + { + first = __p.first; + second = __p.second; + return *this; + } + + pair& + operator=(__conditional_t<__and_, + is_move_assignable<_T2>>::value, + pair&&, __nonesuch&&> __p) + noexcept(__and_, + is_nothrow_move_assignable<_T2>>::value) + { + first = std::forward(__p.first); + second = std::forward(__p.second); + return *this; + } + + template + typename enable_if<__and_, + is_assignable<_T2&, const _U2&>>::value, + pair&>::type + operator=(const pair<_U1, _U2>& __p) + { + first = __p.first; + second = __p.second; + return *this; + } + + template + typename enable_if<__and_, + is_assignable<_T2&, _U2&&>>::value, + pair&>::type + operator=(pair<_U1, _U2>&& __p) + { + first = std::forward<_U1>(__p.first); + second = std::forward<_U2>(__p.second); + return *this; + } +#endif // lib concepts +#else + // C++03 implementation + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 265. std::pair::pair() effects overly restrictive + /** The default constructor creates @c first and @c second using their + * respective default constructors. */ + pair() : first(), second() { } + + /// Two objects may be passed to a `pair` constructor to be copied. + pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } + + /// Templated constructor to convert from other pairs. + template + pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } +#endif // C++11 + }; + + /// @relates pair @{ + +#if __cpp_deduction_guides >= 201606 + template pair(_T1, _T2) -> pair<_T1, _T2>; +#endif + + /// Two pairs of the same type are equal iff their members are equal. + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return __x.first == __y.first && __x.second == __y.second; } + +#if __cpp_lib_three_way_comparison && __cpp_lib_concepts + template + constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>, + __detail::__synth3way_t<_T2>> + operator<=>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { + if (auto __c = __detail::__synth3way(__x.first, __y.first); __c != 0) + return __c; + return __detail::__synth3way(__x.second, __y.second); + } +#else + /** Defines a lexicographical order for pairs. + * + * For two pairs of the same type, `P` is ordered before `Q` if + * `P.first` is less than `Q.first`, or if `P.first` and `Q.first` + * are equivalent (neither is less than the other) and `P.second` is less + * than `Q.second`. + */ + template + inline _GLIBCXX_CONSTEXPR 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); } + + /// Uses @c operator== to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__x == __y); } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return __y < __x; } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__y < __x); } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__x < __y); } +#endif // !(three_way_comparison && concepts) + +#if __cplusplus >= 201103L + /** Swap overload for pairs. Calls std::pair::swap(). + * + * @note This std::swap overload is not declared in C++03 mode, + * which has performance implications, e.g. see https://gcc.gnu.org/PR38466 + */ + template + _GLIBCXX20_CONSTEXPR inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_T1>, + __is_swappable<_T2>>::value>::type +#else + void +#endif + swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if, + __is_swappable<_T2>>::value>::type + swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; +#endif +#endif // __cplusplus >= 201103L + + /// @} relates pair + + /** + * @brief A convenience wrapper for creating a pair from two objects. + * @param __x The first object. + * @param __y The second object. + * @return A newly-constructed pair<> object of the appropriate type. + * + * The C++98 standard says the objects are passed by reference-to-const, + * but C++03 says they are passed by value (this was LWG issue #181). + * + * Since C++11 they have been passed by forwarding reference and then + * forwarded to the new members of the pair. To create a pair with a + * member of reference type, pass a `reference_wrapper` to this function. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 181. make_pair() unintended behavior +#if __cplusplus >= 201103L + // NB: DR 706. + template + constexpr pair::__type, + typename __decay_and_strip<_T2>::__type> + make_pair(_T1&& __x, _T2&& __y) + { + typedef typename __decay_and_strip<_T1>::__type __ds_type1; + typedef typename __decay_and_strip<_T2>::__type __ds_type2; + typedef pair<__ds_type1, __ds_type2> __pair_type; + return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y)); + } +#else + template + inline pair<_T1, _T2> + make_pair(_T1 __x, _T2 __y) + { return pair<_T1, _T2>(__x, __y); } +#endif + + /// @} + +#if __cplusplus >= 201103L + // Various functions which give std::pair a tuple-like interface. + + template + struct __is_tuple_like_impl> : true_type + { }; + + /// Partial specialization for std::pair + template + struct tuple_size> + : public integral_constant { }; + + /// Partial specialization for std::pair + template + struct tuple_element<0, pair<_Tp1, _Tp2>> + { typedef _Tp1 type; }; + + /// Partial specialization for std::pair + template + struct tuple_element<1, pair<_Tp1, _Tp2>> + { typedef _Tp2 type; }; + +#if __cplusplus >= 201703L + template + inline constexpr size_t tuple_size_v> = 2; + + template + inline constexpr size_t tuple_size_v> = 2; + + template + inline constexpr bool __is_pair = false; + + template + inline constexpr bool __is_pair> = true; + + template + inline constexpr bool __is_pair> = true; +#endif + + /// @cond undocumented + template + struct __pair_get; + + template<> + struct __pair_get<0> + { + template + static constexpr _Tp1& + __get(pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr _Tp1&& + __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp1>(__pair.first); } + + template + static constexpr const _Tp1& + __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr const _Tp1&& + __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.first); } + }; + + template<> + struct __pair_get<1> + { + template + static constexpr _Tp2& + __get(pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr _Tp2&& + __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp2>(__pair.second); } + + template + static constexpr const _Tp2& + __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr const _Tp2&& + __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.second); } + }; + /// @endcond + + /** @{ + * std::get overloads for accessing members of std::pair + */ + + template + constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& + get(pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__get(__in); } + + template + constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& + get(pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__move_get(std::move(__in)); } + + template + constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& + get(const pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__const_get(__in); } + + template + constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& + get(const pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__const_move_get(std::move(__in)); } + +#if __cplusplus >= 201402L + +#define __cpp_lib_tuples_by_type 201304L + + template + constexpr _Tp& + get(pair<_Tp, _Up>& __p) noexcept + { return __p.first; } + + template + constexpr const _Tp& + get(const pair<_Tp, _Up>& __p) noexcept + { return __p.first; } + + template + constexpr _Tp&& + get(pair<_Tp, _Up>&& __p) noexcept + { return std::move(__p.first); } + + template + constexpr const _Tp&& + get(const pair<_Tp, _Up>&& __p) noexcept + { return std::move(__p.first); } + + template + constexpr _Tp& + get(pair<_Up, _Tp>& __p) noexcept + { return __p.second; } + + template + constexpr const _Tp& + get(const pair<_Up, _Tp>& __p) noexcept + { return __p.second; } + + template + constexpr _Tp&& + get(pair<_Up, _Tp>&& __p) noexcept + { return std::move(__p.second); } + + template + constexpr const _Tp&& + get(const pair<_Up, _Tp>&& __p) noexcept + { return std::move(__p.second); } + +#endif // C++14 + /// @} +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_PAIR_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9b5e98215b5c180f3af75a82bba401fdac8e43f7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_pair.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h new file mode 100644 index 0000000000000000000000000000000000000000..0824df302f654e182a2bc911cf115883d0c40248 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h @@ -0,0 +1,850 @@ +// Queue implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_queue.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{queue} + */ + +#ifndef _STL_QUEUE_H +#define _STL_QUEUE_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A standard container giving FIFO behavior. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to deque<_Tp>. + * + * Meets many of the requirements of a + * container, + * but does not define anything to do with iterators. Very few of the + * other standard container interfaces are defined. + * + * This is not a true container, but an @e adaptor. It holds another + * container, and provides a wrapper interface to that container. The + * wrapper is what enforces strict first-in-first-out %queue behavior. + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::deque, but it can be any type + * that supports @c front, @c back, @c push_back, and @c pop_front, + * such as std::list or an appropriate user-defined type. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c push and + * @c pop, which are standard %queue/FIFO operations. + */ + template > + class queue + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept) + __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif + + template + friend bool + operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); + + template + friend bool + operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); + +#if __cpp_lib_three_way_comparison + template + friend compare_three_way_result_t<_Seq1> + operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + protected: + /* Maintainers wondering why this isn't uglified as per style + * guidelines should note that this name is specified in the standard, + * C++98 [23.2.3.1]. + * (Why? Presumably for the same reason that it's protected instead + * of private: to allow derivation. But none of the other + * containers allow for derivation. Odd.) + */ + /// @c c is the underlying container. + _Sequence c; + + public: + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + queue(const _Sequence& __c = _Sequence()) + : c(__c) { } +#else + template::value>::type> + queue() + : c() { } + + explicit + queue(const _Sequence& __c) + : c(__c) { } + + explicit + queue(_Sequence&& __c) + : c(std::move(__c)) { } + + template> + explicit + queue(const _Alloc& __a) + : c(__a) { } + + template> + queue(const _Sequence& __c, const _Alloc& __a) + : c(__c, __a) { } + + template> + queue(_Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a) { } + + template> + queue(const queue& __q, const _Alloc& __a) + : c(__q.c, __a) { } + + template> + queue(queue&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a) { } + +#if __cplusplus > 202002L +#define __cpp_lib_adaptor_iterator_pair_constructor 202106L + + template> + queue(_InputIterator __first, _InputIterator __last) + : c(__first, __last) { } + + template, + typename = _Uses<_Alloc>> + queue(_InputIterator __first, _InputIterator __last, const _Alloc& __a) + : c(__first, __last, __a) { } +#endif +#endif + + /** + * Returns true if the %queue is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %queue. */ + _GLIBCXX_NODISCARD + size_type + size() const + { return c.size(); } + + /** + * Returns a read/write reference to the data at the first + * element of the %queue. + */ + _GLIBCXX_NODISCARD + reference + front() + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %queue. + */ + _GLIBCXX_NODISCARD + const_reference + front() const + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %queue. + */ + _GLIBCXX_NODISCARD + reference + back() + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %queue. + */ + _GLIBCXX_NODISCARD + const_reference + back() const + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * @brief Add data to the end of the %queue. + * @param __x Data to be added. + * + * This is a typical %queue operation. The function creates an + * element at the end of the %queue and assigns the given data + * to it. The time complexity of the operation depends on the + * underlying sequence. + */ + void + push(const value_type& __x) + { c.push_back(__x); } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { c.push_back(std::move(__x)); } + +#if __cplusplus > 201402L + template + decltype(auto) + emplace(_Args&&... __args) + { return c.emplace_back(std::forward<_Args>(__args)...); } +#else + template + void + emplace(_Args&&... __args) + { c.emplace_back(std::forward<_Args>(__args)...); } +#endif +#endif + + /** + * @brief Removes first element. + * + * This is a typical %queue operation. It shrinks the %queue by one. + * The time complexity of the operation depends on the underlying + * sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + c.pop_front(); + } + +#if __cplusplus >= 201103L + void + swap(queue& __q) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else + noexcept(__is_nothrow_swappable<_Tp>::value) +#endif + { + using std::swap; + swap(c, __q.c); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template> + queue(_Container) -> queue; + + template> + queue(_Container, _Allocator) + -> queue; + +#ifdef __cpp_lib_adaptor_iterator_pair_constructor + template::value_type, + typename = _RequireInputIter<_InputIterator>> + queue(_InputIterator, _InputIterator) -> queue<_ValT>; + + template::value_type, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + queue(_InputIterator, _InputIterator, _Allocator) + -> queue<_ValT, deque<_ValT, _Allocator>>; +#endif +#endif + + /** + * @brief Queue equality comparison. + * @param __x A %queue. + * @param __y A %queue of the same type as @a __x. + * @return True iff the size and elements of the queues are equal. + * + * This is an equivalence relation. Complexity and semantics depend on the + * underlying sequence type, but the expected rules are: this relation is + * linear in the size of the sequences, and queues are considered equivalent + * if their sequences compare equal. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c == __y.c; } + + /** + * @brief Queue ordering relation. + * @param __x A %queue. + * @param __y A %queue of the same type as @a x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is an total ordering relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, the + * elements must be comparable with @c <, and + * std::lexicographical_compare() is usually used to make the + * determination. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c < __y.c; } + + /// Based on operator== + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __y < __x; } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__x < __y); } + +#if __cpp_lib_three_way_comparison + template + [[nodiscard]] + inline compare_three_way_result_t<_Seq> + operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c <=> __y.c; } +#endif + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif + swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Seq, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + + /** + * @brief A standard container automatically sorting its contents. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to vector<_Tp>. + * @tparam _Compare Comparison function object type, defaults to + * less<_Sequence::value_type>. + * + * This is not a true container, but an @e adaptor. It holds + * another container, and provides a wrapper interface to that + * container. The wrapper is what enforces priority-based sorting + * and %queue behavior. Very few of the standard container/sequence + * interface requirements are met (e.g., iterators). + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::vector, but it can be + * any type that supports @c front(), @c push_back, @c pop_back, + * and random-access iterators, such as std::deque or an + * appropriate user-defined type. + * + * The third template parameter supplies the means of making + * priority comparisons. It defaults to @c less but + * can be anything defining a strict weak ordering. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c + * push, @c pop, and @c top, which are standard %queue operations. + * + * @note No equality/comparison operators are provided for + * %priority_queue. + * + * @note Sorting of the elements takes place as they are added to, + * and removed from, the %priority_queue using the + * %priority_queue's member functions. If you access the elements + * by other means, and change their data such that the sorting + * order would be different, the %priority_queue will not re-sort + * the elements for you. (How could it know to do so?) + */ + template, + typename _Compare = less > + class priority_queue + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires(_Sequence, _SequenceConcept) + __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept) + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) + __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp, + _BinaryFunctionConcept) +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 2684. priority_queue lacking comparator typedef + typedef _Compare value_compare; + + protected: + // See queue::c for notes on these names. + _Sequence c; + _Compare comp; + + public: + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + priority_queue(const _Compare& __x = _Compare(), + const _Sequence& __s = _Sequence()) + : c(__s), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } +#else + template, + is_default_constructible<_Seq>>::value>::type> + priority_queue() + : c(), comp() { } + + explicit + priority_queue(const _Compare& __x, const _Sequence& __s) + : c(__s), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + explicit + priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence()) + : c(std::move(__s)), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + explicit + priority_queue(const _Alloc& __a) + : c(__a), comp() { } + + template> + priority_queue(const _Compare& __x, const _Alloc& __a) + : c(__a), comp(__x) { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2537. Constructors [...] taking allocators should call make_heap + template> + priority_queue(const _Compare& __x, const _Sequence& __c, + const _Alloc& __a) + : c(__c, __a), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + priority_queue(const priority_queue& __q, const _Alloc& __a) + : c(__q.c, __a), comp(__q.comp) { } + + template> + priority_queue(priority_queue&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a), comp(std::move(__q.comp)) { } +#endif + + /** + * @brief Builds a %queue from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __x A comparison functor describing a strict weak ordering. + * @param __s An initial sequence with which to start. + * + * Begins by copying @a __s, inserting a copy of the elements + * from @a [first,last) into the copy of @a __s, then ordering + * the copy according to @a __x. + * + * For more information on function objects, see the + * documentation on @link functors functor base + * classes@endlink. + */ +#if __cplusplus < 201103L + template + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x = _Compare(), + const _Sequence& __s = _Sequence()) + : c(__s), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3529. priority_queue(first, last) should construct c with (first, last) + template> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x = _Compare()) + : c(__first, __last), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3522. Missing requirement on InputIterator template parameter + template> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, const _Sequence& __s) + : c(__s), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + template> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, _Sequence&& __s) + : c(std::move(__s)), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3506. Missing allocator-extended constructors for priority_queue + template, + typename _Requires = _Uses<_Alloc>> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Alloc& __alloc) + : c(__first, __last, __alloc), comp() + { std::make_heap(c.begin(), c.end(), comp); } + + template, + typename _Requires = _Uses<_Alloc>> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, const _Alloc& __alloc) + : c(__first, __last, __alloc), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template, + typename _Requires = _Uses<_Alloc>> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, const _Sequence& __s, + const _Alloc& __alloc) + : c(__s, __alloc), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + template> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, _Sequence&& __s, + const _Alloc& __alloc) + : c(std::move(__s), __alloc), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } +#endif + + /** + * Returns true if the %queue is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %queue. */ + _GLIBCXX_NODISCARD + size_type + size() const + { return c.size(); } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %queue. + */ + _GLIBCXX_NODISCARD + const_reference + top() const + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * @brief Add data to the %queue. + * @param __x Data to be added. + * + * This is a typical %queue operation. + * The time complexity of the operation depends on the underlying + * sequence. + */ + void + push(const value_type& __x) + { + c.push_back(__x); + std::push_heap(c.begin(), c.end(), comp); + } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { + c.push_back(std::move(__x)); + std::push_heap(c.begin(), c.end(), comp); + } + + template + void + emplace(_Args&&... __args) + { + c.emplace_back(std::forward<_Args>(__args)...); + std::push_heap(c.begin(), c.end(), comp); + } +#endif + + /** + * @brief Removes first element. + * + * This is a typical %queue operation. It shrinks the %queue + * by one. The time complexity of the operation depends on the + * underlying sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + std::pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } + +#if __cplusplus >= 201103L + void + swap(priority_queue& __pq) + noexcept(__and_< +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + __is_nothrow_swappable<_Sequence>, +#else + __is_nothrow_swappable<_Tp>, +#endif + __is_nothrow_swappable<_Compare> + >::value) + { + using std::swap; + swap(c, __pq.c); + swap(comp, __pq.comp); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template, + typename = _RequireNotAllocator<_Container>> + priority_queue(_Compare, _Container) + -> priority_queue; + + template::value_type, + typename _Compare = less<_ValT>, + typename _Container = vector<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireNotAllocator<_Container>> + priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), + _Container = _Container()) + -> priority_queue<_ValT, _Container, _Compare>; + + template, + typename = _RequireNotAllocator<_Container>> + priority_queue(_Compare, _Container, _Allocator) + -> priority_queue; +#endif + + // No equality/comparison operators are provided for priority_queue. + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_Sequence>, + __is_swappable<_Compare>>::value>::type +#else + void +#endif + swap(priority_queue<_Tp, _Sequence, _Compare>& __x, + priority_queue<_Tp, _Sequence, _Compare>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Sequence, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_QUEUE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..b97e03c943769d59539d40f7eabe0a788bc0aef7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_queue.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h new file mode 100644 index 0000000000000000000000000000000000000000..063c01c676d3a5978f5a6970b97aa9ca25f6b8a7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h @@ -0,0 +1,128 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_raw_storage_iter.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_RAW_STORAGE_ITERATOR_H +#define _STL_RAW_STORAGE_ITERATOR_H 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +// Ignore warnings about std::iterator. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /** + * This iterator class lets algorithms store their results into + * uninitialized memory. + */ + template + class _GLIBCXX17_DEPRECATED raw_storage_iterator + : public iterator + { + protected: + _OutputIterator _M_iter; + + public: + explicit + raw_storage_iterator(_OutputIterator __x) + : _M_iter(__x) {} + + raw_storage_iterator& + operator*() { return *this; } + + raw_storage_iterator& + operator=(const _Tp& __element) + { + std::_Construct(std::__addressof(*_M_iter), __element); + return *this; + } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2127. Move-construction with raw_storage_iterator + raw_storage_iterator& + operator=(_Tp&& __element) + { + std::_Construct(std::__addressof(*_M_iter), std::move(__element)); + return *this; + } +#endif + + raw_storage_iterator& + operator++() + { + ++_M_iter; + return *this; + } + + raw_storage_iterator + operator++(int) + { + raw_storage_iterator __tmp = *this; + ++_M_iter; + return __tmp; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2454. Add raw_storage_iterator::base() member + _OutputIterator base() const { return _M_iter; } + }; +#pragma GCC diagnostic pop + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..880995695cb92d612552985e8846338101161b6b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_raw_storage_iter.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h new file mode 100644 index 0000000000000000000000000000000000000000..475e93781bf3ae6150e99cb1dfd62d75b9dbe2c9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h @@ -0,0 +1,134 @@ +// std::rel_ops implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the, 2009 Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1996,1997 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file bits/stl_relops.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + * + * This file is only included by ``, which is required by the + * standard to define namespace `rel_ops` and its contents. + */ + +#ifndef _STL_RELOPS_H +#define _STL_RELOPS_H 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace rel_ops + { + /** @namespace std::rel_ops + * @brief The generated relational operators are sequestered here. + * + * Libstdc++ headers must not use the contents of `rel_ops`. + * User code should also avoid them, because unconstrained function + * templates are too greedy and can easily cause ambiguities. + * + * C++20 default comparisons are a better solution. + */ + + /** + * @brief Defines @c != for arbitrary types, in terms of @c ==. + * @param __x A thing. + * @param __y Another thing. + * @return __x != __y + * + * This function uses @c == to determine its result. + */ + template + inline bool + operator!=(const _Tp& __x, const _Tp& __y) + { return !(__x == __y); } + + /** + * @brief Defines @c > for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x > __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator>(const _Tp& __x, const _Tp& __y) + { return __y < __x; } + + /** + * @brief Defines @c <= for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x <= __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator<=(const _Tp& __x, const _Tp& __y) + { return !(__y < __x); } + + /** + * @brief Defines @c >= for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x >= __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator>=(const _Tp& __x, const _Tp& __y) + { return !(__x < __y); } + } // namespace rel_ops + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_RELOPS_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5129e638c98b370cc68dc8e23be0fc0369937e90 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_relops.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h new file mode 100644 index 0000000000000000000000000000000000000000..b6c9746f48160361b079d61da2c00a30dcf5fed0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h @@ -0,0 +1,1086 @@ +// Set implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_set.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{set} + */ + +#ifndef _STL_SET_H +#define _STL_SET_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class multiset; + + /** + * @brief A standard container made up of unique keys, which can be + * retrieved in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using unique keys). + * + * Sets support bidirectional iterators. + * + * The private tree data is declared exactly the same way for set and + * multiset; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template, + typename _Alloc = std::allocator<_Key> > + class set + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Key>::value, + "std::set must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::set must have the same value_type as its allocator"); +# endif +#endif + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Alloc allocator_type; + ///@} + + private: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; + _Rep_type _M_t; // Red-black tree representing set. + + typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits; + + public: + ///@{ + /// Iterator-related typedefs. + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 103. set::iterator is required to be modifiable, + // but this allows modification of keys. + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; + using insert_return_type = typename _Rep_type::insert_return_type; +#endif + + // allocation/deallocation + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + set() : _M_t() { } +#else + set() = default; +#endif + + /** + * @brief Creates a %set with no elements. + * @param __comp Comparator to use. + * @param __a An allocator object. + */ + explicit + set(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) { } + + /** + * @brief Builds a %set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %set consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + set(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief Builds a %set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %set consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + set(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief %Set copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + set(const set& __x) + : _M_t(__x._M_t) { } +#else + set(const set&) = default; + + /** + * @brief %Set move constructor + * + * The newly-created %set contains the exact contents of the moved + * instance. The moved instance is a valid, but unspecified, %set. + */ + set(set&&) = default; + + /** + * @brief Builds a %set from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %set consisting of copies of the elements in the list. + * This is linear in N if the list is already sorted, and NlogN + * otherwise (where N is @a __l.size()). + */ + set(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + set(const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + set(const set& __x, const __type_identity_t& __a) + : _M_t(__x._M_t, _Key_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + set(set&& __x, const __type_identity_t& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + set(initializer_list __l, const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + set(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~set() = default; +#endif + + /** + * @brief %Set assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + set& + operator=(const set& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + set& + operator=(const set&) = default; + + /// Move assignment operator. + set& + operator=(set&&) = default; + + /** + * @brief %Set list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %set with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %set and + * that the resulting %set's size is the same as the number + * of elements assigned. + */ + set& + operator=(initializer_list __l) + { + _M_t._M_assign_unique(__l.begin(), __l.end()); + return *this; + } +#endif + + // accessors: + + /// Returns the comparison object with which the %set was constructed. + key_compare + key_comp() const + { return _M_t.key_comp(); } + /// Returns the comparison object with which the %set was constructed. + value_compare + value_comp() const + { return _M_t.key_comp(); } + /// Returns the allocator object with which the %set was constructed. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points to the last + * element in the %set. Iteration is done in descending order according + * to the keys. + */ + reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %set. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points to the last + * element in the %set. Iteration is done in descending order according + * to the keys. + */ + reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %set. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + /// Returns true if the %set is empty. + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /// Returns the size of the %set. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /// Returns the maximum size of the %set. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + /** + * @brief Swaps data with another %set. + * @param __x A %set of the same element and allocator types. + * + * This exchanges the elements between two sets in constant + * time. (It is only swapping a pointer, an integer, and an + * instance of the @c Compare type (which itself is often + * stateless and empty), so it should be quite fast.) Note + * that the global std::swap() function is specialized such + * that std::swap(s1,s2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(set& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + // insert/erase +#if __cplusplus >= 201103L + /** + * @brief Attempts to build and insert an element into the %set. + * @param __args Arguments used to generate an element. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to build and insert an element into the %set. + * A %set relies on unique keys and thus an element is only inserted if + * it is not already present in the %set. + * + * Insertion requires logarithmic time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to insert an element into the %set. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the element with key equivalent to + * the one generated from @a __args (may or may not be the + * element itself). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_unique(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Attempts to insert an element into the %set. + * @param __x Element to be inserted. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to insert an element into the %set. A %set + * relies on unique keys and thus an element is only inserted if it is + * not already present in the %set. + * + * Insertion requires logarithmic time. + */ + std::pair + insert(const value_type& __x) + { + std::pair __p = + _M_t._M_insert_unique(__x); + return std::pair(__p.first, __p.second); + } + +#if __cplusplus >= 201103L + std::pair + insert(value_type&& __x) + { + std::pair __p = + _M_t._M_insert_unique(std::move(__x)); + return std::pair(__p.first, __p.second); + } +#endif + + /** + * @brief Attempts to insert an element into the %set. + * @param __position An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the element passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + iterator + insert(const_iterator __position, const value_type& __x) + { return _M_t._M_insert_unique_(__position, __x); } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_unique_(__position, std::move(__x)); } +#endif + + /** + * @brief A template function that attempts to insert a range + * of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of elements into the %set. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_unique(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(set<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(set<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %set. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %set. Note that this function only erases the element, and + * that if the element is itself a pointer, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } +#else + /** + * @brief Erases an element from a %set. + * @param position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %set. Note that this function only erases the element, and + * that if the element is itself a pointer, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [__first,__last) range of elements from a %set. + * @param __first Iterator pointing to the start of the range to be + * erased. + + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [first,last) range of elements from a %set. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * Erases all elements in a %set. Note that this function only erases + * the elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // set operations: + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + * + * This function only makes sense for multisets; for set the result will + * either be 0 (not present) or 1 (present). + */ + size_type + count(const key_type& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const + -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is an element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + ///@{ + /** + * @brief Tries to locate an element in a %set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } + + template + auto + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } + + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } + + template + auto + upper_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } + + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + template + friend bool + operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t<_K1> + operator<=>(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); +#else + template + friend bool + operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, _Allocator) + -> set::value_type, + less::value_type>, + _Allocator>; + + template> + set(initializer_list<_Key>, _Allocator) + -> set<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Set equality comparison. + * @param __x A %set. + * @param __y A %set of the same type as @a x. + * @return True iff the size and elements of the sets are equal. + * + * This is an equivalence relation. It is linear in the size of the sets. + * Sets are considered equivalent if their sizes are equal, and if + * corresponding elements compare equal. + */ + template + inline bool + operator==(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Set ordering relation. + * @param __x A `set`. + * @param __y A `set` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Key> + operator<=>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Set ordering relation. + * @param __x A %set. + * @param __y A %set of the same type as @a x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * sets. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Returns !(x == y). + template + inline bool + operator!=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Returns y < x. + template + inline bool + operator>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Returns !(y < x) + template + inline bool + operator<=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Returns !(x < y) + template + inline bool + operator>=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::set::swap(). + template + inline void + swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::set access to internals of compatible sets. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} //namespace std +#endif /* _STL_SET_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..24464eec1469d41113c076d98039087491d78a10 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_set.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h new file mode 100644 index 0000000000000000000000000000000000000000..83416f438bbea0a5c1e1f6c4941fd7eea6c5aed7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h @@ -0,0 +1,435 @@ +// Stack implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_stack.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{stack} + */ + +#ifndef _STL_STACK_H +#define _STL_STACK_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A standard container giving FILO behavior. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to deque<_Tp>. + * + * Meets many of the requirements of a + * container, + * but does not define anything to do with iterators. Very few of the + * other standard container interfaces are defined. + * + * This is not a true container, but an @e adaptor. It holds + * another container, and provides a wrapper interface to that + * container. The wrapper is what enforces strict + * first-in-last-out %stack behavior. + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::deque, but it can be + * any type that supports @c back, @c push_back, and @c pop_back, + * such as std::list, std::vector, or an appropriate user-defined + * type. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c + * push, @c pop, and @c top, which are standard %stack/FILO + * operations. + */ + template > + class stack + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) +# endif + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif + + template + friend bool + operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); + + template + friend bool + operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); + +#if __cpp_lib_three_way_comparison + template + friend compare_three_way_result_t<_Seq1> + operator<=>(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + protected: + // See queue::c for notes on this name. + _Sequence c; + + public: + // XXX removed old def ctor, added def arg to this one to match 14882 + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + stack(const _Sequence& __c = _Sequence()) + : c(__c) { } +#else + template::value>::type> + stack() + : c() { } + + explicit + stack(const _Sequence& __c) + : c(__c) { } + + explicit + stack(_Sequence&& __c) + : c(std::move(__c)) { } + +#if __cplusplus > 202002L +#define __cpp_lib_adaptor_iterator_pair_constructor 202106L + + template> + stack(_InputIterator __first, _InputIterator __last) + : c(__first, __last) { } +#endif + + + template> + explicit + stack(const _Alloc& __a) + : c(__a) { } + + template> + stack(const _Sequence& __c, const _Alloc& __a) + : c(__c, __a) { } + + template> + stack(_Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a) { } + + template> + stack(const stack& __q, const _Alloc& __a) + : c(__q.c, __a) { } + + template> + stack(stack&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a) { } + +#if __cplusplus > 202002L + template, + typename = _Uses<_Alloc>> + stack(_InputIterator __first, _InputIterator __last, const _Alloc& __a) + : c(__first, __last, __a) { } +#endif +#endif + + /** + * Returns true if the %stack is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %stack. */ + _GLIBCXX_NODISCARD + size_type + size() const + { return c.size(); } + + /** + * Returns a read/write reference to the data at the first + * element of the %stack. + */ + _GLIBCXX_NODISCARD + reference + top() + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %stack. + */ + _GLIBCXX_NODISCARD + const_reference + top() const + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * @brief Add data to the top of the %stack. + * @param __x Data to be added. + * + * This is a typical %stack operation. The function creates an + * element at the top of the %stack and assigns the given data + * to it. The time complexity of the operation depends on the + * underlying sequence. + */ + void + push(const value_type& __x) + { c.push_back(__x); } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { c.push_back(std::move(__x)); } + +#if __cplusplus > 201402L + template + decltype(auto) + emplace(_Args&&... __args) + { return c.emplace_back(std::forward<_Args>(__args)...); } +#else + template + void + emplace(_Args&&... __args) + { c.emplace_back(std::forward<_Args>(__args)...); } +#endif +#endif + + /** + * @brief Removes first element. + * + * This is a typical %stack operation. It shrinks the %stack + * by one. The time complexity of the operation depends on the + * underlying sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + c.pop_back(); + } + +#if __cplusplus >= 201103L + void + swap(stack& __s) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else + noexcept(__is_nothrow_swappable<_Tp>::value) +#endif + { + using std::swap; + swap(c, __s.c); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template> + stack(_Container) -> stack; + + template> + stack(_Container, _Allocator) + -> stack; + +#ifdef __cpp_lib_adaptor_iterator_pair_constructor + template::value_type, + typename = _RequireInputIter<_InputIterator>> + stack(_InputIterator, _InputIterator) -> stack<_ValT>; + + template::value_type, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + stack(_InputIterator, _InputIterator, _Allocator) + -> stack<_ValT, deque<_ValT, _Allocator>>; +#endif +#endif + + /** + * @brief Stack equality comparison. + * @param __x A %stack. + * @param __y A %stack of the same type as @a __x. + * @return True iff the size and elements of the stacks are equal. + * + * This is an equivalence relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, and + * stacks are considered equivalent if their sequences compare + * equal. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c == __y.c; } + + /** + * @brief Stack ordering relation. + * @param __x A %stack. + * @param __y A %stack of the same type as @a x. + * @return True iff @a x is lexicographically less than @a __y. + * + * This is an total ordering relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, the + * elements must be comparable with @c <, and + * std::lexicographical_compare() is usually used to make the + * determination. + */ + template + _GLIBCXX_NODISCARD + inline bool + operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c < __y.c; } + + /// Based on operator== + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __y < __x; } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + _GLIBCXX_NODISCARD + inline bool + operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__x < __y); } + +#if __cpp_lib_three_way_comparison + template + [[nodiscard]] + inline compare_three_way_result_t<_Seq> + operator<=>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c <=> __y.c; } +#endif + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif + swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Seq, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_STACK_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..87072723734574d0ebfdafbf98374c57810ac70b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_stack.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h new file mode 100644 index 0000000000000000000000000000000000000000..db7cdb14ca97b2e3dd0c1196c3b9a802d36096e3 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h @@ -0,0 +1,285 @@ +// Temporary buffer implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_tempbuf.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_TEMPBUF_H +#define _STL_TEMPBUF_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail + { + template + inline void + __return_temporary_buffer(_Tp* __p, + size_t __len __attribute__((__unused__))) + { +#if __cpp_sized_deallocation + ::operator delete(__p, __len * sizeof(_Tp)); +#else + ::operator delete(__p); +#endif + } + } + + /** + * @brief Allocates a temporary buffer. + * @param __len The number of objects of type Tp. + * @return See full description. + * + * Reinventing the wheel, but this time with prettier spokes! + * + * This function tries to obtain storage for @c __len adjacent Tp + * objects. The objects themselves are not constructed, of course. + * A pair<> is returned containing the buffer s address and + * capacity (in the units of sizeof(_Tp)), or a pair of 0 values if + * no storage can be obtained. Note that the capacity obtained + * may be less than that requested if the memory is unavailable; + * you should compare len with the .second return value. + * + * Provides the nothrow exception guarantee. + */ + template + _GLIBCXX17_DEPRECATED + pair<_Tp*, ptrdiff_t> + get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOEXCEPT + { + const ptrdiff_t __max = + __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + if (__len > __max) + __len = __max; + + while (__len > 0) + { + _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), + std::nothrow)); + if (__tmp != 0) + return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len = __len == 1 ? 0 : ((__len + 1) / 2); + } + return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); + } + + /** + * @brief The companion to get_temporary_buffer(). + * @param __p A buffer previously allocated by get_temporary_buffer. + * @return None. + * + * Frees the memory pointed to by __p. + */ + template + inline void + return_temporary_buffer(_Tp* __p) + { ::operator delete(__p); } + + /** + * This class is used in two places: stl_algo.h and ext/memory, + * where it is wrapped as the temporary_buffer class. See + * temporary_buffer docs for more notes. + */ + template + class _Temporary_buffer + { + // concept requirements + __glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept) + + public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef pointer iterator; + typedef ptrdiff_t size_type; + + protected: + size_type _M_original_len; + size_type _M_len; + pointer _M_buffer; + + public: + /// As per Table mumble. + size_type + size() const + { return _M_len; } + + /// Returns the size requested by the constructor; may be >size(). + size_type + requested_size() const + { return _M_original_len; } + + /// As per Table mumble. + iterator + begin() + { return _M_buffer; } + + /// As per Table mumble. + iterator + end() + { return _M_buffer + _M_len; } + + /** + * Constructs a temporary buffer of a size somewhere between + * zero and the given length. + */ + _Temporary_buffer(_ForwardIterator __seed, size_type __original_len); + + ~_Temporary_buffer() + { + std::_Destroy(_M_buffer, _M_buffer + _M_len); + std::__detail::__return_temporary_buffer(_M_buffer, _M_len); + } + + private: + // Disable copy constructor and assignment operator. + _Temporary_buffer(const _Temporary_buffer&); + + void + operator=(const _Temporary_buffer&); + }; + + + template + struct __uninitialized_construct_buf_dispatch + { + template + static void + __ucr(_Pointer __first, _Pointer __last, + _ForwardIterator __seed) + { + if (__first == __last) + return; + + _Pointer __cur = __first; + __try + { + std::_Construct(std::__addressof(*__first), + _GLIBCXX_MOVE(*__seed)); + _Pointer __prev = __cur; + ++__cur; + for(; __cur != __last; ++__cur, ++__prev) + std::_Construct(std::__addressof(*__cur), + _GLIBCXX_MOVE(*__prev)); + *__seed = _GLIBCXX_MOVE(*__prev); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_construct_buf_dispatch + { + template + static void + __ucr(_Pointer, _Pointer, _ForwardIterator) { } + }; + + // Constructs objects in the range [first, last). + // Note that while these new objects will take valid values, + // their exact value is not defined. In particular they may + // be 'moved from'. + // + // While *__seed may be altered during this algorithm, it will have + // the same value when the algorithm finishes, unless one of the + // constructions throws. + // + // Requirements: _Pointer::value_type(_Tp&&) is valid. + template + inline void + __uninitialized_construct_buf(_Pointer __first, _Pointer __last, + _ForwardIterator __seed) + { + typedef typename std::iterator_traits<_Pointer>::value_type + _ValueType; + + std::__uninitialized_construct_buf_dispatch< + __has_trivial_constructor(_ValueType)>:: + __ucr(__first, __last, __seed); + } + + template + _Temporary_buffer<_ForwardIterator, _Tp>:: + _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) + : _M_original_len(__original_len), _M_len(0), _M_buffer(0) + { + std::pair __p( + std::get_temporary_buffer(_M_original_len)); + + if (__p.first) + { + __try + { + std::__uninitialized_construct_buf(__p.first, __p.first + __p.second, + __seed); + _M_buffer = __p.first; + _M_len = __p.second; + } + __catch(...) + { + std::__detail::__return_temporary_buffer(__p.first, __p.second); + __throw_exception_again; + } + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_TEMPBUF_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e6ec0c72060482035d3c320416a756703344f85f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tempbuf.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h new file mode 100644 index 0000000000000000000000000000000000000000..a4de61417652a288e361a55fcc8bb7a9838c58a5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h @@ -0,0 +1,2622 @@ +// RB tree implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + */ + +/** @file bits/stl_tree.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map,set} + */ + +#ifndef _STL_TREE_H +#define _STL_TREE_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#if __cplusplus >= 201103L +# include +#endif +#if __cplusplus > 201402L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus > 201103L +# define __cpp_lib_generic_associative_lookup 201304L +#endif + + // Red-black tree class, designed for use in implementing STL + // associative containers (set, multiset, map, and multimap). The + // insertion and deletion algorithms are based on those in Cormen, + // Leiserson, and Rivest, Introduction to Algorithms (MIT Press, + // 1990), except that + // + // (1) the header cell is maintained with links not only to the root + // but also to the leftmost node of the tree, to enable constant + // time begin(), and to the rightmost node of the tree, to enable + // linear time performance when used with the generic set algorithms + // (set_union, etc.) + // + // (2) when a node being deleted has two children its successor node + // is relinked into its place, rather than copied, so that the only + // iterators invalidated are those referring to the deleted node. + + enum _Rb_tree_color { _S_red = false, _S_black = true }; + + struct _Rb_tree_node_base + { + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + + _Rb_tree_color _M_color; + _Base_ptr _M_parent; + _Base_ptr _M_left; + _Base_ptr _M_right; + + static _Base_ptr + _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Const_Base_ptr + _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Base_ptr + _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } + + static _Const_Base_ptr + _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } + }; + + // Helper type offering value initialization guarantee on the compare functor. + template + struct _Rb_tree_key_compare + { + _Key_compare _M_key_compare; + + _Rb_tree_key_compare() + _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Key_compare>::value) + : _M_key_compare() + { } + + _Rb_tree_key_compare(const _Key_compare& __comp) + : _M_key_compare(__comp) + { } + +#if __cplusplus >= 201103L + // Copy constructor added for consistency with C++98 mode. + _Rb_tree_key_compare(const _Rb_tree_key_compare&) = default; + + _Rb_tree_key_compare(_Rb_tree_key_compare&& __x) + noexcept(is_nothrow_copy_constructible<_Key_compare>::value) + : _M_key_compare(__x._M_key_compare) + { } +#endif + }; + + // Helper type to manage default initialization of node count and header. + struct _Rb_tree_header + { + _Rb_tree_node_base _M_header; + size_t _M_node_count; // Keeps track of size of tree. + + _Rb_tree_header() _GLIBCXX_NOEXCEPT + { + _M_header._M_color = _S_red; + _M_reset(); + } + +#if __cplusplus >= 201103L + _Rb_tree_header(_Rb_tree_header&& __x) noexcept + { + if (__x._M_header._M_parent != nullptr) + _M_move_data(__x); + else + { + _M_header._M_color = _S_red; + _M_reset(); + } + } +#endif + + void + _M_move_data(_Rb_tree_header& __from) + { + _M_header._M_color = __from._M_header._M_color; + _M_header._M_parent = __from._M_header._M_parent; + _M_header._M_left = __from._M_header._M_left; + _M_header._M_right = __from._M_header._M_right; + _M_header._M_parent->_M_parent = &_M_header; + _M_node_count = __from._M_node_count; + + __from._M_reset(); + } + + void + _M_reset() + { + _M_header._M_parent = 0; + _M_header._M_left = &_M_header; + _M_header._M_right = &_M_header; + _M_node_count = 0; + } + }; + + template + struct _Rb_tree_node : public _Rb_tree_node_base + { + typedef _Rb_tree_node<_Val>* _Link_type; + +#if __cplusplus < 201103L + _Val _M_value_field; + + _Val* + _M_valptr() + { return std::__addressof(_M_value_field); } + + const _Val* + _M_valptr() const + { return std::__addressof(_M_value_field); } +#else + __gnu_cxx::__aligned_membuf<_Val> _M_storage; + + _Val* + _M_valptr() + { return _M_storage._M_ptr(); } + + const _Val* + _M_valptr() const + { return _M_storage._M_ptr(); } +#endif + }; + + _GLIBCXX_PURE _Rb_tree_node_base* + _Rb_tree_increment(_Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE const _Rb_tree_node_base* + _Rb_tree_increment(const _Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE _Rb_tree_node_base* + _Rb_tree_decrement(_Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE const _Rb_tree_node_base* + _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw (); + + template + struct _Rb_tree_iterator + { + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + + typedef _Rb_tree_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; + typedef _Rb_tree_node<_Tp>* _Link_type; + + _Rb_tree_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type> (_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_increment(_M_node); + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_increment(_M_node); + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_decrement(_M_node); + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_decrement(_M_node); + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if ! __cpp_lib_three_way_comparison + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + _Base_ptr _M_node; + }; + + template + struct _Rb_tree_const_iterator + { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + + typedef _Rb_tree_iterator<_Tp> iterator; + + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + + typedef _Rb_tree_const_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; + typedef const _Rb_tree_node<_Tp>* _Link_type; + + _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT + : _M_node(__it._M_node) { } + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(const_cast(_M_node)); } + + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_increment(_M_node); + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_increment(_M_node); + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_decrement(_M_node); + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_decrement(_M_node); + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if ! __cpp_lib_three_way_comparison + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + _Base_ptr _M_node; + }; + + void + _Rb_tree_insert_and_rebalance(const bool __insert_left, + _Rb_tree_node_base* __x, + _Rb_tree_node_base* __p, + _Rb_tree_node_base& __header) throw (); + + _Rb_tree_node_base* + _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z, + _Rb_tree_node_base& __header) throw (); + +#if __cplusplus > 201402L + template + struct _Rb_tree_merge_helper { }; +#endif + + template > + class _Rb_tree + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Rb_tree_node<_Val> >::other _Node_allocator; + + typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits; + + protected: + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + typedef _Rb_tree_node<_Val>* _Link_type; + typedef const _Rb_tree_node<_Val>* _Const_Link_type; + + private: + // Functor recycling a pool of nodes and using allocation once the pool + // is empty. + struct _Reuse_or_alloc_node + { + _Reuse_or_alloc_node(_Rb_tree& __t) + : _M_root(__t._M_root()), _M_nodes(__t._M_rightmost()), _M_t(__t) + { + if (_M_root) + { + _M_root->_M_parent = 0; + + if (_M_nodes->_M_left) + _M_nodes = _M_nodes->_M_left; + } + else + _M_nodes = 0; + } + +#if __cplusplus >= 201103L + _Reuse_or_alloc_node(const _Reuse_or_alloc_node&) = delete; +#endif + + ~_Reuse_or_alloc_node() + { _M_t._M_erase(static_cast<_Link_type>(_M_root)); } + + template + _Link_type + operator()(_GLIBCXX_FWDREF(_Arg) __arg) + { + _Link_type __node = static_cast<_Link_type>(_M_extract()); + if (__node) + { + _M_t._M_destroy_node(__node); + _M_t._M_construct_node(__node, _GLIBCXX_FORWARD(_Arg, __arg)); + return __node; + } + + return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); + } + + private: + _Base_ptr + _M_extract() + { + if (!_M_nodes) + return _M_nodes; + + _Base_ptr __node = _M_nodes; + _M_nodes = _M_nodes->_M_parent; + if (_M_nodes) + { + if (_M_nodes->_M_right == __node) + { + _M_nodes->_M_right = 0; + + if (_M_nodes->_M_left) + { + _M_nodes = _M_nodes->_M_left; + + while (_M_nodes->_M_right) + _M_nodes = _M_nodes->_M_right; + + if (_M_nodes->_M_left) + _M_nodes = _M_nodes->_M_left; + } + } + else // __node is on the left. + _M_nodes->_M_left = 0; + } + else + _M_root = 0; + + return __node; + } + + _Base_ptr _M_root; + _Base_ptr _M_nodes; + _Rb_tree& _M_t; + }; + + // Functor similar to the previous one but without any pool of nodes to + // recycle. + struct _Alloc_node + { + _Alloc_node(_Rb_tree& __t) + : _M_t(__t) { } + + template + _Link_type + operator()(_GLIBCXX_FWDREF(_Arg) __arg) const + { return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); } + + private: + _Rb_tree& _M_t; + }; + + public: + typedef _Key key_type; + typedef _Val value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + _Node_allocator& + _M_get_Node_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Node_allocator& + _M_get_Node_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Node_allocator()); } + + protected: + _Link_type + _M_get_node() + { return _Alloc_traits::allocate(_M_get_Node_allocator(), 1); } + + void + _M_put_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); } + +#if __cplusplus < 201103L + void + _M_construct_node(_Link_type __node, const value_type& __x) + { + __try + { get_allocator().construct(__node->_M_valptr(), __x); } + __catch(...) + { + _M_put_node(__node); + __throw_exception_again; + } + } + + _Link_type + _M_create_node(const value_type& __x) + { + _Link_type __tmp = _M_get_node(); + _M_construct_node(__tmp, __x); + return __tmp; + } +#else + template + void + _M_construct_node(_Link_type __node, _Args&&... __args) + { + __try + { + ::new(__node) _Rb_tree_node<_Val>; + _Alloc_traits::construct(_M_get_Node_allocator(), + __node->_M_valptr(), + std::forward<_Args>(__args)...); + } + __catch(...) + { + __node->~_Rb_tree_node<_Val>(); + _M_put_node(__node); + __throw_exception_again; + } + } + + template + _Link_type + _M_create_node(_Args&&... __args) + { + _Link_type __tmp = _M_get_node(); + _M_construct_node(__tmp, std::forward<_Args>(__args)...); + return __tmp; + } +#endif + + void + _M_destroy_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { +#if __cplusplus < 201103L + get_allocator().destroy(__p->_M_valptr()); +#else + _Alloc_traits::destroy(_M_get_Node_allocator(), __p->_M_valptr()); + __p->~_Rb_tree_node<_Val>(); +#endif + } + + void + _M_drop_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { + _M_destroy_node(__p); + _M_put_node(__p); + } + + template + _Link_type + _M_clone_node(_Link_type __x, _NodeGen& __node_gen) + { +#if __cplusplus >= 201103L + using _Vp = __conditional_t<_MoveValue, + value_type&&, + const value_type&>; +#endif + _Link_type __tmp + = __node_gen(_GLIBCXX_FORWARD(_Vp, *__x->_M_valptr())); + __tmp->_M_color = __x->_M_color; + __tmp->_M_left = 0; + __tmp->_M_right = 0; + return __tmp; + } + + protected: +#if _GLIBCXX_INLINE_VERSION + template +#else + // Unused _Is_pod_comparator is kept as it is part of mangled name. + template +#endif + struct _Rb_tree_impl + : public _Node_allocator + , public _Rb_tree_key_compare<_Key_compare> + , public _Rb_tree_header + { + typedef _Rb_tree_key_compare<_Key_compare> _Base_key_compare; + + _Rb_tree_impl() + _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Node_allocator>::value + && is_nothrow_default_constructible<_Base_key_compare>::value ) + : _Node_allocator() + { } + + _Rb_tree_impl(const _Rb_tree_impl& __x) + : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x)) + , _Base_key_compare(__x._M_key_compare) + , _Rb_tree_header() + { } + +#if __cplusplus < 201103L + _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a) + : _Node_allocator(__a), _Base_key_compare(__comp) + { } +#else + _Rb_tree_impl(_Rb_tree_impl&&) + noexcept( is_nothrow_move_constructible<_Base_key_compare>::value ) + = default; + + explicit + _Rb_tree_impl(_Node_allocator&& __a) + : _Node_allocator(std::move(__a)) + { } + + _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a) + : _Node_allocator(std::move(__a)), + _Base_key_compare(std::move(__x)), + _Rb_tree_header(std::move(__x)) + { } + + _Rb_tree_impl(const _Key_compare& __comp, _Node_allocator&& __a) + : _Node_allocator(std::move(__a)), _Base_key_compare(__comp) + { } +#endif + }; + + _Rb_tree_impl<_Compare> _M_impl; + + protected: + _Base_ptr& + _M_root() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_parent; } + + _Const_Base_ptr + _M_root() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_parent; } + + _Base_ptr& + _M_leftmost() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_left; } + + _Const_Base_ptr + _M_leftmost() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_left; } + + _Base_ptr& + _M_rightmost() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_right; } + + _Const_Base_ptr + _M_rightmost() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_right; } + + _Link_type + _M_mbegin() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); } + + _Link_type + _M_begin() _GLIBCXX_NOEXCEPT + { return _M_mbegin(); } + + _Const_Link_type + _M_begin() const _GLIBCXX_NOEXCEPT + { + return static_cast<_Const_Link_type> + (this->_M_impl._M_header._M_parent); + } + + _Base_ptr + _M_end() _GLIBCXX_NOEXCEPT + { return &this->_M_impl._M_header; } + + _Const_Base_ptr + _M_end() const _GLIBCXX_NOEXCEPT + { return &this->_M_impl._M_header; } + + static const _Key& + _S_key(_Const_Link_type __x) + { +#if __cplusplus >= 201103L + // If we're asking for the key we're presumably using the comparison + // object, and so this is a good place to sanity check it. + static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, + "comparison object must be invocable " + "with two arguments of key type"); +# if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2542. Missing const requirements for associative containers + if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{}) + static_assert( + is_invocable_v, + "comparison object must be invocable as const"); +# endif // C++17 +#endif // C++11 + + return _KeyOfValue()(*__x->_M_valptr()); + } + + static _Link_type + _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(__x->_M_left); } + + static _Const_Link_type + _S_left(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Const_Link_type>(__x->_M_left); } + + static _Link_type + _S_right(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(__x->_M_right); } + + static _Const_Link_type + _S_right(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Const_Link_type>(__x->_M_right); } + + static const _Key& + _S_key(_Const_Base_ptr __x) + { return _S_key(static_cast<_Const_Link_type>(__x)); } + + static _Base_ptr + _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Const_Base_ptr + _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Base_ptr + _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_maximum(__x); } + + static _Const_Base_ptr + _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_maximum(__x); } + + public: + typedef _Rb_tree_iterator iterator; + typedef _Rb_tree_const_iterator const_iterator; + + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = _Node_handle<_Key, _Val, _Node_allocator>; + using insert_return_type = _Node_insert_return< + __conditional_t, const_iterator, iterator>, + node_type>; +#endif + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_unique_pos(const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_equal_pos(const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_hint_unique_pos(const_iterator __pos, + const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_hint_equal_pos(const_iterator __pos, + const key_type& __k); + + private: +#if __cplusplus >= 201103L + template + iterator + _M_insert_(_Base_ptr __x, _Base_ptr __y, _Arg&& __v, _NodeGen&); + + iterator + _M_insert_node(_Base_ptr __x, _Base_ptr __y, _Link_type __z); + + template + iterator + _M_insert_lower(_Base_ptr __y, _Arg&& __v); + + template + iterator + _M_insert_equal_lower(_Arg&& __x); + + iterator + _M_insert_lower_node(_Base_ptr __p, _Link_type __z); + + iterator + _M_insert_equal_lower_node(_Link_type __z); +#else + template + iterator + _M_insert_(_Base_ptr __x, _Base_ptr __y, + const value_type& __v, _NodeGen&); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 233. Insertion hints in associative containers. + iterator + _M_insert_lower(_Base_ptr __y, const value_type& __v); + + iterator + _M_insert_equal_lower(const value_type& __x); +#endif + + enum { __as_lvalue, __as_rvalue }; + + template + _Link_type + _M_copy(_Link_type, _Base_ptr, _NodeGen&); + + template + _Link_type + _M_copy(const _Rb_tree& __x, _NodeGen& __gen) + { + _Link_type __root = + _M_copy<_MoveValues>(__x._M_mbegin(), _M_end(), __gen); + _M_leftmost() = _S_minimum(__root); + _M_rightmost() = _S_maximum(__root); + _M_impl._M_node_count = __x._M_impl._M_node_count; + return __root; + } + + _Link_type + _M_copy(const _Rb_tree& __x) + { + _Alloc_node __an(*this); + return _M_copy<__as_lvalue>(__x, __an); + } + + void + _M_erase(_Link_type __x); + + iterator + _M_lower_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k); + + const_iterator + _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const; + + iterator + _M_upper_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k); + + const_iterator + _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const; + + public: + // allocation/deallocation +#if __cplusplus < 201103L + _Rb_tree() { } +#else + _Rb_tree() = default; +#endif + + _Rb_tree(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_impl(__comp, _Node_allocator(__a)) { } + + _Rb_tree(const _Rb_tree& __x) + : _M_impl(__x._M_impl) + { + if (__x._M_root() != 0) + _M_root() = _M_copy(__x); + } + +#if __cplusplus >= 201103L + _Rb_tree(const allocator_type& __a) + : _M_impl(_Node_allocator(__a)) + { } + + _Rb_tree(const _Rb_tree& __x, const allocator_type& __a) + : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a)) + { + if (__x._M_root() != nullptr) + _M_root() = _M_copy(__x); + } + + _Rb_tree(_Rb_tree&&) = default; + + _Rb_tree(_Rb_tree&& __x, const allocator_type& __a) + : _Rb_tree(std::move(__x), _Node_allocator(__a)) + { } + + private: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, true_type) + noexcept(is_nothrow_default_constructible<_Compare>::value) + : _M_impl(std::move(__x._M_impl), std::move(__a)) + { } + + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, false_type) + : _M_impl(__x._M_impl._M_key_compare, std::move(__a)) + { + if (__x._M_root() != nullptr) + _M_move_data(__x, false_type{}); + } + + public: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) + noexcept( noexcept( + _Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(), + std::declval())) ) + : _Rb_tree(std::move(__x), std::move(__a), + typename _Alloc_traits::is_always_equal{}) + { } +#endif + + ~_Rb_tree() _GLIBCXX_NOEXCEPT + { _M_erase(_M_begin()); } + + _Rb_tree& + operator=(const _Rb_tree& __x); + + // Accessors. + _Compare + key_comp() const + { return _M_impl._M_key_compare; } + + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_header._M_left); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_header._M_left); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(&this->_M_impl._M_header); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(&this->_M_impl._M_header); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_impl._M_node_count == 0; } + + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_impl._M_node_count; } + + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Alloc_traits::max_size(_M_get_Node_allocator()); } + + void + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value); + + // Insert/erase. +#if __cplusplus >= 201103L + template + pair + _M_insert_unique(_Arg&& __x); + + template + iterator + _M_insert_equal(_Arg&& __x); + + template + iterator + _M_insert_unique_(const_iterator __pos, _Arg&& __x, _NodeGen&); + + template + iterator + _M_insert_unique_(const_iterator __pos, _Arg&& __x) + { + _Alloc_node __an(*this); + return _M_insert_unique_(__pos, std::forward<_Arg>(__x), __an); + } + + template + iterator + _M_insert_equal_(const_iterator __pos, _Arg&& __x, _NodeGen&); + + template + iterator + _M_insert_equal_(const_iterator __pos, _Arg&& __x) + { + _Alloc_node __an(*this); + return _M_insert_equal_(__pos, std::forward<_Arg>(__x), __an); + } + + template + pair + _M_emplace_unique(_Args&&... __args); + + template + iterator + _M_emplace_equal(_Args&&... __args); + + template + iterator + _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args); + + template + iterator + _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args); + + template + using __same_value_type + = is_same::value_type>; + + template + __enable_if_t<__same_value_type<_InputIterator>::value> + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __an); + } + + template + __enable_if_t::value> + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + for (; __first != __last; ++__first) + _M_emplace_unique(*__first); + } + + template + __enable_if_t<__same_value_type<_InputIterator>::value> + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __an); + } + + template + __enable_if_t::value> + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_emplace_equal(*__first); + } +#else + pair + _M_insert_unique(const value_type& __x); + + iterator + _M_insert_equal(const value_type& __x); + + template + iterator + _M_insert_unique_(const_iterator __pos, const value_type& __x, + _NodeGen&); + + iterator + _M_insert_unique_(const_iterator __pos, const value_type& __x) + { + _Alloc_node __an(*this); + return _M_insert_unique_(__pos, __x, __an); + } + + template + iterator + _M_insert_equal_(const_iterator __pos, const value_type& __x, + _NodeGen&); + iterator + _M_insert_equal_(const_iterator __pos, const value_type& __x) + { + _Alloc_node __an(*this); + return _M_insert_equal_(__pos, __x, __an); + } + + template + void + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __an); + } + + template + void + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __an); + } +#endif + + private: + void + _M_erase_aux(const_iterator __position); + + void + _M_erase_aux(const_iterator __first, const_iterator __last); + + public: +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { + __glibcxx_assert(__position != end()); + const_iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result._M_const_cast(); + } + + // LWG 2059. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { + __glibcxx_assert(__position != end()); + iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result; + } +#else + void + erase(iterator __position) + { + __glibcxx_assert(__position != end()); + _M_erase_aux(__position); + } + + void + erase(const_iterator __position) + { + __glibcxx_assert(__position != end()); + _M_erase_aux(__position); + } +#endif + + size_type + erase(const key_type& __x); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { + _M_erase_aux(__first, __last); + return __last._M_const_cast(); + } +#else + void + erase(iterator __first, iterator __last) + { _M_erase_aux(__first, __last); } + + void + erase(const_iterator __first, const_iterator __last) + { _M_erase_aux(__first, __last); } +#endif + + void + clear() _GLIBCXX_NOEXCEPT + { + _M_erase(_M_begin()); + _M_impl._M_reset(); + } + + // Set operations. + iterator + find(const key_type& __k); + + const_iterator + find(const key_type& __k) const; + + size_type + count(const key_type& __k) const; + + iterator + lower_bound(const key_type& __k) + { return _M_lower_bound(_M_begin(), _M_end(), __k); } + + const_iterator + lower_bound(const key_type& __k) const + { return _M_lower_bound(_M_begin(), _M_end(), __k); } + + iterator + upper_bound(const key_type& __k) + { return _M_upper_bound(_M_begin(), _M_end(), __k); } + + const_iterator + upper_bound(const key_type& __k) const + { return _M_upper_bound(_M_begin(), _M_end(), __k); } + + pair + equal_range(const key_type& __k); + + pair + equal_range(const key_type& __k) const; + +#if __cplusplus >= 201402L + template> + iterator + _M_find_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_find_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_find_tr(const _Kt& __k) const + { + auto __j = _M_lower_bound_tr(__k); + if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node))) + __j = end(); + return __j; + } + + template> + size_type + _M_count_tr(const _Kt& __k) const + { + auto __p = _M_equal_range_tr(__k); + return std::distance(__p.first, __p.second); + } + + template> + iterator + _M_lower_bound_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_lower_bound_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_lower_bound_tr(const _Kt& __k) const + { + auto __x = _M_begin(); + auto __y = _M_end(); + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + { + __y = __x; + __x = _S_left(__x); + } + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template> + iterator + _M_upper_bound_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_upper_bound_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_upper_bound_tr(const _Kt& __k) const + { + auto __x = _M_begin(); + auto __y = _M_end(); + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + { + __y = __x; + __x = _S_left(__x); + } + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template> + pair + _M_equal_range_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + auto __ret = __const_this->_M_equal_range_tr(__k); + return { __ret.first._M_const_cast(), __ret.second._M_const_cast() }; + } + + template> + pair + _M_equal_range_tr(const _Kt& __k) const + { + auto __low = _M_lower_bound_tr(__k); + auto __high = __low; + auto& __cmp = _M_impl._M_key_compare; + while (__high != end() && !__cmp(__k, _S_key(__high._M_node))) + ++__high; + return { __low, __high }; + } +#endif + + // Debugging. + bool + __rb_verify() const; + +#if __cplusplus >= 201103L + _Rb_tree& + operator=(_Rb_tree&&) + noexcept(_Alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Compare>::value); + + template + void + _M_assign_unique(_Iterator, _Iterator); + + template + void + _M_assign_equal(_Iterator, _Iterator); + + private: + // Move elements from container with equal allocator. + void + _M_move_data(_Rb_tree& __x, true_type) + { _M_impl._M_move_data(__x._M_impl); } + + // Move elements from container with possibly non-equal allocator, + // which might result in a copy not a move. + void + _M_move_data(_Rb_tree&, false_type); + + // Move assignment from container with equal allocator. + void + _M_move_assign(_Rb_tree&, true_type); + + // Move assignment from container with possibly non-equal allocator, + // which might result in a copy not a move. + void + _M_move_assign(_Rb_tree&, false_type); +#endif + +#if __cplusplus > 201402L + public: + /// Re-insert an extracted node. + insert_return_type + _M_reinsert_node_unique(node_type&& __nh) + { + insert_return_type __ret; + if (__nh.empty()) + __ret.position = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + + auto __res = _M_get_insert_unique_pos(__nh._M_key()); + if (__res.second) + { + __ret.position + = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + __nh._M_ptr = nullptr; + __ret.inserted = true; + } + else + { + __ret.node = std::move(__nh); + __ret.position = iterator(__res.first); + __ret.inserted = false; + } + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_equal(node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_equal_pos(__nh._M_key()); + if (__res.second) + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + else + __ret = _M_insert_equal_lower_node(__nh._M_ptr); + __nh._M_ptr = nullptr; + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_hint_unique(const_iterator __hint, node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_hint_unique_pos(__hint, __nh._M_key()); + if (__res.second) + { + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + __nh._M_ptr = nullptr; + } + else + __ret = iterator(__res.first); + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_hint_equal(const_iterator __hint, node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_hint_equal_pos(__hint, __nh._M_key()); + if (__res.second) + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + else + __ret = _M_insert_equal_lower_node(__nh._M_ptr); + __nh._M_ptr = nullptr; + } + return __ret; + } + + /// Extract a node. + node_type + extract(const_iterator __pos) + { + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_const_cast()._M_node, _M_impl._M_header); + --_M_impl._M_node_count; + return { static_cast<_Link_type>(__ptr), _M_get_Node_allocator() }; + } + + /// Extract a node. + node_type + extract(const key_type& __k) + { + node_type __nh; + auto __pos = find(__k); + if (__pos != end()) + __nh = extract(const_iterator(__pos)); + return __nh; + } + + template + using _Compatible_tree + = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>; + + template + friend class _Rb_tree_merge_helper; + + /// Merge from a compatible container into one with unique keys. + template + void + _M_merge_unique(_Compatible_tree<_Compare2>& __src) noexcept + { + using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>; + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + { + auto __pos = __i++; + auto __res = _M_get_insert_unique_pos(_KeyOfValue()(*__pos)); + if (__res.second) + { + auto& __src_impl = _Merge_helper::_S_get_impl(__src); + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_node, __src_impl._M_header); + --__src_impl._M_node_count; + _M_insert_node(__res.first, __res.second, + static_cast<_Link_type>(__ptr)); + } + } + } + + /// Merge from a compatible container into one with equivalent keys. + template + void + _M_merge_equal(_Compatible_tree<_Compare2>& __src) noexcept + { + using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>; + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + { + auto __pos = __i++; + auto __res = _M_get_insert_equal_pos(_KeyOfValue()(*__pos)); + if (__res.second) + { + auto& __src_impl = _Merge_helper::_S_get_impl(__src); + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_node, __src_impl._M_header); + --__src_impl._M_node_count; + _M_insert_node(__res.first, __res.second, + static_cast<_Link_type>(__ptr)); + } + } + } +#endif // C++17 + + friend bool + operator==(const _Rb_tree& __x, const _Rb_tree& __y) + { + return __x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin()); + } + +#if __cpp_lib_three_way_comparison + friend auto + operator<=>(const _Rb_tree& __x, const _Rb_tree& __y) + { + if constexpr (requires { typename __detail::__synth3way_t<_Val>; }) + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + friend bool + operator<(const _Rb_tree& __x, const _Rb_tree& __y) + { + return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); + } +#endif + + private: +#if __cplusplus >= 201103L + // An RAII _Node handle + struct _Auto_node + { + template + _Auto_node(_Rb_tree& __t, _Args&&... __args) + : _M_t(__t), + _M_node(__t._M_create_node(std::forward<_Args>(__args)...)) + { } + + ~_Auto_node() + { + if (_M_node) + _M_t._M_drop_node(_M_node); + } + + _Auto_node(_Auto_node&& __n) + : _M_t(__n._M_t), _M_node(__n._M_node) + { __n._M_node = nullptr; } + + const _Key& + _M_key() const + { return _S_key(_M_node); } + + iterator + _M_insert(pair<_Base_ptr, _Base_ptr> __p) + { + auto __it = _M_t._M_insert_node(__p.first, __p.second, _M_node); + _M_node = nullptr; + return __it; + } + + iterator + _M_insert_equal_lower() + { + auto __it = _M_t._M_insert_equal_lower_node(_M_node); + _M_node = nullptr; + return __it; + } + + _Rb_tree& _M_t; + _Link_type _M_node; + }; +#endif // C++11 + }; + + template + inline void + swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) + { __x.swap(__y); } + +#if __cplusplus >= 201103L + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_data(_Rb_tree& __x, false_type) + { + if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) + _M_move_data(__x, true_type()); + else + { + constexpr bool __move = !__move_if_noexcept_cond::value; + _Alloc_node __an(*this); + _M_root() = _M_copy<__move>(__x, __an); + if _GLIBCXX17_CONSTEXPR (__move) + __x.clear(); + } + } + + template + inline void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_assign(_Rb_tree& __x, true_type) + { + clear(); + if (__x._M_root() != nullptr) + _M_move_data(__x, true_type()); + std::__alloc_on_move(_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_assign(_Rb_tree& __x, false_type) + { + if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) + return _M_move_assign(__x, true_type{}); + + // Try to move each node reusing existing nodes and copying __x nodes + // structure. + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + if (__x._M_root() != nullptr) + { + _M_root() = _M_copy<__as_rvalue>(__x, __roan); + __x.clear(); + } + } + + template + inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + operator=(_Rb_tree&& __x) + noexcept(_Alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Compare>::value) + { + _M_impl._M_key_compare = std::move(__x._M_impl._M_key_compare); + _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>()); + return *this; + } + + template + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_assign_unique(_Iterator __first, _Iterator __last) + { + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __roan); + } + + template + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_assign_equal(_Iterator __first, _Iterator __last) + { + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __roan); + } +#endif + + template + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + operator=(const _Rb_tree& __x) + { + if (this != std::__addressof(__x)) + { + // Note that _Key may be a constant type. +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __x._M_get_Node_allocator(); + if (!_Alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // Replacement allocator cannot free existing storage, we need + // to erase nodes first. + clear(); + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + } +#endif + + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + _M_impl._M_key_compare = __x._M_impl._M_key_compare; + if (__x._M_root() != 0) + _M_root() = _M_copy<__as_lvalue>(__x, __roan); + } + + return *this; + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_(_Base_ptr __x, _Base_ptr __p, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__p))); + + _Link_type __z = __node_gen(_GLIBCXX_FORWARD(_Arg, __v)); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_lower(_Base_ptr __p, _Arg&& __v) +#else + _M_insert_lower(_Base_ptr __p, const _Val& __v) +#endif + { + bool __insert_left = (__p == _M_end() + || !_M_impl._M_key_compare(_S_key(__p), + _KeyOfValue()(__v))); + + _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v)); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_equal_lower(_Arg&& __v) +#else + _M_insert_equal_lower(const _Val& __v) +#endif + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ? + _S_left(__x) : _S_right(__x); + } + return _M_insert_lower(__y, _GLIBCXX_FORWARD(_Arg, __v)); + } + + template + template + typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type + _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>:: + _M_copy(_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen) + { + // Structural copy. __x and __p must be non-null. + _Link_type __top = _M_clone_node<_MoveValues>(__x, __node_gen); + __top->_M_parent = __p; + + __try + { + if (__x->_M_right) + __top->_M_right = + _M_copy<_MoveValues>(_S_right(__x), __top, __node_gen); + __p = __top; + __x = _S_left(__x); + + while (__x != 0) + { + _Link_type __y = _M_clone_node<_MoveValues>(__x, __node_gen); + __p->_M_left = __y; + __y->_M_parent = __p; + if (__x->_M_right) + __y->_M_right = _M_copy<_MoveValues>(_S_right(__x), + __y, __node_gen); + __p = __y; + __x = _S_left(__x); + } + } + __catch(...) + { + _M_erase(__top); + __throw_exception_again; + } + return __top; + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase(_Link_type __x) + { + // Erase without rebalancing. + while (__x != 0) + { + _M_erase(_S_right(__x)); + _Link_type __y = _S_left(__x); + _M_drop_node(__x); + __x = __y; + } + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_lower_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k) + { + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const + { + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_upper_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k) + { + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const + { + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template + pair::iterator, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + equal_range(const _Key& __k) + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + if (_M_impl._M_key_compare(_S_key(__x), __k)) + __x = _S_right(__x); + else if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + { + _Link_type __xu(__x); + _Base_ptr __yu(__y); + __y = __x, __x = _S_left(__x); + __xu = _S_right(__xu); + return pair(_M_lower_bound(__x, __y, __k), + _M_upper_bound(__xu, __yu, __k)); + } + } + return pair(iterator(__y), + iterator(__y)); + } + + template + pair::const_iterator, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + equal_range(const _Key& __k) const + { + _Const_Link_type __x = _M_begin(); + _Const_Base_ptr __y = _M_end(); + while (__x != 0) + { + if (_M_impl._M_key_compare(_S_key(__x), __k)) + __x = _S_right(__x); + else if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + { + _Const_Link_type __xu(__x); + _Const_Base_ptr __yu(__y); + __y = __x, __x = _S_left(__x); + __xu = _S_right(__xu); + return pair(_M_lower_bound(__x, __y, __k), + _M_upper_bound(__xu, __yu, __k)); + } + } + return pair(const_iterator(__y), + const_iterator(__y)); + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { + if (_M_root() == 0) + { + if (__t._M_root() != 0) + _M_impl._M_move_data(__t._M_impl); + } + else if (__t._M_root() == 0) + __t._M_impl._M_move_data(_M_impl); + else + { + std::swap(_M_root(),__t._M_root()); + std::swap(_M_leftmost(),__t._M_leftmost()); + std::swap(_M_rightmost(),__t._M_rightmost()); + + _M_root()->_M_parent = _M_end(); + __t._M_root()->_M_parent = __t._M_end(); + std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count); + } + // No need to swap header's color as it does not change. + std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare); + + _Alloc_traits::_S_on_swap(_M_get_Node_allocator(), + __t._M_get_Node_allocator()); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_unique_pos(const key_type& __k) + { + typedef pair<_Base_ptr, _Base_ptr> _Res; + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + bool __comp = true; + while (__x != 0) + { + __y = __x; + __comp = _M_impl._M_key_compare(__k, _S_key(__x)); + __x = __comp ? _S_left(__x) : _S_right(__x); + } + iterator __j = iterator(__y); + if (__comp) + { + if (__j == begin()) + return _Res(__x, __y); + else + --__j; + } + if (_M_impl._M_key_compare(_S_key(__j._M_node), __k)) + return _Res(__x, __y); + return _Res(__j._M_node, 0); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_equal_pos(const key_type& __k) + { + typedef pair<_Base_ptr, _Base_ptr> _Res; + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = _M_impl._M_key_compare(__k, _S_key(__x)) ? + _S_left(__x) : _S_right(__x); + } + return _Res(__x, __y); + } + + template +#if __cplusplus >= 201103L + template +#endif + pair::iterator, bool> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_unique(_Arg&& __v) +#else + _M_insert_unique(const _Val& __v) +#endif + { + typedef pair _Res; + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_unique_pos(_KeyOfValue()(__v)); + + if (__res.second) + { + _Alloc_node __an(*this); + return _Res(_M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), __an), + true); + } + + return _Res(iterator(__res.first), false); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_equal(_Arg&& __v) +#else + _M_insert_equal(const _Val& __v) +#endif + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_equal_pos(_KeyOfValue()(__v)); + _Alloc_node __an(*this); + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), __an); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_hint_unique_pos(const_iterator __position, + const key_type& __k) + { + iterator __pos = __position._M_const_cast(); + typedef pair<_Base_ptr, _Base_ptr> _Res; + + // end() + if (__pos._M_node == _M_end()) + { + if (size() > 0 + && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k)) + return _Res(0, _M_rightmost()); + else + return _M_get_insert_unique_pos(__k); + } + else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node))) + { + // First, try before... + iterator __before = __pos; + if (__pos._M_node == _M_leftmost()) // begin() + return _Res(_M_leftmost(), _M_leftmost()); + else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k)) + { + if (_S_right(__before._M_node) == 0) + return _Res(0, __before._M_node); + else + return _Res(__pos._M_node, __pos._M_node); + } + else + return _M_get_insert_unique_pos(__k); + } + else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) + { + // ... then try after. + iterator __after = __pos; + if (__pos._M_node == _M_rightmost()) + return _Res(0, _M_rightmost()); + else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node))) + { + if (_S_right(__pos._M_node) == 0) + return _Res(0, __pos._M_node); + else + return _Res(__after._M_node, __after._M_node); + } + else + return _M_get_insert_unique_pos(__k); + } + else + // Equivalent keys. + return _Res(__pos._M_node, 0); + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_unique_(const_iterator __position, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v)); + + if (__res.second) + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), + __node_gen); + return iterator(__res.first); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_hint_equal_pos(const_iterator __position, const key_type& __k) + { + iterator __pos = __position._M_const_cast(); + typedef pair<_Base_ptr, _Base_ptr> _Res; + + // end() + if (__pos._M_node == _M_end()) + { + if (size() > 0 + && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost()))) + return _Res(0, _M_rightmost()); + else + return _M_get_insert_equal_pos(__k); + } + else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) + { + // First, try before... + iterator __before = __pos; + if (__pos._M_node == _M_leftmost()) // begin() + return _Res(_M_leftmost(), _M_leftmost()); + else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node))) + { + if (_S_right(__before._M_node) == 0) + return _Res(0, __before._M_node); + else + return _Res(__pos._M_node, __pos._M_node); + } + else + return _M_get_insert_equal_pos(__k); + } + else + { + // ... then try after. + iterator __after = __pos; + if (__pos._M_node == _M_rightmost()) + return _Res(0, _M_rightmost()); + else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k)) + { + if (_S_right(__pos._M_node) == 0) + return _Res(0, __pos._M_node); + else + return _Res(__after._M_node, __after._M_node); + } + else + return _Res(0, 0); + } + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal_(const_iterator __position, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v)); + + if (__res.second) + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), + __node_gen); + + return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v)); + } + +#if __cplusplus >= 201103L + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z) + -> iterator + { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_S_key(__z), + _S_key(__p))); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_lower_node(_Base_ptr __p, _Link_type __z) + -> iterator + { + bool __insert_left = (__p == _M_end() + || !_M_impl._M_key_compare(_S_key(__p), + _S_key(__z))); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal_lower_node(_Link_type __z) + -> iterator + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ? + _S_left(__x) : _S_right(__x); + } + return _M_insert_lower_node(__y, __z); + } + + template + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_unique(_Args&&... __args) + -> pair + { + _Auto_node __z(*this, std::forward<_Args>(__args)...); + auto __res = _M_get_insert_unique_pos(__z._M_key()); + if (__res.second) + return {__z._M_insert(__res), true}; + return {iterator(__res.first), false}; + } + + template + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_equal(_Args&&... __args) + -> iterator + { + _Auto_node __z(*this, std::forward<_Args>(__args)...); + auto __res = _M_get_insert_equal_pos(__z._M_key()); + return __z._M_insert(__res); + } + + template + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args) + -> iterator + { + _Auto_node __z(*this, std::forward<_Args>(__args)...); + auto __res = _M_get_insert_hint_unique_pos(__pos, __z._M_key()); + if (__res.second) + return __z._M_insert(__res); + return iterator(__res.first); + } + + template + template + auto + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args) + -> iterator + { + _Auto_node __z(*this, std::forward<_Args>(__args)...); + auto __res = _M_get_insert_hint_equal_pos(__pos, __z._M_key()); + if (__res.second) + return __z._M_insert(__res); + return __z._M_insert_equal_lower(); + } +#endif + + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase_aux(const_iterator __position) + { + _Link_type __y = + static_cast<_Link_type>(_Rb_tree_rebalance_for_erase + (const_cast<_Base_ptr>(__position._M_node), + this->_M_impl._M_header)); + _M_drop_node(__y); + --_M_impl._M_node_count; + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase_aux(const_iterator __first, const_iterator __last) + { + if (__first == begin() && __last == end()) + clear(); + else + while (__first != __last) + _M_erase_aux(__first++); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(const _Key& __x) + { + pair __p = equal_range(__x); + const size_type __old_size = size(); + _M_erase_aux(__p.first, __p.second); + return __old_size - size(); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + find(const _Key& __k) + { + iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + find(const _Key& __k) const + { + const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + count(const _Key& __k) const + { + pair __p = equal_range(__k); + const size_type __n = std::distance(__p.first, __p.second); + return __n; + } + + _GLIBCXX_PURE unsigned int + _Rb_tree_black_count(const _Rb_tree_node_base* __node, + const _Rb_tree_node_base* __root) throw (); + + template + bool + _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const + { + if (_M_impl._M_node_count == 0 || begin() == end()) + return _M_impl._M_node_count == 0 && begin() == end() + && this->_M_impl._M_header._M_left == _M_end() + && this->_M_impl._M_header._M_right == _M_end(); + + unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root()); + for (const_iterator __it = begin(); __it != end(); ++__it) + { + _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node); + _Const_Link_type __L = _S_left(__x); + _Const_Link_type __R = _S_right(__x); + + if (__x->_M_color == _S_red) + if ((__L && __L->_M_color == _S_red) + || (__R && __R->_M_color == _S_red)) + return false; + + if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L))) + return false; + if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x))) + return false; + + if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len) + return false; + } + + if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) + return false; + if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) + return false; + return true; + } + +#if __cplusplus > 201402L + // Allow access to internals of compatible _Rb_tree specializations. + template + struct _Rb_tree_merge_helper<_Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>; + + static auto& + _S_get_impl(_Rb_tree<_Key, _Val, _Sel, _Cmp2, _Alloc>& __tree) + { return __tree._M_impl; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bde5a4b16acea121ae6e6409f5342bc4d09e255b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_tree.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h new file mode 100644 index 0000000000000000000000000000000000000000..7ed69f53f7d8f04963303c7170f3723ab176ab9b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h @@ -0,0 +1,1146 @@ +// Raw memory manipulators -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_uninitialized.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_UNINITIALIZED_H +#define _STL_UNINITIALIZED_H 1 + +#if __cplusplus >= 201103L +#include +#endif + +#include // copy +#include // __alloc_traits + +#if __cplusplus >= 201703L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup memory + * @{ + */ + + /// @cond undocumented + +#if __cplusplus >= 201103L + template + constexpr bool + __check_constructible() + { + // Trivial types can have deleted constructors, but std::copy etc. + // only use assignment (or memmove) not construction, so we need an + // explicit check that construction from _Tp is actually valid, + // otherwise some ill-formed uses of std::uninitialized_xxx would + // compile without errors. This gives a nice clear error message. + static_assert(is_constructible<_ValueType, _Tp>::value, + "result type must be constructible from input type"); + + return true; + } + +// If the type is trivial we don't need to construct it, just assign to it. +// But trivial types can still have deleted or inaccessible assignment, +// so don't try to use std::copy or std::fill etc. if we can't assign. +# define _GLIBCXX_USE_ASSIGN_FOR_INIT(T, U) \ + __is_trivial(T) && __is_assignable(T&, U) \ + && std::__check_constructible() +#else +// No need to check if is_constructible for C++98. Trivial types have +// no user-declared constructors, so if the assignment is valid, construction +// should be too. +# define _GLIBCXX_USE_ASSIGN_FOR_INIT(T, U) \ + __is_trivial(T) && __is_assignable(T&, U) +#endif + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __do_uninit_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + _ForwardIterator __cur = __result; + __try + { + for (; __first != __last; ++__first, (void)++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + + template + struct __uninitialized_copy + { + template + static _ForwardIterator + __uninit_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { return std::__do_uninit_copy(__first, __last, __result); } + }; + + template<> + struct __uninitialized_copy + { + template + static _ForwardIterator + __uninit_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { return std::copy(__first, __last, __result); } + }; + + /// @endcond + + /** + * @brief Copies the range [first,last) into result. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return __result + (__first - __last) + * + * Like copy(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type + _ValueType1; + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType2; + + // _ValueType1 must be trivially-copyable to use memmove, so don't + // bother optimizing to std::copy if it isn't. + // XXX Unnecessary because std::copy would check it anyway? + const bool __can_memmove = __is_trivial(_ValueType1); + +#if __cplusplus < 201103L + typedef typename iterator_traits<_InputIterator>::reference _From; +#else + using _From = decltype(*__first); +#endif + const bool __assignable + = _GLIBCXX_USE_ASSIGN_FOR_INIT(_ValueType2, _From); + + return std::__uninitialized_copy<__can_memmove && __assignable>:: + __uninit_copy(__first, __last, __result); + } + + /// @cond undocumented + + template + _GLIBCXX20_CONSTEXPR void + __do_uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct(std::__addressof(*__cur), __x); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + + template + struct __uninitialized_fill + { + template + static void + __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { std::__do_uninit_fill(__first, __last, __x); } + }; + + template<> + struct __uninitialized_fill + { + template + static void + __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { std::fill(__first, __last, __x); } + }; + + /// @endcond + + /** + * @brief Copies the value x into the range [first,last). + * @param __first An input iterator. + * @param __last An input iterator. + * @param __x The source value. + * @return Nothing. + * + * Like fill(), but does not require an initialized output range. + */ + template + inline void + uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + // Trivial types do not need a constructor to begin their lifetime, + // so try to use std::fill to benefit from its memset optimization. + const bool __can_fill + = _GLIBCXX_USE_ASSIGN_FOR_INIT(_ValueType, const _Tp&); + + std::__uninitialized_fill<__can_fill>:: + __uninit_fill(__first, __last, __x); + } + + /// @cond undocumented + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __do_uninit_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct(std::__addressof(*__cur), __x); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + + template + struct __uninitialized_fill_n + { + template + static _ForwardIterator + __uninit_fill_n(_ForwardIterator __first, _Size __n, + const _Tp& __x) + { return std::__do_uninit_fill_n(__first, __n, __x); } + }; + + template<> + struct __uninitialized_fill_n + { + template + static _ForwardIterator + __uninit_fill_n(_ForwardIterator __first, _Size __n, + const _Tp& __x) + { return std::fill_n(__first, __n, __x); } + }; + + /// @endcond + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 1339. uninitialized_fill_n should return the end of its range + /** + * @brief Copies the value x into the range [first,first+n). + * @param __first An input iterator. + * @param __n The number of copies to make. + * @param __x The source value. + * @return Nothing. + * + * Like fill_n(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + // Trivial types do not need a constructor to begin their lifetime, + // so try to use std::fill_n to benefit from its optimizations. + const bool __can_fill + = _GLIBCXX_USE_ASSIGN_FOR_INIT(_ValueType, const _Tp&) + // For arbitrary class types and floating point types we can't assume + // that __n > 0 and std::__size_to_integer(__n) > 0 are equivalent, + // so only use std::fill_n when _Size is already an integral type. + && __is_integer<_Size>::__value; + + return __uninitialized_fill_n<__can_fill>:: + __uninit_fill_n(__first, __n, __x); + } + +#undef _GLIBCXX_USE_ASSIGN_FOR_INIT + + /// @cond undocumented + + // Extensions: versions of uninitialized_copy, uninitialized_fill, + // and uninitialized_fill_n that take an allocator parameter. + // We dispatch back to the standard versions when we're given the + // default allocator. For nondefault allocators we do not use + // any of the POD optimizations. + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + { + _ForwardIterator __cur = __result; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __first != __last; ++__first, (void)++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur, __alloc); + __throw_exception_again; + } + } + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, allocator<_Tp>&) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__do_uninit_copy(__first, __last, __result); +#endif + return std::uninitialized_copy(__first, __last, __result); + } + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_move_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + { + return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_ITERATOR(__last), + __result, __alloc); + } + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_move_if_noexcept_a(_InputIterator __first, + _InputIterator __last, + _ForwardIterator __result, + _Allocator& __alloc) + { + return std::__uninitialized_copy_a + (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc); + } + + template + _GLIBCXX20_CONSTEXPR + void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __cur != __last; ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), __x); + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, allocator<_Tp2>&) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__do_uninit_fill(__first, __last, __x); +#endif + std::uninitialized_fill(__first, __last, __x); + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __n > 0; --__n, (void) ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), __x); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, allocator<_Tp2>&) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__do_uninit_fill_n(__first, __n, __x); +#endif + return std::uninitialized_fill_n(__first, __n, __x); + } + + + // Extensions: __uninitialized_copy_move, __uninitialized_move_copy, + // __uninitialized_fill_move, __uninitialized_move_fill. + // All of these algorithms take a user-supplied allocator, which is used + // for construction and destruction. + + // __uninitialized_copy_move + // Copies [first1, last1) into [result, result + (last1 - first1)), and + // move [first2, last2) into + // [result, result + (last1 - first1) + (last2 - first2)). + template + inline _ForwardIterator + __uninitialized_copy_move(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _ForwardIterator __result, + _Allocator& __alloc) + { + _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1, + __result, + __alloc); + __try + { + return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_move_copy + // Moves [first1, last1) into [result, result + (last1 - first1)), and + // copies [first2, last2) into + // [result, result + (last1 - first1) + (last2 - first2)). + template + inline _ForwardIterator + __uninitialized_move_copy(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _ForwardIterator __result, + _Allocator& __alloc) + { + _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1, + __result, + __alloc); + __try + { + return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_fill_move + // Fills [result, mid) with x, and moves [first, last) into + // [mid, mid + (last - first)). + template + inline _ForwardIterator + __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid, + const _Tp& __x, _InputIterator __first, + _InputIterator __last, _Allocator& __alloc) + { + std::__uninitialized_fill_a(__result, __mid, __x, __alloc); + __try + { + return std::__uninitialized_move_a(__first, __last, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_move_fill + // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and + // fills [first2 + (last1 - first1), last2) with x. + template + inline void + __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, + _ForwardIterator __last2, const _Tp& __x, + _Allocator& __alloc) + { + _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1, + __first2, + __alloc); + __try + { + std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc); + } + __catch(...) + { + std::_Destroy(__first2, __mid2, __alloc); + __throw_exception_again; + } + } + + /// @endcond + +#if __cplusplus >= 201103L + /// @cond undocumented + + // Extensions: __uninitialized_default, __uninitialized_default_n, + // __uninitialized_default_a, __uninitialized_default_n_a. + + template + struct __uninitialized_default_1 + { + template + static void + __uninit_default(_ForwardIterator __first, _ForwardIterator __last) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct(std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_1 + { + template + static void + __uninit_default(_ForwardIterator __first, _ForwardIterator __last) + { + if (__first == __last) + return; + + typename iterator_traits<_ForwardIterator>::value_type* __val + = std::__addressof(*__first); + std::_Construct(__val); + if (++__first != __last) + std::fill(__first, __last, *__val); + } + }; + + template + struct __uninitialized_default_n_1 + { + template + _GLIBCXX20_CONSTEXPR + static _ForwardIterator + __uninit_default_n(_ForwardIterator __first, _Size __n) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct(std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_n_1 + { + template + _GLIBCXX20_CONSTEXPR + static _ForwardIterator + __uninit_default_n(_ForwardIterator __first, _Size __n) + { + if (__n > 0) + { + typename iterator_traits<_ForwardIterator>::value_type* __val + = std::__addressof(*__first); + std::_Construct(__val); + ++__first; + __first = std::fill_n(__first, __n - 1, *__val); + } + return __first; + } + }; + + // __uninitialized_default + // Fills [first, last) with value-initialized value_types. + template + inline void + __uninitialized_default(_ForwardIterator __first, + _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // trivial types can have deleted assignment + const bool __assignable = is_copy_assignable<_ValueType>::value; + + std::__uninitialized_default_1<__is_trivial(_ValueType) + && __assignable>:: + __uninit_default(__first, __last); + } + + // __uninitialized_default_n + // Fills [first, first + n) with value-initialized value_types. + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_default_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // See uninitialized_fill_n for the conditions for using std::fill_n. + constexpr bool __can_fill + = __and_, is_copy_assignable<_ValueType>>::value; + + return __uninitialized_default_n_1<__is_trivial(_ValueType) + && __can_fill>:: + __uninit_default_n(__first, __n); + } + + + // __uninitialized_default_a + // Fills [first, last) with value_types constructed by the allocator + // alloc, with no arguments passed to the construct call. + template + void + __uninitialized_default_a(_ForwardIterator __first, + _ForwardIterator __last, + _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __cur != __last; ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline void + __uninitialized_default_a(_ForwardIterator __first, + _ForwardIterator __last, + allocator<_Tp>&) + { std::__uninitialized_default(__first, __last); } + + + // __uninitialized_default_n_a + // Fills [first, first + n) with value_types constructed by the allocator + // alloc, with no arguments passed to the construct call. + template + _GLIBCXX20_CONSTEXPR _ForwardIterator + __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, + _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __n > 0; --__n, (void) ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_default_n_a specialization for std::allocator, + // which ignores the allocator and value-initializes the elements. + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, + allocator<_Tp>&) + { return std::__uninitialized_default_n(__first, __n); } + + template + struct __uninitialized_default_novalue_1 + { + template + static void + __uninit_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct_novalue(std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_novalue_1 + { + template + static void + __uninit_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + } + }; + + template + struct __uninitialized_default_novalue_n_1 + { + template + static _ForwardIterator + __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct_novalue(std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_novalue_n_1 + { + template + static _ForwardIterator + __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) + { return std::next(__first, __n); } + }; + + // __uninitialized_default_novalue + // Fills [first, last) with default-initialized value_types. + template + inline void + __uninitialized_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + std::__uninitialized_default_novalue_1< + is_trivially_default_constructible<_ValueType>::value>:: + __uninit_default_novalue(__first, __last); + } + + // __uninitialized_default_novalue_n + // Fills [first, first + n) with default-initialized value_types. + template + inline _ForwardIterator + __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + return __uninitialized_default_novalue_n_1< + is_trivially_default_constructible<_ValueType>::value>:: + __uninit_default_novalue_n(__first, __n); + } + + template + _ForwardIterator + __uninitialized_copy_n(_InputIterator __first, _Size __n, + _ForwardIterator __result, input_iterator_tag) + { + _ForwardIterator __cur = __result; + __try + { + for (; __n > 0; --__n, (void) ++__first, ++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + + template + inline _ForwardIterator + __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n, + _ForwardIterator __result, + random_access_iterator_tag) + { return std::uninitialized_copy(__first, __first + __n, __result); } + + template + pair<_InputIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, + _ForwardIterator __result, input_iterator_tag) + { + _ForwardIterator __cur = __result; + __try + { + for (; __n > 0; --__n, (void) ++__first, ++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return {__first, __cur}; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + + template + inline pair<_RandomAccessIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n, + _ForwardIterator __result, + random_access_iterator_tag) + { + auto __second_res = uninitialized_copy(__first, __first + __n, __result); + auto __first_res = std::next(__first, __n); + return {__first_res, __second_res}; + } + + /// @endcond + + /** + * @brief Copies the range [first,first+n) into result. + * @param __first An input iterator. + * @param __n The number of elements to copy. + * @param __result An output iterator. + * @return __result + __n + * @since C++11 + * + * Like copy_n(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_copy_n(_InputIterator __first, _Size __n, + _ForwardIterator __result) + { return std::__uninitialized_copy_n(__first, __n, __result, + std::__iterator_category(__first)); } + + /// @cond undocumented + template + inline pair<_InputIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, + _ForwardIterator __result) + { + return + std::__uninitialized_copy_n_pair(__first, __n, __result, + std::__iterator_category(__first)); + } + /// @endcond +#endif + +#if __cplusplus >= 201703L +# define __cpp_lib_raw_memory_algorithms 201606L + + /** + * @brief Default-initializes objects in the range [first,last). + * @param __first A forward iterator. + * @param __last A forward iterator. + * @since C++17 + */ + template + inline void + uninitialized_default_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + __uninitialized_default_novalue(__first, __last); + } + + /** + * @brief Default-initializes objects in the range [first,first+count). + * @param __first A forward iterator. + * @param __count The number of objects to construct. + * @return __first + __count + * @since C++17 + */ + template + inline _ForwardIterator + uninitialized_default_construct_n(_ForwardIterator __first, _Size __count) + { + return __uninitialized_default_novalue_n(__first, __count); + } + + /** + * @brief Value-initializes objects in the range [first,last). + * @param __first A forward iterator. + * @param __last A forward iterator. + * @since C++17 + */ + template + inline void + uninitialized_value_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + return __uninitialized_default(__first, __last); + } + + /** + * @brief Value-initializes objects in the range [first,first+count). + * @param __first A forward iterator. + * @param __count The number of objects to construct. + * @return __result + __count + * @since C++17 + */ + template + inline _ForwardIterator + uninitialized_value_construct_n(_ForwardIterator __first, _Size __count) + { + return __uninitialized_default_n(__first, __count); + } + + /** + * @brief Move-construct from the range [first,last) into result. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return __result + (__first - __last) + * @since C++17 + */ + template + inline _ForwardIterator + uninitialized_move(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + return std::uninitialized_copy + (_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result); + } + + /** + * @brief Move-construct from the range [first,first+count) into result. + * @param __first An input iterator. + * @param __count The number of objects to initialize. + * @param __result An output iterator. + * @return __result + __count + * @since C++17 + */ + template + inline pair<_InputIterator, _ForwardIterator> + uninitialized_move_n(_InputIterator __first, _Size __count, + _ForwardIterator __result) + { + auto __res = std::__uninitialized_copy_n_pair + (_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + __count, __result); + return {__res.first.base(), __res.second}; + } +#endif // C++17 + +#if __cplusplus >= 201103L + /// @cond undocumented + + template + _GLIBCXX20_CONSTEXPR + inline void + __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig, + _Allocator& __alloc) + noexcept(noexcept(std::allocator_traits<_Allocator>::construct(__alloc, + __dest, std::move(*__orig))) + && noexcept(std::allocator_traits<_Allocator>::destroy( + __alloc, std::__addressof(*__orig)))) + { + typedef std::allocator_traits<_Allocator> __traits; + __traits::construct(__alloc, __dest, std::move(*__orig)); + __traits::destroy(__alloc, std::__addressof(*__orig)); + } + + // This class may be specialized for specific types. + // Also known as is_trivially_relocatable. + template + struct __is_bitwise_relocatable + : is_trivial<_Tp> { }; + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __relocate_a_1(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + noexcept(noexcept(std::__relocate_object_a(std::addressof(*__result), + std::addressof(*__first), + __alloc))) + { + typedef typename iterator_traits<_InputIterator>::value_type + _ValueType; + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType2; + static_assert(std::is_same<_ValueType, _ValueType2>::value, + "relocation is only possible for values of the same type"); + _ForwardIterator __cur = __result; + for (; __first != __last; ++__first, (void)++__cur) + std::__relocate_object_a(std::__addressof(*__cur), + std::__addressof(*__first), __alloc); + return __cur; + } + + template + _GLIBCXX20_CONSTEXPR + inline __enable_if_t::value, _Tp*> + __relocate_a_1(_Tp* __first, _Tp* __last, + _Tp* __result, + [[__maybe_unused__]] allocator<_Up>& __alloc) noexcept + { + ptrdiff_t __count = __last - __first; + if (__count > 0) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + // Can't use memmove. Wrap the pointer so that __relocate_a_1 + // resolves to the non-trivial overload above. + __gnu_cxx::__normal_iterator<_Tp*, void> __out(__result); + __out = std::__relocate_a_1(__first, __last, __out, __alloc); + return __out.base(); + } +#endif + __builtin_memmove(__result, __first, __count * sizeof(_Tp)); + } + return __result + __count; + } + + + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + __relocate_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + noexcept(noexcept(__relocate_a_1(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result), __alloc))) + { + return std::__relocate_a_1(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result), __alloc); + } + + /// @endcond +#endif + + /// @} group memory + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_UNINITIALIZED_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..a7e6b891fe56761317df5ccfdac20f8dff76f68c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_uninitialized.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h new file mode 100644 index 0000000000000000000000000000000000000000..b4ff3989a5dd5555949a212b236ed54be7e670fb --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h @@ -0,0 +1,2130 @@ +// Vector implementation -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_vector.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _STL_VECTOR_H +#define _STL_VECTOR_H 1 + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif +#if __cplusplus >= 202002L +# include +#define __cpp_lib_constexpr_vector 201907L +#endif + +#include + +#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR +extern "C" void +__sanitizer_annotate_contiguous_container(const void*, const void*, + const void*, const void*); +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// See bits/stl_deque.h's _Deque_base for an explanation. + template + struct _Vector_base + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer + pointer; + + struct _Vector_impl_data + { + pointer _M_start; + pointer _M_finish; + pointer _M_end_of_storage; + + _GLIBCXX20_CONSTEXPR + _Vector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + _Vector_impl_data(_Vector_impl_data&& __x) noexcept + : _M_start(__x._M_start), _M_finish(__x._M_finish), + _M_end_of_storage(__x._M_end_of_storage) + { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); } +#endif + + _GLIBCXX20_CONSTEXPR + void + _M_copy_data(_Vector_impl_data const& __x) _GLIBCXX_NOEXCEPT + { + _M_start = __x._M_start; + _M_finish = __x._M_finish; + _M_end_of_storage = __x._M_end_of_storage; + } + + _GLIBCXX20_CONSTEXPR + void + _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + _Vector_impl_data __tmp; + __tmp._M_copy_data(*this); + _M_copy_data(__x); + __x._M_copy_data(__tmp); + } + }; + + struct _Vector_impl + : public _Tp_alloc_type, public _Vector_impl_data + { + _GLIBCXX20_CONSTEXPR + _Vector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Tp_alloc_type>::value) + : _Tp_alloc_type() + { } + + _GLIBCXX20_CONSTEXPR + _Vector_impl(_Tp_alloc_type const& __a) _GLIBCXX_NOEXCEPT + : _Tp_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + // Not defaulted, to enforce noexcept(true) even when + // !is_nothrow_move_constructible<_Tp_alloc_type>. + _GLIBCXX20_CONSTEXPR + _Vector_impl(_Vector_impl&& __x) noexcept + : _Tp_alloc_type(std::move(__x)), _Vector_impl_data(std::move(__x)) + { } + + _GLIBCXX20_CONSTEXPR + _Vector_impl(_Tp_alloc_type&& __a) noexcept + : _Tp_alloc_type(std::move(__a)) + { } + + _GLIBCXX20_CONSTEXPR + _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept + : _Tp_alloc_type(std::move(__a)), _Vector_impl_data(std::move(__rv)) + { } +#endif + +#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR + template + struct _Asan + { + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type> + ::size_type size_type; + + static _GLIBCXX20_CONSTEXPR void + _S_shrink(_Vector_impl&, size_type) { } + static _GLIBCXX20_CONSTEXPR void + _S_on_dealloc(_Vector_impl&) { } + + typedef _Vector_impl& _Reinit; + + struct _Grow + { + _GLIBCXX20_CONSTEXPR _Grow(_Vector_impl&, size_type) { } + _GLIBCXX20_CONSTEXPR void _M_grew(size_type) { } + }; + }; + + // Enable ASan annotations for memory obtained from std::allocator. + template + struct _Asan > + { + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type> + ::size_type size_type; + + // Adjust ASan annotation for [_M_start, _M_end_of_storage) to + // mark end of valid region as __curr instead of __prev. + static _GLIBCXX20_CONSTEXPR void + _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr) + { +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return; +#endif + __sanitizer_annotate_contiguous_container(__impl._M_start, + __impl._M_end_of_storage, __prev, __curr); + } + + static _GLIBCXX20_CONSTEXPR void + _S_grow(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); } + + static _GLIBCXX20_CONSTEXPR void + _S_shrink(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); } + + static _GLIBCXX20_CONSTEXPR void + _S_on_dealloc(_Vector_impl& __impl) + { + if (__impl._M_start) + _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage); + } + + // Used on reallocation to tell ASan unused capacity is invalid. + struct _Reinit + { + explicit _GLIBCXX20_CONSTEXPR + _Reinit(_Vector_impl& __impl) : _M_impl(__impl) + { + // Mark unused capacity as valid again before deallocating it. + _S_on_dealloc(_M_impl); + } + + _GLIBCXX20_CONSTEXPR + ~_Reinit() + { + // Mark unused capacity as invalid after reallocation. + if (_M_impl._M_start) + _S_adjust(_M_impl, _M_impl._M_end_of_storage, + _M_impl._M_finish); + } + + _Vector_impl& _M_impl; + +#if __cplusplus >= 201103L + _Reinit(const _Reinit&) = delete; + _Reinit& operator=(const _Reinit&) = delete; +#endif + }; + + // Tell ASan when unused capacity is initialized to be valid. + struct _Grow + { + _GLIBCXX20_CONSTEXPR + _Grow(_Vector_impl& __impl, size_type __n) + : _M_impl(__impl), _M_n(__n) + { _S_grow(_M_impl, __n); } + + _GLIBCXX20_CONSTEXPR + ~_Grow() { if (_M_n) _S_shrink(_M_impl, _M_n); } + + _GLIBCXX20_CONSTEXPR + void _M_grew(size_type __n) { _M_n -= __n; } + +#if __cplusplus >= 201103L + _Grow(const _Grow&) = delete; + _Grow& operator=(const _Grow&) = delete; +#endif + private: + _Vector_impl& _M_impl; + size_type _M_n; + }; + }; + +#define _GLIBCXX_ASAN_ANNOTATE_REINIT \ + typename _Base::_Vector_impl::template _Asan<>::_Reinit const \ + __attribute__((__unused__)) __reinit_guard(this->_M_impl) +#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \ + typename _Base::_Vector_impl::template _Asan<>::_Grow \ + __attribute__((__unused__)) __grow_guard(this->_M_impl, (n)) +#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n) +#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \ + _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n) +#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \ + _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl) +#else // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR) +#define _GLIBCXX_ASAN_ANNOTATE_REINIT +#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) +#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) +#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) +#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC +#endif // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR + }; + + public: + typedef _Alloc allocator_type; + + _GLIBCXX20_CONSTEXPR + _Tp_alloc_type& + _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _GLIBCXX20_CONSTEXPR + const _Tp_alloc_type& + _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _GLIBCXX20_CONSTEXPR + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + _Vector_base() = default; +#else + _Vector_base() { } +#endif + + _GLIBCXX20_CONSTEXPR + _Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _M_impl(__a) { } + + // Kept for ABI compatibility. +#if !_GLIBCXX_INLINE_VERSION + _GLIBCXX20_CONSTEXPR + _Vector_base(size_t __n) + : _M_impl() + { _M_create_storage(__n); } +#endif + + _GLIBCXX20_CONSTEXPR + _Vector_base(size_t __n, const allocator_type& __a) + : _M_impl(__a) + { _M_create_storage(__n); } + +#if __cplusplus >= 201103L + _Vector_base(_Vector_base&&) = default; + + // Kept for ABI compatibility. +# if !_GLIBCXX_INLINE_VERSION + _GLIBCXX20_CONSTEXPR + _Vector_base(_Tp_alloc_type&& __a) noexcept + : _M_impl(std::move(__a)) { } + + _GLIBCXX20_CONSTEXPR + _Vector_base(_Vector_base&& __x, const allocator_type& __a) + : _M_impl(__a) + { + if (__x.get_allocator() == __a) + this->_M_impl._M_swap_data(__x._M_impl); + else + { + size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start; + _M_create_storage(__n); + } + } +# endif + + _GLIBCXX20_CONSTEXPR + _Vector_base(const allocator_type& __a, _Vector_base&& __x) + : _M_impl(_Tp_alloc_type(__a), std::move(__x._M_impl)) + { } +#endif + + _GLIBCXX20_CONSTEXPR + ~_Vector_base() _GLIBCXX_NOEXCEPT + { + _M_deallocate(_M_impl._M_start, + _M_impl._M_end_of_storage - _M_impl._M_start); + } + + public: + _Vector_impl _M_impl; + + _GLIBCXX20_CONSTEXPR + pointer + _M_allocate(size_t __n) + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; + return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); + } + + _GLIBCXX20_CONSTEXPR + void + _M_deallocate(pointer __p, size_t __n) + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; + if (__p) + _Tr::deallocate(_M_impl, __p, __n); + } + + protected: + _GLIBCXX20_CONSTEXPR + void + _M_create_storage(size_t __n) + { + this->_M_impl._M_start = this->_M_allocate(__n); + this->_M_impl._M_finish = this->_M_impl._M_start; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + } + }; + + /** + * @brief A standard container which offers fixed time access to + * individual elements in any order. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements with the + * %exception of @c push_front and @c pop_front. + * + * In some terminology a %vector can be described as a dynamic + * C-style array, it offers fast and efficient access to individual + * elements in any order and saves the user from worrying about + * memory and size allocation. Subscripting ( @c [] ) access is + * also provided as with C-style arrays. + */ + template > + class vector : protected _Vector_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // Concept requirements. + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::vector must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::vector must have the same value_type as its allocator"); +# endif +#endif + + typedef _Vector_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; + + public: + typedef _Tp value_type; + typedef typename _Base::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + private: +#if __cplusplus >= 201103L + static constexpr bool + _S_nothrow_relocate(true_type) + { + return noexcept(std::__relocate_a(std::declval(), + std::declval(), + std::declval(), + std::declval<_Tp_alloc_type&>())); + } + + static constexpr bool + _S_nothrow_relocate(false_type) + { return false; } + + static constexpr bool + _S_use_relocate() + { + // Instantiating std::__relocate_a might cause an error outside the + // immediate context (in __relocate_object_a's noexcept-specifier), + // so only do it if we know the type can be move-inserted into *this. + return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); + } + + static pointer + _S_do_relocate(pointer __first, pointer __last, pointer __result, + _Tp_alloc_type& __alloc, true_type) noexcept + { + return std::__relocate_a(__first, __last, __result, __alloc); + } + + static pointer + _S_do_relocate(pointer, pointer, pointer __result, + _Tp_alloc_type&, false_type) noexcept + { return __result; } + + static _GLIBCXX20_CONSTEXPR pointer + _S_relocate(pointer __first, pointer __last, pointer __result, + _Tp_alloc_type& __alloc) noexcept + { +#if __cpp_if_constexpr + // All callers have already checked _S_use_relocate() so just do it. + return std::__relocate_a(__first, __last, __result, __alloc); +#else + using __do_it = __bool_constant<_S_use_relocate()>; + return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); +#endif + } +#endif // C++11 + + protected: + using _Base::_M_allocate; + using _Base::_M_deallocate; + using _Base::_M_impl; + using _Base::_M_get_Tp_allocator; + + public: + // [23.2.4.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %vector with no elements. + */ +#if __cplusplus >= 201103L + vector() = default; +#else + vector() { } +#endif + + /** + * @brief Creates a %vector with no elements. + * @param __a An allocator object. + */ + explicit + _GLIBCXX20_CONSTEXPR + vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _Base(__a) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %vector with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n default + * constructed elements. + */ + explicit + _GLIBCXX20_CONSTEXPR + vector(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %vector with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n copies of @a __value. + */ + _GLIBCXX20_CONSTEXPR + vector(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_fill_initialize(__n, __value); } +#else + /** + * @brief Creates a %vector with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n copies of @a __value. + */ + explicit + vector(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_fill_initialize(__n, __value); } +#endif + + /** + * @brief %Vector copy constructor. + * @param __x A %vector of identical element and allocator types. + * + * All the elements of @a __x are copied, but any unused capacity in + * @a __x will not be copied + * (i.e. capacity() == size() in the new %vector). + * + * The newly-created %vector uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + _GLIBCXX20_CONSTEXPR + vector(const vector& __x) + : _Base(__x.size(), + _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) + { + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + +#if __cplusplus >= 201103L + /** + * @brief %Vector move constructor. + * + * The newly-created %vector contains the exact contents of the + * moved instance. + * The contents of the moved instance are a valid, but unspecified + * %vector. + */ + vector(vector&&) noexcept = default; + + /// Copy constructor with alternative allocator + _GLIBCXX20_CONSTEXPR + vector(const vector& __x, const __type_identity_t& __a) + : _Base(__x.size(), __a) + { + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + + private: + _GLIBCXX20_CONSTEXPR + vector(vector&& __rv, const allocator_type& __m, true_type) noexcept + : _Base(__m, std::move(__rv)) + { } + + _GLIBCXX20_CONSTEXPR + vector(vector&& __rv, const allocator_type& __m, false_type) + : _Base(__m) + { + if (__rv.get_allocator() == __m) + this->_M_impl._M_swap_data(__rv._M_impl); + else if (!__rv.empty()) + { + this->_M_create_storage(__rv.size()); + this->_M_impl._M_finish = + std::__uninitialized_move_a(__rv.begin(), __rv.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + __rv.clear(); + } + } + + public: + /// Move constructor with alternative allocator + _GLIBCXX20_CONSTEXPR + vector(vector&& __rv, const __type_identity_t& __m) + noexcept( noexcept( + vector(std::declval(), std::declval(), + std::declval())) ) + : vector(std::move(__rv), __m, typename _Alloc_traits::is_always_equal{}) + { } + + /** + * @brief Builds a %vector from an initializer list. + * @param __l An initializer_list. + * @param __a An allocator. + * + * Create a %vector consisting of copies of the elements in the + * initializer_list @a __l. + * + * This will call the element type's copy constructor N times + * (where N is @a __l.size()) and do no memory reallocation. + */ + _GLIBCXX20_CONSTEXPR + vector(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /** + * @brief Builds a %vector from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator. + * + * Create a %vector consisting of copies of the elements from + * [first,last). + * + * If the iterators are forward, bidirectional, or + * random-access, then this will call the elements' copy + * constructor N times (where N is distance(first,last)) and do + * no memory reallocation. But if only input iterators are + * used, then this will do at most 2N calls to the copy + * constructor, and logN memory reallocations. + */ +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#else + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + /** + * The dtor only erases the elements, and note that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX20_CONSTEXPR + ~vector() _GLIBCXX_NOEXCEPT + { + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC; + } + + /** + * @brief %Vector assignment operator. + * @param __x A %vector of identical element and allocator types. + * + * All the elements of @a __x are copied, but any unused capacity in + * @a __x will not be copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + _GLIBCXX20_CONSTEXPR + vector& + operator=(const vector& __x); + +#if __cplusplus >= 201103L + /** + * @brief %Vector move assignment operator. + * @param __x A %vector of identical element and allocator types. + * + * The contents of @a __x are moved into this %vector (without copying, + * if the allocators permit it). + * Afterwards @a __x is a valid, but unspecified %vector. + * + * Whether the allocator is moved depends on the allocator traits. + */ + _GLIBCXX20_CONSTEXPR + vector& + operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Alloc_traits::_S_propagate_on_move_assign() + || _Alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief %Vector list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ + _GLIBCXX20_CONSTEXPR + vector& + operator=(initializer_list __l) + { + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %vector. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %vector with @a __n copies of the given + * value. Note that the assignment completely changes the + * %vector and that the resulting %vector's size is the same as + * the number of elements assigned. + */ + _GLIBCXX20_CONSTEXPR + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %vector with copies of the elements in the + * range [__first,__last). + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ +#if __cplusplus >= 201103L + template> + _GLIBCXX20_CONSTEXPR + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_dispatch(__first, __last, __false_type()); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer list to a %vector. + * @param __l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ + _GLIBCXX20_CONSTEXPR + void + assign(initializer_list __l) + { + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /// Get a copy of the memory allocation object. + using _Base::get_allocator; + + // iterators + /** + * Returns a read/write iterator that points to the first + * element in the %vector. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %vector. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_start); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %vector. Iteration is done in ordinary + * element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %vector. Iteration is done in + * ordinary element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read/write reverse iterator that points to the + * last element in the %vector. Iteration is done in reverse + * element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %vector. Iteration is done in + * reverse element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %vector. Iteration is done + * in reverse element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %vector. Iteration + * is done in reverse element order. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %vector. Iteration is done in ordinary + * element order. + */ + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %vector. Iteration is done in + * ordinary element order. + */ + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_iterator + cend() const noexcept + { return const_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %vector. Iteration is done in + * reverse element order. + */ + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %vector. Iteration + * is done in reverse element order. + */ + [[__nodiscard__]] _GLIBCXX20_CONSTEXPR + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // [23.2.4.2] capacity + /** Returns the number of elements in the %vector. */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + size() const _GLIBCXX_NOEXCEPT + { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } + + /** Returns the size() of the largest possible %vector. */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _S_max_size(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * default constructed elements are appended. + */ + _GLIBCXX20_CONSTEXPR + void + resize(size_type __new_size) + { + if (__new_size > size()) + _M_default_append(__new_size - size()); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } + + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * the %vector is extended and new elements are populated with + * given data. + */ + _GLIBCXX20_CONSTEXPR + void + resize(size_type __new_size, const value_type& __x) + { + if (__new_size > size()) + _M_fill_insert(end(), __new_size - size(), __x); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } +#else + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * the %vector is extended and new elements are populated with + * given data. + */ + _GLIBCXX20_CONSTEXPR + void + resize(size_type __new_size, value_type __x = value_type()) + { + if (__new_size > size()) + _M_fill_insert(end(), __new_size - size(), __x); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } +#endif + +#if __cplusplus >= 201103L + /** A non-binding request to reduce capacity() to size(). */ + _GLIBCXX20_CONSTEXPR + void + shrink_to_fit() + { _M_shrink_to_fit(); } +#endif + + /** + * Returns the total number of elements that the %vector can + * hold before needing to allocate more memory. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); } + + /** + * Returns true if the %vector is empty. (Thus begin() would + * equal end().) + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + bool + empty() const _GLIBCXX_NOEXCEPT + { return begin() == end(); } + + /** + * @brief Attempt to preallocate enough memory for specified number of + * elements. + * @param __n Number of elements required. + * @throw std::length_error If @a n exceeds @c max_size(). + * + * This function attempts to reserve enough memory for the + * %vector to hold the specified number of elements. If the + * number requested is more than max_size(), length_error is + * thrown. + * + * The advantage of this function is that if optimal code is a + * necessity and the user can determine the number of elements + * that will be required, the user can reserve the memory in + * %advance, and thus prevent a possible reallocation of memory + * and copying of %vector data. + */ + _GLIBCXX20_CONSTEXPR + void + reserve(size_type __n); + + // element access + /** + * @brief Subscript access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } + + /** + * @brief Subscript access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } + + protected: + /// Safety check used only from at(). + _GLIBCXX20_CONSTEXPR + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("vector::_M_range_check: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + /** + * @brief Provides access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the vector. The + * function throws out_of_range if the check fails. + */ + _GLIBCXX20_CONSTEXPR + reference + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * @brief Provides access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the vector. The + * function throws out_of_range if the check fails. + */ + _GLIBCXX20_CONSTEXPR + const_reference + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * Returns a read/write reference to the data at the first + * element of the %vector. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %vector. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %vector. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %vector. + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // data access + /** + * Returns a pointer such that [data(), data() + size()) is a valid + * range. For a non-empty %vector, data() == &front(). + */ + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + _Tp* + data() _GLIBCXX_NOEXCEPT + { return _M_data_ptr(this->_M_impl._M_start); } + + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR + const _Tp* + data() const _GLIBCXX_NOEXCEPT + { return _M_data_ptr(this->_M_impl._M_start); } + + // [23.2.4.3] modifiers + /** + * @brief Add data to the end of the %vector. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %vector and assigns the given data + * to it. Due to the nature of a %vector this operation can be + * done in constant time if the %vector has preallocated space + * available. + */ + _GLIBCXX20_CONSTEXPR + void + push_back(const value_type& __x) + { + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + __x); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_realloc_insert(end(), __x); + } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + void + push_back(value_type&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR + reference +#else + void +#endif + emplace_back(_Args&&... __args); +#endif + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %vector by one. + * + * Note that no data is returned, and if the last element's + * data is needed, it should be retrieved before pop_back() is + * called. + */ + _GLIBCXX20_CONSTEXPR + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + --this->_M_impl._M_finish; + _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); + _GLIBCXX_ASAN_ANNOTATE_SHRINK(1); + } + +#if __cplusplus >= 201103L + /** + * @brief Inserts an object in %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified location. + * Note that this kind of operation could be expensive for a %vector + * and if it is frequently used the user should consider using + * std::list. + */ + template + _GLIBCXX20_CONSTEXPR + iterator + emplace(const_iterator __position, _Args&&... __args) + { return _M_emplace_aux(__position, std::forward<_Args>(__args)...); } + + /** + * @brief Inserts given value into %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %vector before specified iterator. + * @param __position An iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_insert_rval(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer_list into the %vector. + * @param __position An iterator into the %vector. + * @param __l An initializer_list. + * + * This function will insert copies of the data in the + * initializer_list @a l into the %vector before the location + * specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, initializer_list __l) + { + auto __offset = __position - cbegin(); + _M_range_insert(begin() + __offset, __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a number of copies of given data into the %vector. + * @param __position A const_iterator into the %vector. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a specified number of copies of + * the given data before the location specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, size_type __n, const value_type& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(begin() + __offset, __n, __x); + return begin() + __offset; + } +#else + /** + * @brief Inserts a number of copies of given data into the %vector. + * @param __position An iterator into the %vector. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of + * the given data before the location specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %vector. + * @param __position A const_iterator into the %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %vector before the location specified + * by @a pos. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + template> + _GLIBCXX20_CONSTEXPR + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_insert_dispatch(begin() + __offset, + __first, __last, __false_type()); + return begin() + __offset; + } +#else + /** + * @brief Inserts a range into the %vector. + * @param __position An iterator into the %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %vector before the location specified + * by @a pos. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %vector by one. + * + * Note This operation could be expensive and if it is + * frequently used the user should consider using std::list. + * The user is also cautioned that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + _GLIBCXX20_CONSTEXPR + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) + { return _M_erase(begin() + (__position - cbegin())); } +#else + erase(iterator __position) + { return _M_erase(__position); } +#endif + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a __last + * prior to erasing (or end()). + * + * This function will erase the elements in the range + * [__first,__last) and shorten the %vector accordingly. + * + * Note This operation could be expensive and if it is + * frequently used the user should consider using std::list. + * The user is also cautioned that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + _GLIBCXX20_CONSTEXPR + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) + { + const auto __beg = begin(); + const auto __cbeg = cbegin(); + return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg)); + } +#else + erase(iterator __first, iterator __last) + { return _M_erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %vector. + * @param __x A %vector of the same element and allocator types. + * + * This exchanges the elements between two vectors in constant time. + * (Three pointers, so it should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(v1,v2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + _GLIBCXX20_CONSTEXPR + void + swap(vector& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif + this->_M_impl._M_swap_data(__x._M_impl); + _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + _GLIBCXX20_CONSTEXPR + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(this->_M_impl._M_start); } + + protected: + /** + * Memory expansion handler. Uses the member allocation function to + * obtain @a n bytes of memory, and then copies [first,last) into it. + */ + template + _GLIBCXX20_CONSTEXPR + pointer + _M_allocate_and_copy(size_type __n, + _ForwardIterator __first, _ForwardIterator __last) + { + pointer __result = this->_M_allocate(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, __result, + _M_get_Tp_allocator()); + return __result; + } + __catch(...) + { + _M_deallocate(__result, __n); + __throw_exception_again; + } + } + + + // Internal constructor functions follow. + + // Called by the range constructor to implement [23.1.1]/9 + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) + { + this->_M_impl._M_start = _M_allocate(_S_check_init_len( + static_cast(__n), _M_get_Tp_allocator())); + this->_M_impl._M_end_of_storage = + this->_M_impl._M_start + static_cast(__n); + _M_fill_initialize(static_cast(__n), __value); + } + + // Called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#endif + + // Called by the second initialize_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + __try { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } __catch(...) { + clear(); + __throw_exception_again; + } + } + + // Called by the second initialize_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + this->_M_impl._M_start + = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator())); + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + + // Called by the first initialize_dispatch above and by the + // vector(n,value,a) constructor. + _GLIBCXX20_CONSTEXPR + void + _M_fill_initialize(size_type __n, const value_type& __value) + { + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, + _M_get_Tp_allocator()); + } + +#if __cplusplus >= 201103L + // Called by the vector(n) constructor. + _GLIBCXX20_CONSTEXPR + void + _M_default_initialize(size_type __n) + { + this->_M_impl._M_finish = + std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, + _M_get_Tp_allocator()); + } +#endif + + // Internal assign functions follow. The *_aux functions do the actual + // assignment work for the range versions. + + // Called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // Called by the range assign to implement [23.1.1]/9 + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } + + // Called by the second assign_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // Called by the second assign_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag); + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + _GLIBCXX20_CONSTEXPR + void + _M_fill_assign(size_type __n, const value_type& __val); + + // Internal insert functions follow. + + // Called by the range insert to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + _GLIBCXX20_CONSTEXPR + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + __true_type) + { _M_fill_insert(__pos, __n, __val); } + + // Called by the range insert to implement [23.1.1]/9 + template + _GLIBCXX20_CONSTEXPR + void + _M_insert_dispatch(iterator __pos, _InputIterator __first, + _InputIterator __last, __false_type) + { + _M_range_insert(__pos, __first, __last, + std::__iterator_category(__first)); + } + + // Called by the second insert_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag); + + // Called by the second insert_dispatch above + template + _GLIBCXX20_CONSTEXPR + void + _M_range_insert(iterator __pos, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + // Called by insert(p,n,x), and the range insert when it turns out to be + // the same thing. + _GLIBCXX20_CONSTEXPR + void + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + +#if __cplusplus >= 201103L + // Called by resize(n). + _GLIBCXX20_CONSTEXPR + void + _M_default_append(size_type __n); + + _GLIBCXX20_CONSTEXPR + bool + _M_shrink_to_fit(); +#endif + +#if __cplusplus < 201103L + // Called by insert(p,x) + void + _M_insert_aux(iterator __position, const value_type& __x); + + void + _M_realloc_insert(iterator __position, const value_type& __x); +#else + // A value_type object constructed with _Alloc_traits::construct() + // and destroyed with _Alloc_traits::destroy(). + struct _Temporary_value + { + template + _GLIBCXX20_CONSTEXPR explicit + _Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec) + { + _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(), + std::forward<_Args>(__args)...); + } + + _GLIBCXX20_CONSTEXPR + ~_Temporary_value() + { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } + + _GLIBCXX20_CONSTEXPR value_type& + _M_val() noexcept { return _M_storage._M_val; } + + private: + _GLIBCXX20_CONSTEXPR _Tp* + _M_ptr() noexcept { return std::__addressof(_M_storage._M_val); } + + union _Storage + { + constexpr _Storage() : _M_byte() { } + _GLIBCXX20_CONSTEXPR ~_Storage() { } + _Storage& operator=(const _Storage&) = delete; + unsigned char _M_byte; + _Tp _M_val; + }; + + vector* _M_this; + _Storage _M_storage; + }; + + // Called by insert(p,x) and other functions when insertion needs to + // reallocate or move existing elements. _Arg is either _Tp& or _Tp. + template + _GLIBCXX20_CONSTEXPR + void + _M_insert_aux(iterator __position, _Arg&& __arg); + + template + _GLIBCXX20_CONSTEXPR + void + _M_realloc_insert(iterator __position, _Args&&... __args); + + // Either move-construct at the end, or forward to _M_insert_aux. + _GLIBCXX20_CONSTEXPR + iterator + _M_insert_rval(const_iterator __position, value_type&& __v); + + // Try to emplace at the end, otherwise forward to _M_insert_aux. + template + _GLIBCXX20_CONSTEXPR + iterator + _M_emplace_aux(const_iterator __position, _Args&&... __args); + + // Emplacing an rvalue of the correct type can use _M_insert_rval. + _GLIBCXX20_CONSTEXPR + iterator + _M_emplace_aux(const_iterator __position, value_type&& __v) + { return _M_insert_rval(__position, std::move(__v)); } +#endif + + // Called by _M_fill_insert, _M_insert_aux etc. + _GLIBCXX20_CONSTEXPR + size_type + _M_check_len(size_type __n, const char* __s) const + { + if (max_size() - size() < __n) + __throw_length_error(__N(__s)); + + const size_type __len = size() + (std::max)(size(), __n); + return (__len < size() || __len > max_size()) ? max_size() : __len; + } + + // Called by constructors to check initial size. + static _GLIBCXX20_CONSTEXPR size_type + _S_check_init_len(size_type __n, const allocator_type& __a) + { + if (__n > _S_max_size(_Tp_alloc_type(__a))) + __throw_length_error( + __N("cannot create std::vector larger than max_size()")); + return __n; + } + + static _GLIBCXX20_CONSTEXPR size_type + _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + { + // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX, + // and realistically we can't store more than PTRDIFF_MAX/sizeof(T) + // (even if std::allocator_traits::max_size says we can). + const size_t __diffmax + = __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + const size_t __allocmax = _Alloc_traits::max_size(__a); + return (std::min)(__diffmax, __allocmax); + } + + // Internal erase functions follow. + + // Called by erase(q1,q2), clear(), resize(), _M_fill_assign, + // _M_assign_aux. + _GLIBCXX20_CONSTEXPR + void + _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT + { + if (size_type __n = this->_M_impl._M_finish - __pos) + { + std::_Destroy(__pos, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __pos; + _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n); + } + } + + _GLIBCXX20_CONSTEXPR + iterator + _M_erase(iterator __position); + + _GLIBCXX20_CONSTEXPR + iterator + _M_erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + private: + // Constant-time move assignment when source object's memory can be + // moved, either because the source's allocator will move too + // or because the allocators are equal. + _GLIBCXX20_CONSTEXPR + void + _M_move_assign(vector&& __x, true_type) noexcept + { + vector __tmp(get_allocator()); + this->_M_impl._M_swap_data(__x._M_impl); + __tmp._M_impl._M_swap_data(__x._M_impl); + std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); + } + + // Do move assignment when it might not be possible to move source + // object's memory, resulting in a linear-time operation. + _GLIBCXX20_CONSTEXPR + void + _M_move_assign(vector&& __x, false_type) + { + if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) + _M_move_assign(std::move(__x), true_type()); + else + { + // The rvalue's allocator cannot be moved and is not equal, + // so we need to individually move each element. + this->_M_assign_aux(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + std::random_access_iterator_tag()); + __x.clear(); + } + } +#endif + + template + _GLIBCXX20_CONSTEXPR + _Up* + _M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT + { return __ptr; } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + typename std::pointer_traits<_Ptr>::element_type* + _M_data_ptr(_Ptr __ptr) const + { return empty() ? nullptr : std::__to_address(__ptr); } +#else + template + _Up* + _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT + { return __ptr; } + + template + value_type* + _M_data_ptr(_Ptr __ptr) + { return empty() ? (value_type*)0 : __ptr.operator->(); } + + template + const value_type* + _M_data_ptr(_Ptr __ptr) const + { return empty() ? (const value_type*)0 : __ptr.operator->(); } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> vector<_ValT, _Allocator>; +#endif + + /** + * @brief Vector equality comparison. + * @param __x A %vector. + * @param __y A %vector of the same type as @a __x. + * @return True iff the size and elements of the vectors are equal. + * + * This is an equivalence relation. It is linear in the size of the + * vectors. Vectors are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return (__x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin())); } + +#if __cpp_lib_three_way_comparison + /** + * @brief Vector ordering relation. + * @param __x A `vector`. + * @param __y A `vector` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + _GLIBCXX20_CONSTEXPR + inline __detail::__synth3way_t<_Tp> + operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Vector ordering relation. + * @param __x A %vector. + * @param __y A %vector of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * vectors. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + inline bool + operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::vector::swap(). + template + _GLIBCXX20_CONSTEXPR + inline void + swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // vector into a variant, but only if move assignment cannot throw. + template + struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>> + : std::is_nothrow_move_assignable<_GLIBCXX_STD_C::vector<_Tp, _Alloc>> + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_VECTOR_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1ac539ce01bacf99a545e8875bd1bab54f8748e2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stl_vector.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..86c5845b8355ef640ad179b7b79527f0dc718384 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h @@ -0,0 +1,270 @@ +// Stream iterators + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/stream_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _STREAM_ITERATOR_H +#define _STREAM_ITERATOR_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + +// Ignore warnings about std::iterator. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /// Provides input iterator semantics for streams. + template, typename _Dist = ptrdiff_t> + class istream_iterator + : public iterator + { + public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT, _Traits> istream_type; + + private: + istream_type* _M_stream; + _Tp _M_value; + // This bool becomes false at end-of-stream. It should be sufficient to + // check _M_stream != nullptr instead, but historically we did not set + // _M_stream to null when reaching the end, so we need to keep this flag. + bool _M_ok; + + public: + /// Construct end of input stream iterator. + _GLIBCXX_CONSTEXPR istream_iterator() + _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Tp>::value) + : _M_stream(0), _M_value(), _M_ok(false) {} + + /// Construct start of input stream iterator. + istream_iterator(istream_type& __s) + : _M_stream(std::__addressof(__s)), _M_ok(true) + { _M_read(); } + + istream_iterator(const istream_iterator& __obj) + _GLIBCXX_NOEXCEPT_IF(is_nothrow_copy_constructible<_Tp>::value) + : _M_stream(__obj._M_stream), _M_value(__obj._M_value), + _M_ok(__obj._M_ok) + { } + +#if __cplusplus > 201703L && __cpp_lib_concepts + constexpr + istream_iterator(default_sentinel_t) + noexcept(is_nothrow_default_constructible_v<_Tp>) + : istream_iterator() { } +#endif + +#if __cplusplus >= 201103L + istream_iterator& operator=(const istream_iterator&) = default; + ~istream_iterator() = default; +#endif + + _GLIBCXX_NODISCARD + const _Tp& + operator*() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_deref_istream) + ._M_iterator(*this)); + return _M_value; + } + + _GLIBCXX_NODISCARD + const _Tp* + operator->() const _GLIBCXX_NOEXCEPT + { return std::__addressof((operator*())); } + + istream_iterator& + operator++() + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_inc_istream) + ._M_iterator(*this)); + _M_read(); + return *this; + } + + istream_iterator + operator++(int) + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_inc_istream) + ._M_iterator(*this)); + istream_iterator __tmp = *this; + _M_read(); + return __tmp; + } + + private: + bool + _M_equal(const istream_iterator& __x) const _GLIBCXX_NOEXCEPT + { + // Ideally this would just return _M_stream == __x._M_stream, + // but code compiled with old versions never sets _M_stream to null. + return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); + } + + void + _M_read() + { + if (_M_stream && !(*_M_stream >> _M_value)) + { + _M_stream = 0; + _M_ok = false; + } + } + + /// Return true if the iterators refer to the same stream, + /// or are both at end-of-stream. + _GLIBCXX_NODISCARD + friend bool + operator==(const istream_iterator& __x, const istream_iterator& __y) + _GLIBCXX_NOEXCEPT + { return __x._M_equal(__y); } + +#if __cpp_impl_three_way_comparison < 201907L + /// Return true if the iterators refer to different streams, + /// or if one is at end-of-stream and the other is not. + _GLIBCXX_NODISCARD + friend bool + operator!=(const istream_iterator& __x, const istream_iterator& __y) + _GLIBCXX_NOEXCEPT + { return !__x._M_equal(__y); } +#endif + +#if __cplusplus > 201703L && __cpp_lib_concepts + [[nodiscard]] + friend bool + operator==(const istream_iterator& __i, default_sentinel_t) noexcept + { return !__i._M_stream; } +#endif + }; + + /** + * @brief Provides output iterator semantics for streams. + * + * This class provides an iterator to write to an ostream. The type Tp is + * the only type written by this iterator and there must be an + * operator<<(Tp) defined. + * + * @tparam _Tp The type to write to the ostream. + * @tparam _CharT The ostream char_type. + * @tparam _Traits The ostream char_traits. + */ + template > + class ostream_iterator + : public iterator + { + public: + ///@{ + /// Public typedef +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + ///@} + + private: + ostream_type* _M_stream; + const _CharT* _M_string; + + public: + /// Construct from an ostream. + ostream_iterator(ostream_type& __s) _GLIBCXX_NOEXCEPT + : _M_stream(std::__addressof(__s)), _M_string(0) {} + + /** + * Construct from an ostream. + * + * The delimiter string @a c is written to the stream after every Tp + * written to the stream. The delimiter is not copied, and thus must + * not be destroyed while this iterator is in use. + * + * @param __s Underlying ostream to write to. + * @param __c CharT delimiter string to insert. + */ + ostream_iterator(ostream_type& __s, const _CharT* __c) _GLIBCXX_NOEXCEPT + : _M_stream(std::__addressof(__s)), _M_string(__c) { } + + /// Copy constructor. + ostream_iterator(const ostream_iterator& __obj) _GLIBCXX_NOEXCEPT + : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { } + +#if __cplusplus >= 201103L + ostream_iterator& operator=(const ostream_iterator&) = default; +#endif + + /// Writes @a value to underlying ostream using operator<<. If + /// constructed with delimiter string, writes delimiter to ostream. + ostream_iterator& + operator=(const _Tp& __value) + { + __glibcxx_requires_cond(_M_stream != 0, + _M_message(__gnu_debug::__msg_output_ostream) + ._M_iterator(*this)); + *_M_stream << __value; + if (_M_string) + *_M_stream << _M_string; + return *this; + } + + _GLIBCXX_NODISCARD + ostream_iterator& + operator*() _GLIBCXX_NOEXCEPT + { return *this; } + + ostream_iterator& + operator++() _GLIBCXX_NOEXCEPT + { return *this; } + + ostream_iterator& + operator++(int) _GLIBCXX_NOEXCEPT + { return *this; } + }; +#pragma GCC diagnostic pop + + /// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..cc89f6a669ccadef8f8cb38b896f666f6d765ee9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stream_iterator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc new file mode 100644 index 0000000000000000000000000000000000000000..64f82fcf8ff1ca2e417d9e3bfab3704fbbb02454 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc @@ -0,0 +1,169 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/streambuf.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{streambuf} + */ + +// +// ISO C++ 14882: 27.5 Stream buffers +// + +#ifndef _STREAMBUF_TCC +#define _STREAMBUF_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + streamsize + basic_streambuf<_CharT, _Traits>:: + xsgetn(char_type* __s, streamsize __n) + { + streamsize __ret = 0; + while (__ret < __n) + { + const streamsize __buf_len = this->egptr() - this->gptr(); + if (__buf_len) + { + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); + traits_type::copy(__s, this->gptr(), __len); + __ret += __len; + __s += __len; + this->__safe_gbump(__len); + } + + if (__ret < __n) + { + const int_type __c = this->uflow(); + if (!traits_type::eq_int_type(__c, traits_type::eof())) + { + traits_type::assign(*__s++, traits_type::to_char_type(__c)); + ++__ret; + } + else + break; + } + } + return __ret; + } + + template + streamsize + basic_streambuf<_CharT, _Traits>:: + xsputn(const char_type* __s, streamsize __n) + { + streamsize __ret = 0; + while (__ret < __n) + { + const streamsize __buf_len = this->epptr() - this->pptr(); + if (__buf_len) + { + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); + traits_type::copy(this->pptr(), __s, __len); + __ret += __len; + __s += __len; + this->__safe_pbump(__len); + } + + if (__ret < __n) + { + int_type __c = this->overflow(traits_type::to_int_type(*__s)); + if (!traits_type::eq_int_type(__c, traits_type::eof())) + { + ++__ret; + ++__s; + } + else + break; + } + } + return __ret; + } + + // Conceivably, this could be used to implement buffer-to-buffer + // copies, if this was ever desired in an un-ambiguous way by the + // standard. + template + streamsize + __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout, + bool& __ineof) + { + streamsize __ret = 0; + __ineof = true; + typename _Traits::int_type __c = __sbin->sgetc(); + while (!_Traits::eq_int_type(__c, _Traits::eof())) + { + __c = __sbout->sputc(_Traits::to_char_type(__c)); + if (_Traits::eq_int_type(__c, _Traits::eof())) + { + __ineof = false; + break; + } + ++__ret; + __c = __sbin->snextc(); + } + return __ret; + } + + template + inline streamsize + __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout) + { + bool __ineof; + return __copy_streambufs_eof(__sbin, __sbout, __ineof); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_streambuf; + + extern template + streamsize + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_streambuf; + + extern template + streamsize + __copy_streambufs(basic_streambuf*, + basic_streambuf*); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..fe4d2ce4e4f63a29f790f7529670533e54ae867d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h new file mode 100644 index 0000000000000000000000000000000000000000..72344c630880243b7a65cb3a8e6ed8ac74478d93 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h @@ -0,0 +1,519 @@ +// Streambuf iterators + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/streambuf_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _STREAMBUF_ITERATOR_H +#define _STREAMBUF_ITERATOR_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + +// Ignore warnings about std::iterator. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // 24.5.3 Template class istreambuf_iterator + /// Provides input iterator semantics for streambufs. + template + class istreambuf_iterator + : public iterator + { + public: + // Types: + ///@{ + /// Public typedefs +#if __cplusplus < 201103L + typedef _CharT& reference; // Changed to _CharT by LWG 445 +#elif __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3188. istreambuf_iterator::pointer should not be unspecified + using pointer = void; +#endif + + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_istream<_CharT, _Traits> istream_type; + ///@} + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_move_a2(istreambuf_iterator<_CharT2>, + istreambuf_iterator<_CharT2>, _CharT2*); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_n_a(istreambuf_iterator<_CharT2>, _Size, _CharT2*, bool); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + istreambuf_iterator<_CharT2> >::__type + find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + const _CharT2&); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + void>::__type + advance(istreambuf_iterator<_CharT2>&, _Distance); + + private: + // 24.5.3 istreambuf_iterator + // p 1 + // If the end of stream is reached (streambuf_type::sgetc() + // returns traits_type::eof()), the iterator becomes equal to + // the "end of stream" iterator value. + // NB: This implementation assumes the "end of stream" value + // is EOF, or -1. + mutable streambuf_type* _M_sbuf; + int_type _M_c; + + public: + /// Construct end of input stream iterator. + _GLIBCXX_CONSTEXPR istreambuf_iterator() _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(0), _M_c(traits_type::eof()) { } + +#if __cplusplus > 201703L && __cpp_lib_concepts + constexpr istreambuf_iterator(default_sentinel_t) noexcept + : istreambuf_iterator() { } +#endif + +#if __cplusplus >= 201103L + istreambuf_iterator(const istreambuf_iterator&) noexcept = default; + + ~istreambuf_iterator() = default; +#endif + + /// Construct start of input stream iterator. + istreambuf_iterator(istream_type& __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { } + + /// Construct start of streambuf iterator. + istreambuf_iterator(streambuf_type* __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s), _M_c(traits_type::eof()) { } + +#if __cplusplus >= 201103L + istreambuf_iterator& + operator=(const istreambuf_iterator&) noexcept = default; +#endif + + /// Return the current character pointed to by iterator. This returns + /// streambuf.sgetc(). It cannot be assigned. NB: The result of + /// operator*() on an end of stream is undefined. + _GLIBCXX_NODISCARD + char_type + operator*() const + { + int_type __c = _M_get(); + +#ifdef _GLIBCXX_DEBUG_PEDANTIC + // Dereferencing a past-the-end istreambuf_iterator is a + // libstdc++ extension + __glibcxx_requires_cond(!_S_is_eof(__c), + _M_message(__gnu_debug::__msg_deref_istreambuf) + ._M_iterator(*this)); +#endif + return traits_type::to_char_type(__c); + } + + /// Advance the iterator. Calls streambuf.sbumpc(). + istreambuf_iterator& + operator++() + { + __glibcxx_requires_cond(_M_sbuf && + (!_S_is_eof(_M_c) || !_S_is_eof(_M_sbuf->sgetc())), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(*this)); + + _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + return *this; + } + + /// Advance the iterator. Calls streambuf.sbumpc(). + istreambuf_iterator + operator++(int) + { + __glibcxx_requires_cond(_M_sbuf && + (!_S_is_eof(_M_c) || !_S_is_eof(_M_sbuf->sgetc())), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(*this)); + + istreambuf_iterator __old = *this; + __old._M_c = _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + return __old; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 110 istreambuf_iterator::equal not const + // NB: there is also number 111 (NAD) relevant to this function. + /// Return true both iterators are end or both are not end. + _GLIBCXX_NODISCARD + bool + equal(const istreambuf_iterator& __b) const + { return _M_at_eof() == __b._M_at_eof(); } + + private: + int_type + _M_get() const + { + int_type __ret = _M_c; + if (_M_sbuf && _S_is_eof(__ret) && _S_is_eof(__ret = _M_sbuf->sgetc())) + _M_sbuf = 0; + return __ret; + } + + bool + _M_at_eof() const + { return _S_is_eof(_M_get()); } + + static bool + _S_is_eof(int_type __c) + { + const int_type __eof = traits_type::eof(); + return traits_type::eq_int_type(__c, __eof); + } + +#if __cplusplus > 201703L && __cpp_lib_concepts + [[nodiscard]] + friend bool + operator==(const istreambuf_iterator& __i, default_sentinel_t __s) + { return __i._M_at_eof(); } +#endif + }; + + template + _GLIBCXX_NODISCARD + inline bool + operator==(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return __a.equal(__b); } + +#if __cpp_impl_three_way_comparison < 201907L + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return !__a.equal(__b); } +#endif + + /// Provides output iterator semantics for streambufs. + template + class ostreambuf_iterator + : public iterator + { + public: + // Types: + ///@{ + /// Public typedefs +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + ///@} + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + + private: + streambuf_type* _M_sbuf; + bool _M_failed; + + public: + +#if __cplusplus > 201703L + constexpr + ostreambuf_iterator() noexcept + : _M_sbuf(nullptr), _M_failed(true) { } +#endif + + /// Construct output iterator from ostream. + ostreambuf_iterator(ostream_type& __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { } + + /// Construct output iterator from streambuf. + ostreambuf_iterator(streambuf_type* __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s), _M_failed(!_M_sbuf) { } + + /// Write character to streambuf. Calls streambuf.sputc(). + ostreambuf_iterator& + operator=(_CharT __c) + { + if (!_M_failed && + _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof())) + _M_failed = true; + return *this; + } + + /// Return *this. + _GLIBCXX_NODISCARD + ostreambuf_iterator& + operator*() + { return *this; } + + /// Return *this. + ostreambuf_iterator& + operator++(int) + { return *this; } + + /// Return *this. + ostreambuf_iterator& + operator++() + { return *this; } + + /// Return true if previous operator=() failed. + _GLIBCXX_NODISCARD + bool + failed() const _GLIBCXX_USE_NOEXCEPT + { return _M_failed; } + + ostreambuf_iterator& + _M_put(const _CharT* __ws, streamsize __len) + { + if (__builtin_expect(!_M_failed, true) + && __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len, + false)) + _M_failed = true; + return *this; + } + }; +#pragma GCC diagnostic pop + + // Overloads for streambuf iterators. + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + copy(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, + ostreambuf_iterator<_CharT> __result) + { + if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed) + { + bool __ineof; + __copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof); + if (!__ineof) + __result._M_failed = true; + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_move_a2(_CharT* __first, _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_move_a2(const _CharT* __first, const _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_move_a2(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, _CharT* __result) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + + if (__first._M_sbuf && !__last._M_sbuf) + { + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, traits_type::eof())) + { + const streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + traits_type::copy(__result, __sb->gptr(), __n); + __sb->__safe_gbump(__n); + __result += __n; + __c = __sb->underflow(); + } + else + { + *__result++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + } + } + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_n_a(istreambuf_iterator<_CharT> __it, _Size __n, _CharT* __result, + bool __strict __attribute__((__unused__))) + { + if (__n == 0) + return __result; + + __glibcxx_requires_cond(__it._M_sbuf, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__it)); + _CharT* __beg = __result; + __result += __it._M_sbuf->sgetn(__beg, __n); + __glibcxx_requires_cond(!__strict || __result - __beg == __n, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__it)); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + istreambuf_iterator<_CharT> >::__type + find(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, const _CharT& __val) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + const int_type __eof = traits_type::eof(); + + if (__first._M_sbuf && !__last._M_sbuf) + { + const int_type __ival = traits_type::to_int_type(__val); + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __ival)) + { + streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + const _CharT* __p = traits_type::find(__sb->gptr(), + __n, __val); + if (__p) + __n = __p - __sb->gptr(); + __sb->__safe_gbump(__n); + __c = __sb->sgetc(); + } + else + __c = __sb->snextc(); + } + + __first._M_c = __eof; + } + + return __first; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + void>::__type + advance(istreambuf_iterator<_CharT>& __i, _Distance __n) + { + if (__n == 0) + return; + + __glibcxx_assert(__n > 0); + __glibcxx_requires_cond(!__i._M_at_eof(), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__i)); + + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + const int_type __eof = traits_type::eof(); + + streambuf_type* __sb = __i._M_sbuf; + while (__n > 0) + { + streamsize __size = __sb->egptr() - __sb->gptr(); + if (__size > __n) + { + __sb->__safe_gbump(__n); + break; + } + + __sb->__safe_gbump(__size); + __n -= __size; + if (traits_type::eq_int_type(__sb->underflow(), __eof)) + { + __glibcxx_requires_cond(__n == 0, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__i)); + break; + } + } + + __i._M_c = __eof; + } + +/// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6a8252206ebed35bca3606e616be1e5c603681de Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@streambuf_iterator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h new file mode 100644 index 0000000000000000000000000000000000000000..65e62bdf0c5c4f7e8af70aa39d749f2b12e5776b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h @@ -0,0 +1,100 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/stringfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _STRINGFWD_H +#define _STRINGFWD_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup strings Strings + * + * @{ + */ + + template + struct char_traits; + + template<> struct char_traits; + + template<> struct char_traits; + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> struct char_traits; +#endif + +#if __cplusplus >= 201103L + template<> struct char_traits; + template<> struct char_traits; +#endif + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + template, + typename _Alloc = allocator<_CharT> > + class basic_string; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// A string of @c char + typedef basic_string string; + + /// A string of @c wchar_t + typedef basic_string wstring; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// A string of @c char8_t + typedef basic_string u8string; +#endif + +#if __cplusplus >= 201103L + /// A string of @c char16_t + typedef basic_string u16string; + + /// A string of @c char32_t + typedef basic_string u32string; +#endif + + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _STRINGFWD_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..213b55c1e5fb81403f49b628d126e00d8352a6ea Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@stringfwd.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h new file mode 100644 index 0000000000000000000000000000000000000000..712de5a6ff94d25b0f78c4184f51a35d1044b077 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h @@ -0,0 +1,117 @@ +// std::this_thread::sleep_for/until declarations -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/this_thread_sleep.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{thread} + */ + +#ifndef _GLIBCXX_THIS_THREAD_SLEEP_H +#define _GLIBCXX_THIS_THREAD_SLEEP_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include // std::chrono::* + +#ifdef _GLIBCXX_USE_NANOSLEEP +# include // errno, EINTR +# include // nanosleep +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup threads + * @{ + */ + + /** @namespace std::this_thread + * @brief ISO C++ 2011 namespace for interacting with the current thread + * + * C++11 30.3.2 [thread.thread.this] Namespace this_thread. + */ + namespace this_thread + { +#ifndef _GLIBCXX_NO_SLEEP + +#ifndef _GLIBCXX_USE_NANOSLEEP + void + __sleep_for(chrono::seconds, chrono::nanoseconds); +#endif + + /// this_thread::sleep_for + template + inline void + sleep_for(const chrono::duration<_Rep, _Period>& __rtime) + { + if (__rtime <= __rtime.zero()) + return; + auto __s = chrono::duration_cast(__rtime); + auto __ns = chrono::duration_cast(__rtime - __s); +#ifdef _GLIBCXX_USE_NANOSLEEP + struct ::timespec __ts = + { + static_cast(__s.count()), + static_cast(__ns.count()) + }; + while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR) + { } +#else + __sleep_for(__s, __ns); +#endif + } + + /// this_thread::sleep_until + template + inline void + sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + auto __now = _Clock::now(); + if (_Clock::is_steady) + { + if (__now < __atime) + sleep_for(__atime - __now); + return; + } + while (__now < __atime) + { + sleep_for(__atime - __now); + __now = _Clock::now(); + } + } +#endif // ! NO_SLEEP + } // namespace this_thread + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 + +#endif // _GLIBCXX_THIS_THREAD_SLEEP_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bd33e1a854cf41986e0713e0fbf2b1768a0a72c8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@this_thread_sleep.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h new file mode 100644 index 0000000000000000000000000000000000000000..7884f49622d67abb445ac809c843da10f9f8801e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h @@ -0,0 +1,457 @@ +// Class template uniform_int_distribution -*- C++ -*- + +// Copyright (C) 2009-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/uniform_int_dist.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _GLIBCXX_BITS_UNIFORM_INT_DIST_H +#define _GLIBCXX_BITS_UNIFORM_INT_DIST_H + +#include +#include +#if __cplusplus > 201703L +# include +#endif +#include // __glibcxx_function_requires + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __cpp_lib_concepts + /// Requirements for a uniform random bit generator. + template + concept uniform_random_bit_generator + = invocable<_Gen&> && unsigned_integral> + && requires + { + { _Gen::min() } -> same_as>; + { _Gen::max() } -> same_as>; + requires bool_constant<(_Gen::min() < _Gen::max())>::value; + }; +#endif + + namespace __detail + { + // Determine whether number is a power of two. + // This is true for zero, which is OK because we want _Power_of_2(n+1) + // to be true if n==numeric_limits<_Tp>::max() and so n+1 wraps around. + template + constexpr bool + _Power_of_2(_Tp __x) + { + return ((__x - 1) & __x) == 0; + } + } + + /** + * @brief Uniform discrete distribution for random numbers. + * A discrete random distribution on the range @f$[min, max]@f$ with equal + * probability throughout the range. + */ + template + class uniform_int_distribution + { + static_assert(std::is_integral<_IntType>::value, + "template argument must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + /** Parameter type. */ + struct param_type + { + typedef uniform_int_distribution<_IntType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_IntType __a, + _IntType __b = __gnu_cxx::__int_traits<_IntType>::__max) + : _M_a(__a), _M_b(__b) + { + __glibcxx_assert(_M_a <= _M_b); + } + + result_type + a() const + { return _M_a; } + + result_type + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _IntType _M_a; + _IntType _M_b; + }; + + public: + /** + * @brief Constructs a uniform distribution object. + */ + uniform_int_distribution() : uniform_int_distribution(0) { } + + /** + * @brief Constructs a uniform distribution object. + */ + explicit + uniform_int_distribution(_IntType __a, + _IntType __b + = __gnu_cxx::__int_traits<_IntType>::__max) + : _M_param(__a, __b) + { } + + explicit + uniform_int_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the uniform integer distribution. + */ + void + reset() { } + + result_type + a() const + { return _M_param.a(); } + + result_type + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the inclusive lower bound of the distribution range. + */ + result_type + min() const + { return this->a(); } + + /** + * @brief Returns the inclusive upper bound of the distribution range. + */ + result_type + max() const + { return this->b(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomBitGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomBitGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two uniform integer distributions have + * the same parameters. + */ + friend bool + operator==(const uniform_int_distribution& __d1, + const uniform_int_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + // Lemire's nearly divisionless algorithm. + // Returns an unbiased random number from __g downscaled to [0,__range) + // using an unsigned type _Wp twice as wide as unsigned type _Up. + template + static _Up + _S_nd(_Urbg& __g, _Up __range) + { + using _Up_traits = __gnu_cxx::__int_traits<_Up>; + using _Wp_traits = __gnu_cxx::__int_traits<_Wp>; + static_assert(!_Up_traits::__is_signed, "U must be unsigned"); + static_assert(!_Wp_traits::__is_signed, "W must be unsigned"); + static_assert(_Wp_traits::__digits == (2 * _Up_traits::__digits), + "W must be twice as wide as U"); + + // reference: Fast Random Integer Generation in an Interval + // ACM Transactions on Modeling and Computer Simulation 29 (1), 2019 + // https://arxiv.org/abs/1805.10941 + _Wp __product = _Wp(__g()) * _Wp(__range); + _Up __low = _Up(__product); + if (__low < __range) + { + _Up __threshold = -__range % __range; + while (__low < __threshold) + { + __product = _Wp(__g()) * _Wp(__range); + __low = _Up(__product); + } + } + return __product >> _Up_traits::__digits; + } + }; + + template + template + typename uniform_int_distribution<_IntType>::result_type + uniform_int_distribution<_IntType>:: + operator()(_UniformRandomBitGenerator& __urng, + const param_type& __param) + { + typedef typename _UniformRandomBitGenerator::result_type _Gresult_type; + typedef typename make_unsigned::type __utype; + typedef typename common_type<_Gresult_type, __utype>::type __uctype; + + constexpr __uctype __urngmin = _UniformRandomBitGenerator::min(); + constexpr __uctype __urngmax = _UniformRandomBitGenerator::max(); + static_assert( __urngmin < __urngmax, + "Uniform random bit generator must define min() < max()"); + constexpr __uctype __urngrange = __urngmax - __urngmin; + + const __uctype __urange + = __uctype(__param.b()) - __uctype(__param.a()); + + __uctype __ret; + if (__urngrange > __urange) + { + // downscaling + + const __uctype __uerange = __urange + 1; // __urange can be zero + +#if defined __UINT64_TYPE__ && defined __UINT32_TYPE__ +#if __SIZEOF_INT128__ + if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT64_MAX__) + { + // __urng produces values that use exactly 64-bits, + // so use 128-bit integers to downscale to desired range. + __UINT64_TYPE__ __u64erange = __uerange; + __ret = __extension__ _S_nd(__urng, + __u64erange); + } + else +#endif + if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT32_MAX__) + { + // __urng produces values that use exactly 32-bits, + // so use 64-bit integers to downscale to desired range. + __UINT32_TYPE__ __u32erange = __uerange; + __ret = _S_nd<__UINT64_TYPE__>(__urng, __u32erange); + } + else +#endif + { + // fallback case (2 divisions) + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + do + __ret = __uctype(__urng()) - __urngmin; + while (__ret >= __past); + __ret /= __scaling; + } + } + else if (__urngrange < __urange) + { + // upscaling + /* + Note that every value in [0, urange] + can be written uniquely as + + (urngrange + 1) * high + low + + where + + high in [0, urange / (urngrange + 1)] + + and + + low in [0, urngrange]. + */ + __uctype __tmp; // wraparound control + do + { + const __uctype __uerngrange = __urngrange + 1; + __tmp = (__uerngrange * operator() + (__urng, param_type(0, __urange / __uerngrange))); + __ret = __tmp + (__uctype(__urng()) - __urngmin); + } + while (__ret > __urange || __ret < __tmp); + } + else + __ret = __uctype(__urng()) - __urngmin; + + return __ret + __param.a(); + } + + + template + template + void + uniform_int_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typedef typename _UniformRandomBitGenerator::result_type _Gresult_type; + typedef typename make_unsigned::type __utype; + typedef typename common_type<_Gresult_type, __utype>::type __uctype; + + static_assert( __urng.min() < __urng.max(), + "Uniform random bit generator must define min() < max()"); + + constexpr __uctype __urngmin = __urng.min(); + constexpr __uctype __urngmax = __urng.max(); + constexpr __uctype __urngrange = __urngmax - __urngmin; + const __uctype __urange + = __uctype(__param.b()) - __uctype(__param.a()); + + __uctype __ret; + + if (__urngrange > __urange) + { + if (__detail::_Power_of_2(__urngrange + 1) + && __detail::_Power_of_2(__urange + 1)) + { + while (__f != __t) + { + __ret = __uctype(__urng()) - __urngmin; + *__f++ = (__ret & __urange) + __param.a(); + } + } + else + { + // downscaling + const __uctype __uerange = __urange + 1; // __urange can be zero + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + while (__f != __t) + { + do + __ret = __uctype(__urng()) - __urngmin; + while (__ret >= __past); + *__f++ = __ret / __scaling + __param.a(); + } + } + } + else if (__urngrange < __urange) + { + // upscaling + /* + Note that every value in [0, urange] + can be written uniquely as + + (urngrange + 1) * high + low + + where + + high in [0, urange / (urngrange + 1)] + + and + + low in [0, urngrange]. + */ + __uctype __tmp; // wraparound control + while (__f != __t) + { + do + { + constexpr __uctype __uerngrange = __urngrange + 1; + __tmp = (__uerngrange * operator() + (__urng, param_type(0, __urange / __uerngrange))); + __ret = __tmp + (__uctype(__urng()) - __urngmin); + } + while (__ret > __urange || __ret < __tmp); + *__f++ = __ret; + } + } + else + while (__f != __t) + *__f++ = __uctype(__urng()) - __urngmin + __param.a(); + } + + // operator!= and operator<< and operator>> are defined in + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..94623240837b74f565fa1fb1c27d668ccb7f54f1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uniform_int_dist.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h new file mode 100644 index 0000000000000000000000000000000000000000..1f1aa15c463e7e221624ac0728b9bd195082ed29 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h @@ -0,0 +1,243 @@ +// std::unique_lock implementation -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unique_lock.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{mutex} + */ + +#ifndef _GLIBCXX_UNIQUE_LOCK_H +#define _GLIBCXX_UNIQUE_LOCK_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include // for std::swap +#include // for std::defer_lock_t + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @brief A movable scoped lock type. + * + * A unique_lock controls mutex ownership within a scope. Ownership of the + * mutex can be delayed until after construction and can be transferred + * to another unique_lock by move construction or move assignment. If a + * mutex lock is owned when the destructor runs ownership will be released. + * + * @ingroup mutexes + */ + template + class unique_lock + { + public: + typedef _Mutex mutex_type; + + unique_lock() noexcept + : _M_device(0), _M_owns(false) + { } + + explicit unique_lock(mutex_type& __m) + : _M_device(std::__addressof(__m)), _M_owns(false) + { + lock(); + _M_owns = true; + } + + unique_lock(mutex_type& __m, defer_lock_t) noexcept + : _M_device(std::__addressof(__m)), _M_owns(false) + { } + + unique_lock(mutex_type& __m, try_to_lock_t) + : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock()) + { } + + unique_lock(mutex_type& __m, adopt_lock_t) noexcept + : _M_device(std::__addressof(__m)), _M_owns(true) + { + // XXX calling thread owns mutex + } + + template + unique_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __atime) + : _M_device(std::__addressof(__m)), + _M_owns(_M_device->try_lock_until(__atime)) + { } + + template + unique_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rtime) + : _M_device(std::__addressof(__m)), + _M_owns(_M_device->try_lock_for(__rtime)) + { } + + ~unique_lock() + { + if (_M_owns) + unlock(); + } + + unique_lock(const unique_lock&) = delete; + unique_lock& operator=(const unique_lock&) = delete; + + unique_lock(unique_lock&& __u) noexcept + : _M_device(__u._M_device), _M_owns(__u._M_owns) + { + __u._M_device = 0; + __u._M_owns = false; + } + + unique_lock& operator=(unique_lock&& __u) noexcept + { + if(_M_owns) + unlock(); + + unique_lock(std::move(__u)).swap(*this); + + __u._M_device = 0; + __u._M_owns = false; + + return *this; + } + + void + lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_device->lock(); + _M_owns = true; + } + } + + bool + try_lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock(); + return _M_owns; + } + } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_until(__atime); + return _M_owns; + } + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_for(__rtime); + return _M_owns; + } + } + + void + unlock() + { + if (!_M_owns) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_device) + { + _M_device->unlock(); + _M_owns = false; + } + } + + void + swap(unique_lock& __u) noexcept + { + std::swap(_M_device, __u._M_device); + std::swap(_M_owns, __u._M_owns); + } + + mutex_type* + release() noexcept + { + mutex_type* __ret = _M_device; + _M_device = 0; + _M_owns = false; + return __ret; + } + + bool + owns_lock() const noexcept + { return _M_owns; } + + explicit operator bool() const noexcept + { return owns_lock(); } + + mutex_type* + mutex() const noexcept + { return _M_device; } + + private: + mutex_type* _M_device; + bool _M_owns; + }; + + /// Swap overload for unique_lock objects. + /// @relates unique_lock + template + inline void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif // _GLIBCXX_UNIQUE_LOCK_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..35f452748d6c37820f580a2f7ba03b1a29be8e90 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_lock.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h new file mode 100644 index 0000000000000000000000000000000000000000..ad60fada59bf491079b113f4b904ef13880bea89 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h @@ -0,0 +1,1165 @@ +// unique_ptr implementation -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unique_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _UNIQUE_PTR_H +#define _UNIQUE_PTR_H 1 + +#include +#include +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +# include +#endif + +#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc +# if __cpp_lib_constexpr_memory < 202202L +// Defined with older value in bits/ptr_traits.h for C++20 +# undef __cpp_lib_constexpr_memory +# define __cpp_lib_constexpr_memory 202202L +# endif +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template class auto_ptr; +#pragma GCC diagnostic pop +#endif + + /// Primary template of default_delete, used by unique_ptr for single objects + /// @since C++11 + template + struct default_delete + { + /// Default constructor + constexpr default_delete() noexcept = default; + + /** @brief Converting constructor. + * + * Allows conversion from a deleter for objects of another type, `_Up`, + * only if `_Up*` is convertible to `_Tp*`. + */ + template>> + _GLIBCXX23_CONSTEXPR + default_delete(const default_delete<_Up>&) noexcept { } + + /// Calls `delete __ptr` + _GLIBCXX23_CONSTEXPR + void + operator()(_Tp* __ptr) const + { + static_assert(!is_void<_Tp>::value, + "can't delete pointer to incomplete type"); + static_assert(sizeof(_Tp)>0, + "can't delete pointer to incomplete type"); + delete __ptr; + } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 740 - omit specialization for array objects with a compile time length + + /// Specialization of default_delete for arrays, used by `unique_ptr` + template + struct default_delete<_Tp[]> + { + public: + /// Default constructor + constexpr default_delete() noexcept = default; + + /** @brief Converting constructor. + * + * Allows conversion from a deleter for arrays of another type, such as + * a const-qualified version of `_Tp`. + * + * Conversions from types derived from `_Tp` are not allowed because + * it is undefined to `delete[]` an array of derived types through a + * pointer to the base type. + */ + template>> + _GLIBCXX23_CONSTEXPR + default_delete(const default_delete<_Up[]>&) noexcept { } + + /// Calls `delete[] __ptr` + template + _GLIBCXX23_CONSTEXPR + typename enable_if::value>::type + operator()(_Up* __ptr) const + { + static_assert(sizeof(_Tp)>0, + "can't delete pointer to incomplete type"); + delete [] __ptr; + } + }; + + /// @cond undocumented + + // Manages the pointer and deleter of a unique_ptr + template + class __uniq_ptr_impl + { + template + struct _Ptr + { + using type = _Up*; + }; + + template + struct + _Ptr<_Up, _Ep, __void_t::type::pointer>> + { + using type = typename remove_reference<_Ep>::type::pointer; + }; + + public: + using _DeleterConstraint = enable_if< + __and_<__not_>, + is_default_constructible<_Dp>>::value>; + + using pointer = typename _Ptr<_Tp, _Dp>::type; + + static_assert( !is_rvalue_reference<_Dp>::value, + "unique_ptr's deleter type must be a function object type" + " or an lvalue reference type" ); + + __uniq_ptr_impl() = default; + _GLIBCXX23_CONSTEXPR + __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } + + template + _GLIBCXX23_CONSTEXPR + __uniq_ptr_impl(pointer __p, _Del&& __d) + : _M_t(__p, std::forward<_Del>(__d)) { } + + _GLIBCXX23_CONSTEXPR + __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept + : _M_t(std::move(__u._M_t)) + { __u._M_ptr() = nullptr; } + + _GLIBCXX23_CONSTEXPR + __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept + { + reset(__u.release()); + _M_deleter() = std::forward<_Dp>(__u._M_deleter()); + return *this; + } + + _GLIBCXX23_CONSTEXPR + pointer& _M_ptr() noexcept { return std::get<0>(_M_t); } + _GLIBCXX23_CONSTEXPR + pointer _M_ptr() const noexcept { return std::get<0>(_M_t); } + _GLIBCXX23_CONSTEXPR + _Dp& _M_deleter() noexcept { return std::get<1>(_M_t); } + _GLIBCXX23_CONSTEXPR + const _Dp& _M_deleter() const noexcept { return std::get<1>(_M_t); } + + _GLIBCXX23_CONSTEXPR + void reset(pointer __p) noexcept + { + const pointer __old_p = _M_ptr(); + _M_ptr() = __p; + if (__old_p) + _M_deleter()(__old_p); + } + + _GLIBCXX23_CONSTEXPR + pointer release() noexcept + { + pointer __p = _M_ptr(); + _M_ptr() = nullptr; + return __p; + } + + _GLIBCXX23_CONSTEXPR + void + swap(__uniq_ptr_impl& __rhs) noexcept + { + using std::swap; + swap(this->_M_ptr(), __rhs._M_ptr()); + swap(this->_M_deleter(), __rhs._M_deleter()); + } + + private: + tuple _M_t; + }; + + // Defines move construction + assignment as either defaulted or deleted. + template ::value, + bool = is_move_assignable<_Dp>::value> + struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = default; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = default; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = delete; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = delete; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; + }; + /// @endcond + + // 20.7.1.2 unique_ptr for single objects. + + /// A move-only smart pointer that manages unique ownership of a resource. + /// @headerfile memory + /// @since C++11 + template > + class unique_ptr + { + template + using _DeleterConstraint = + typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; + + __uniq_ptr_data<_Tp, _Dp> _M_t; + + public: + using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; + using element_type = _Tp; + using deleter_type = _Dp; + + private: + // helper template for detecting a safe conversion from another + // unique_ptr + template + using __safe_conversion_up = __and_< + is_convertible::pointer, pointer>, + __not_> + >; + + public: + // Constructors. + + /// Default constructor, creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr() noexcept + : _M_t() + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * + * The deleter will be value-initialized. + */ + template> + _GLIBCXX23_CONSTEXPR + explicit + unique_ptr(pointer __p) noexcept + : _M_t(__p) + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p __d + */ + template>> + _GLIBCXX23_CONSTEXPR + unique_ptr(pointer __p, const deleter_type& __d) noexcept + : _M_t(__p, __d) { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * @param __d An rvalue reference to a (non-reference) deleter. + * + * The deleter will be initialized with @p std::move(__d) + */ + template>> + _GLIBCXX23_CONSTEXPR + unique_ptr(pointer __p, + __enable_if_t::value, + _Del&&> __d) noexcept + : _M_t(__p, std::move(__d)) + { } + + template::type> + _GLIBCXX23_CONSTEXPR + unique_ptr(pointer, + __enable_if_t::value, + _DelUnref&&>) = delete; + + /// Creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr(nullptr_t) noexcept + : _M_t() + { } + + // Move constructors. + + /// Move constructor. + unique_ptr(unique_ptr&&) = default; + + /** @brief Converting constructor from another type + * + * Requires that the pointer owned by @p __u is convertible to the + * type of pointer owned by this object, @p __u does not own an array, + * and @p __u has a compatible deleter type. + */ + template, + __conditional_t::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>>> + _GLIBCXX23_CONSTEXPR + unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) + { } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /// Converting constructor from @c auto_ptr + template, is_same<_Dp, default_delete<_Tp>>>> + unique_ptr(auto_ptr<_Up>&& __u) noexcept; +#pragma GCC diagnostic pop +#endif + + /// Destructor, invokes the deleter if the stored pointer is not null. +#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc + constexpr +#endif + ~unique_ptr() noexcept + { + static_assert(__is_invocable::value, + "unique_ptr's deleter must be invocable with a pointer"); + auto& __ptr = _M_t._M_ptr(); + if (__ptr != nullptr) + get_deleter()(std::move(__ptr)); + __ptr = pointer(); + } + + // Assignment. + + /** @brief Move assignment operator. + * + * Invokes the deleter if this object owns a pointer. + */ + unique_ptr& operator=(unique_ptr&&) = default; + + /** @brief Assignment from another type. + * + * @param __u The object to transfer ownership from, which owns a + * convertible pointer to a non-array object. + * + * Invokes the deleter if this object owns a pointer. + */ + template + _GLIBCXX23_CONSTEXPR + typename enable_if< __and_< + __safe_conversion_up<_Up, _Ep>, + is_assignable + >::value, + unique_ptr&>::type + operator=(unique_ptr<_Up, _Ep>&& __u) noexcept + { + reset(__u.release()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); + return *this; + } + + /// Reset the %unique_ptr to empty, invoking the deleter if necessary. + _GLIBCXX23_CONSTEXPR + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Dereference the stored pointer. + _GLIBCXX23_CONSTEXPR + typename add_lvalue_reference::type + operator*() const noexcept(noexcept(*std::declval())) + { + __glibcxx_assert(get() != pointer()); + return *get(); + } + + /// Return the stored pointer. + _GLIBCXX23_CONSTEXPR + pointer + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); + return get(); + } + + /// Return the stored pointer. + _GLIBCXX23_CONSTEXPR + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + _GLIBCXX23_CONSTEXPR + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + _GLIBCXX23_CONSTEXPR + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + _GLIBCXX23_CONSTEXPR + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + _GLIBCXX23_CONSTEXPR + pointer + release() noexcept + { return _M_t.release(); } + + /** @brief Replace the stored pointer. + * + * @param __p The new pointer to store. + * + * The deleter will be invoked if a pointer is already owned. + */ + _GLIBCXX23_CONSTEXPR + void + reset(pointer __p = pointer()) noexcept + { + static_assert(__is_invocable::value, + "unique_ptr's deleter must be invocable with a pointer"); + _M_t.reset(std::move(__p)); + } + + /// Exchange the pointer and deleter with another object. + _GLIBCXX23_CONSTEXPR + void + swap(unique_ptr& __u) noexcept + { + static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); + _M_t.swap(__u._M_t); + } + + // Disable copy from lvalue. + unique_ptr(const unique_ptr&) = delete; + unique_ptr& operator=(const unique_ptr&) = delete; + }; + + // 20.7.1.3 unique_ptr for array objects with a runtime length + // [unique.ptr.runtime] + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 740 - omit specialization for array objects with a compile time length + + /// A move-only smart pointer that manages unique ownership of an array. + /// @headerfile memory + /// @since C++11 + template + class unique_ptr<_Tp[], _Dp> + { + template + using _DeleterConstraint = + typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; + + __uniq_ptr_data<_Tp, _Dp> _M_t; + + template + using __remove_cv = typename remove_cv<_Up>::type; + + // like is_base_of<_Tp, _Up> but false if unqualified types are the same + template + using __is_derived_Tp + = __and_< is_base_of<_Tp, _Up>, + __not_, __remove_cv<_Up>>> >; + + public: + using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; + using element_type = _Tp; + using deleter_type = _Dp; + + // helper template for detecting a safe conversion from another + // unique_ptr + template, + typename _UP_pointer = typename _UPtr::pointer, + typename _UP_element_type = typename _UPtr::element_type> + using __safe_conversion_up = __and_< + is_array<_Up>, + is_same, + is_same<_UP_pointer, _UP_element_type*>, + is_convertible<_UP_element_type(*)[], element_type(*)[]> + >; + + // helper template for detecting a safe conversion from a raw pointer + template + using __safe_conversion_raw = __and_< + __or_<__or_, + is_same<_Up, nullptr_t>>, + __and_, + is_same, + is_convertible< + typename remove_pointer<_Up>::type(*)[], + element_type(*)[]> + > + > + >; + + // Constructors. + + /// Default constructor, creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr() noexcept + : _M_t() + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * + * The deleter will be value-initialized. + */ + template, + typename = typename enable_if< + __safe_conversion_raw<_Up>::value, bool>::type> + _GLIBCXX23_CONSTEXPR + explicit + unique_ptr(_Up __p) noexcept + : _M_t(__p) + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p __d + */ + template, + is_copy_constructible<_Del>>> + _GLIBCXX23_CONSTEXPR + unique_ptr(_Up __p, const deleter_type& __d) noexcept + : _M_t(__p, __d) { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p std::move(__d) + */ + template, + is_move_constructible<_Del>>> + _GLIBCXX23_CONSTEXPR + unique_ptr(_Up __p, + __enable_if_t::value, + _Del&&> __d) noexcept + : _M_t(std::move(__p), std::move(__d)) + { } + + template::type, + typename = _Require<__safe_conversion_raw<_Up>>> + unique_ptr(_Up, + __enable_if_t::value, + _DelUnref&&>) = delete; + + /// Move constructor. + unique_ptr(unique_ptr&&) = default; + + /// Creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr(nullptr_t) noexcept + : _M_t() + { } + + template, + __conditional_t::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>>> + _GLIBCXX23_CONSTEXPR + unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) + { } + + /// Destructor, invokes the deleter if the stored pointer is not null. +#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc + constexpr +#endif + ~unique_ptr() + { + auto& __ptr = _M_t._M_ptr(); + if (__ptr != nullptr) + get_deleter()(__ptr); + __ptr = pointer(); + } + + // Assignment. + + /** @brief Move assignment operator. + * + * Invokes the deleter if this object owns a pointer. + */ + unique_ptr& + operator=(unique_ptr&&) = default; + + /** @brief Assignment from another type. + * + * @param __u The object to transfer ownership from, which owns a + * convertible pointer to an array object. + * + * Invokes the deleter if this object owns a pointer. + */ + template + _GLIBCXX23_CONSTEXPR + typename + enable_if<__and_<__safe_conversion_up<_Up, _Ep>, + is_assignable + >::value, + unique_ptr&>::type + operator=(unique_ptr<_Up, _Ep>&& __u) noexcept + { + reset(__u.release()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); + return *this; + } + + /// Reset the %unique_ptr to empty, invoking the deleter if necessary. + _GLIBCXX23_CONSTEXPR + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Access an element of owned array. + _GLIBCXX23_CONSTEXPR + typename std::add_lvalue_reference::type + operator[](size_t __i) const + { + __glibcxx_assert(get() != pointer()); + return get()[__i]; + } + + /// Return the stored pointer. + _GLIBCXX23_CONSTEXPR + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + _GLIBCXX23_CONSTEXPR + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + _GLIBCXX23_CONSTEXPR + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + _GLIBCXX23_CONSTEXPR + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + _GLIBCXX23_CONSTEXPR + pointer + release() noexcept + { return _M_t.release(); } + + /** @brief Replace the stored pointer. + * + * @param __p The new pointer to store. + * + * The deleter will be invoked if a pointer is already owned. + */ + template , + __and_, + is_pointer<_Up>, + is_convertible< + typename remove_pointer<_Up>::type(*)[], + element_type(*)[] + > + > + > + >> + _GLIBCXX23_CONSTEXPR + void + reset(_Up __p) noexcept + { _M_t.reset(std::move(__p)); } + + _GLIBCXX23_CONSTEXPR + void reset(nullptr_t = nullptr) noexcept + { reset(pointer()); } + + /// Exchange the pointer and deleter with another object. + _GLIBCXX23_CONSTEXPR + void + swap(unique_ptr& __u) noexcept + { + static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); + _M_t.swap(__u._M_t); + } + + // Disable copy from lvalue. + unique_ptr(const unique_ptr&) = delete; + unique_ptr& operator=(const unique_ptr&) = delete; + }; + + /// @{ + /// @relates unique_ptr + + /// Swap overload for unique_ptr + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + _GLIBCXX23_CONSTEXPR + typename enable_if<__is_swappable<_Dp>::value>::type +#else + void +#endif + swap(unique_ptr<_Tp, _Dp>& __x, + unique_ptr<_Tp, _Dp>& __y) noexcept + { __x.swap(__y); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if::value>::type + swap(unique_ptr<_Tp, _Dp>&, + unique_ptr<_Tp, _Dp>&) = delete; +#endif + + /// Equality operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator==(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return __x.get() == __y.get(); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept + { return !__x; } + +#ifndef __cpp_lib_three_way_comparison + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD + inline bool + operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept + { return !__x; } + + /// Inequality operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return __x.get() != __y.get(); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD + inline bool + operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept + { return (bool)__x; } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD + inline bool + operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept + { return (bool)__x; } +#endif // three way comparison + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { + typedef typename + std::common_type::pointer, + typename unique_ptr<_Up, _Ep>::pointer>::type _CT; + return std::less<_CT>()(__x.get(), __y.get()); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + return std::less::pointer>()(__x.get(), + nullptr); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { + return std::less::pointer>()(nullptr, + __x.get()); + } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return !(__y < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { return !(nullptr < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { return !(__x < nullptr); } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator>(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return (__y < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + return std::less::pointer>()(nullptr, + __x.get()); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { + return std::less::pointer>()(__x.get(), + nullptr); + } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator>=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return !(__x < __y); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD _GLIBCXX23_CONSTEXPR + inline bool + operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { return !(__x < nullptr); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { return !(nullptr < __x); } + +#ifdef __cpp_lib_three_way_comparison + template + requires three_way_comparable_with::pointer, + typename unique_ptr<_Up, _Ep>::pointer> + _GLIBCXX23_CONSTEXPR + inline + compare_three_way_result_t::pointer, + typename unique_ptr<_Up, _Ep>::pointer> + operator<=>(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return compare_three_way()(__x.get(), __y.get()); } + + template + requires three_way_comparable::pointer> + _GLIBCXX23_CONSTEXPR + inline + compare_three_way_result_t::pointer> + operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + using pointer = typename unique_ptr<_Tp, _Dp>::pointer; + return compare_three_way()(__x.get(), static_cast(nullptr)); + } +#endif + /// @} relates unique_ptr + + /// @cond undocumented + template::__enable_hash_call> + struct __uniq_ptr_hash +#if ! _GLIBCXX_INLINE_VERSION + : private __poison_hash<_Ptr> +#endif + { + size_t + operator()(const _Up& __u) const + noexcept(noexcept(std::declval>()(std::declval<_Ptr>()))) + { return hash<_Ptr>()(__u.get()); } + }; + + template + struct __uniq_ptr_hash<_Up, _Ptr, false> + : private __poison_hash<_Ptr> + { }; + /// @endcond + + /// std::hash specialization for unique_ptr. + template + struct hash> + : public __hash_base>, + public __uniq_ptr_hash> + { }; + +#if __cplusplus >= 201402L +#define __cpp_lib_make_unique 201304L + + /// @cond undocumented +namespace __detail +{ + template + struct _MakeUniq + { typedef unique_ptr<_Tp> __single_object; }; + + template + struct _MakeUniq<_Tp[]> + { typedef unique_ptr<_Tp[]> __array; }; + + template + struct _MakeUniq<_Tp[_Bound]> + { struct __invalid_type { }; }; + + template + using __unique_ptr_t = typename _MakeUniq<_Tp>::__single_object; + template + using __unique_ptr_array_t = typename _MakeUniq<_Tp>::__array; + template + using __invalid_make_unique_t = typename _MakeUniq<_Tp>::__invalid_type; +} + /// @endcond + + /** Create an object owned by a `unique_ptr`. + * @tparam _Tp A non-array object type. + * @param __args Constructor arguments for the new object. + * @returns A `unique_ptr<_Tp>` that owns the new object. + * @since C++14 + * @relates unique_ptr + */ + template + _GLIBCXX23_CONSTEXPR + inline __detail::__unique_ptr_t<_Tp> + make_unique(_Args&&... __args) + { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } + + /** Create an array owned by a `unique_ptr`. + * @tparam _Tp An array type of unknown bound, such as `U[]`. + * @param __num The number of elements of type `U` in the new array. + * @returns A `unique_ptr` that owns the new array. + * @since C++14 + * @relates unique_ptr + * + * The array elements are value-initialized. + */ + template + _GLIBCXX23_CONSTEXPR + inline __detail::__unique_ptr_array_t<_Tp> + make_unique(size_t __num) + { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } + + /** Disable std::make_unique for arrays of known bound. + * @tparam _Tp An array type of known bound, such as `U[N]`. + * @since C++14 + * @relates unique_ptr + */ + template + __detail::__invalid_make_unique_t<_Tp> + make_unique(_Args&&...) = delete; + +#if __cplusplus > 201703L + /** Create a default-initialied object owned by a `unique_ptr`. + * @tparam _Tp A non-array object type. + * @returns A `unique_ptr<_Tp>` that owns the new object. + * @since C++20 + * @relates unique_ptr + */ + template + _GLIBCXX23_CONSTEXPR + inline __detail::__unique_ptr_t<_Tp> + make_unique_for_overwrite() + { return unique_ptr<_Tp>(new _Tp); } + + /** Create a default-initialized array owned by a `unique_ptr`. + * @tparam _Tp An array type of unknown bound, such as `U[]`. + * @param __num The number of elements of type `U` in the new array. + * @returns A `unique_ptr` that owns the new array. + * @since C++20 + * @relates unique_ptr + */ + template + _GLIBCXX23_CONSTEXPR + inline __detail::__unique_ptr_array_t<_Tp> + make_unique_for_overwrite(size_t __num) + { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]); } + + /** Disable std::make_unique_for_overwrite for arrays of known bound. + * @tparam _Tp An array type of known bound, such as `U[N]`. + * @since C++20 + * @relates unique_ptr + */ + template + __detail::__invalid_make_unique_t<_Tp> + make_unique_for_overwrite(_Args&&...) = delete; +#endif // C++20 + +#endif // C++14 + +#if __cplusplus > 201703L && __cpp_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2948. unique_ptr does not define operator<< for stream output + /// Stream output operator for unique_ptr + /// @relates unique_ptr + /// @since C++20 + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const unique_ptr<_Tp, _Dp>& __p) + requires requires { __os << __p.get(); } + { + __os << __p.get(); + return __os; + } +#endif // C++20 + + /// @} group pointer_abstractions + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // unique_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _UNIQUE_PTR_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..24758426de63d022f1c1de4381279ef77bf74f9c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unique_ptr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h new file mode 100644 index 0000000000000000000000000000000000000000..d5edfde8caf450845f36b035128645aecb1e57d2 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h @@ -0,0 +1,2215 @@ +// unordered_map implementation -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unordered_map.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_map} + */ + +#ifndef _UNORDERED_MAP_H +#define _UNORDERED_MAP_H + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// Base types for unordered_map. + template + using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>; + + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator >, + typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>> + using __umap_hashtable = _Hashtable<_Key, std::pair, + _Alloc, __detail::_Select1st, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + /// Base types for unordered_multimap. + template + using __ummap_traits = __detail::_Hashtable_traits<_Cache, false, false>; + + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator >, + typename _Tr = __ummap_traits<__cache_default<_Key, _Hash>::value>> + using __ummap_hashtable = _Hashtable<_Key, std::pair, + _Alloc, __detail::_Select1st, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + template + class unordered_multimap; + + /** + * @brief A standard container composed of unique keys (containing + * at most one of each key value) that associates values of another type + * with the keys. + * + * @ingroup unordered_associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to + * std::allocator>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * The resulting value type of the container is std::pair. + * + * Base is _Hashtable, dispatched at compile time via template + * alias __umap_hashtable. + */ + template, + typename _Pred = equal_to<_Key>, + typename _Alloc = allocator>> + class unordered_map + { + typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::mapped_type mapped_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; + using insert_return_type = typename _Hashtable::insert_return_type; +#endif + + //construct/destroy/copy + + /// Default constructor. + unordered_map() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_map(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_map consisting of copies of the elements from + * [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_map(const unordered_map&) = default; + + /// Move constructor. + unordered_map(unordered_map&&) = default; + + /** + * @brief Creates an %unordered_map with no elements. + * @param __a An allocator object. + */ + explicit + unordered_map(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_map to copy. + * @param __a An allocator object. + */ + unordered_map(const unordered_map& __umap, + const allocator_type& __a) + : _M_h(__umap._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_map to move. + * @param __a An allocator object. + */ + unordered_map(unordered_map&& __umap, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__umap._M_h), __a)) ) + : _M_h(std::move(__umap._M_h), __a) + { } + + /** + * @brief Builds an %unordered_map from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_map consisting of copies of the elements in the + * list. This is linear in N (where N is @a __l.size()). + */ + unordered_map(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) + { } + + unordered_map(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_map(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_map& + operator=(const unordered_map&) = default; + + /// Move assignment operator. + unordered_map& + operator=(unordered_map&&) = default; + + /** + * @brief %Unordered_map list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_map with copies of the elements in + * the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_map and + * that the resulting %unordered_map's size is the same as the number + * of elements assigned. + */ + unordered_map& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_map. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_map is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_map. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_map. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + /** + * Returns a read/write iterator that points to the first element in the + * %unordered_map. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_map. + */ + const_iterator + begin() const noexcept + { return _M_h.begin(); } + + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + ///@} + + /** + * Returns a read/write iterator that points one past the last element in + * the %unordered_map. + */ + iterator + end() noexcept + { return _M_h.end(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_map. + */ + const_iterator + end() const noexcept + { return _M_h.end(); } + + const_iterator + cend() const noexcept + { return _M_h.end(); } + ///@} + + // modifiers. + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_map. + * An %unordered_map relies on unique keys and thus a %pair is only + * inserted if its first element (the key) is not already present in the + * %unordered_map. + * + * Insertion requires amortized constant time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator, node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)).position; } + +#define __cpp_lib_unordered_map_try_emplace 201411L + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __args Arguments used to generate the .second for a + * new pair instance. + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_map. + * An %unordered_map relies on unique keys and thus a %pair is only + * inserted if its first element (the key) is not already present in the + * %unordered_map. + * If a %pair is not inserted, this function has no effect. + * + * Insertion requires amortized constant time. + */ + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + return _M_h.try_emplace(cend(), __k, std::forward<_Args>(__args)...); + } + + // move-capable overload + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + return _M_h.try_emplace(cend(), std::move(__k), + std::forward<_Args>(__args)...); + } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __hint An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __args Arguments used to generate the .second for a + * new pair instance. + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. However, if insertion did not take place, + * this function has no effect. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + return _M_h.try_emplace(__hint, __k, + std::forward<_Args>(__args)...).first; + } + + // move-capable overload + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + return _M_h.try_emplace(__hint, std::move(__k), + std::forward<_Args>(__args)...).first; + } +#endif // C++17 + + ///@{ + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the + * %unordered_map. An %unordered_map relies on unique keys and thus a + * %pair is only inserted if its first element (the key) is not already + * present in the %unordered_map. + * + * Insertion requires amortized constant time. + */ + std::pair + insert(const value_type& __x) + { return _M_h.insert(__x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + + template + __enable_if_t::value, + pair> + insert(_Pair&& __x) + { return _M_h.emplace(std::forward<_Pair>(__x)); } + ///@} + + ///@{ + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __hint, _Pair&& __x) + { return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the %unordered_map. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + + +#if __cplusplus > 201402L + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the + * %unordered_map. An %unordered_map relies on unique keys and thus a + * %pair is only inserted if its first element (the key) is not already + * present in the %unordered_map. + * If the %pair was already in the %unordered_map, the .second of + * the %pair is assigned from __obj. + * + * Insertion requires amortized constant time. + */ + template + pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(cend(), __k, + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret; + } + + // move-capable overload + template + pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(cend(), std::move(__k), + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret; + } + + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. + * If the %pair was already in the %unordered map, the .second of + * the %pair is assigned from __obj. + * Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + insert_or_assign(const_iterator __hint, const key_type& __k, + _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(__hint, __k, std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret.first; + } + + // move-capable overload + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(__hint, std::move(__k), + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret.first; + } +#endif + + ///@{ + /** + * @brief Erases an element from an %unordered_map. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_map. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_map. For an %unordered_map the result of this function + * can only be 0 (not present) or 1 (present). + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an %unordered_map. + * Note that this function only erases the elements, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_map. + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_map. + * @param __x An %unordered_map of the same element and allocator + * types. + * + * This exchanges the elements between two %unordered_map in constant + * time. + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + */ + void + swap(unordered_map& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_map was + /// constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_map was + /// constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_map. + * @param __x Key to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Key to count. + * @return Number of elements with specified key. + * + * This function only makes sense for %unordered_multimap; for + * %unordered_map the result will either be 0 (not present) or 1 + * (present). + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function probably only makes sense for %unordered_multimap. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Subscript ( @c [] ) access to %unordered_map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data of the (key,data) %pair. + * + * Allows for easy lookup with the subscript ( @c [] )operator. Returns + * data associated with the key specified in subscript. If the key does + * not exist, a pair with that key is created using default values, which + * is then returned. + * + * Lookup requires constant time. + */ + mapped_type& + operator[](const key_type& __k) + { return _M_h[__k]; } + + mapped_type& + operator[](key_type&& __k) + { return _M_h[std::move(__k)]; } + ///@} + + ///@{ + /** + * @brief Access to %unordered_map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data whose key is equal to @a __k, if + * such a data is present in the %unordered_map. + * @throw std::out_of_range If no such data is present. + */ + mapped_type& + at(const key_type& __k) + { return _M_h.at(__k); } + + const mapped_type& + at(const key_type& __k) const + { return _M_h.at(__k); } + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_map. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_map. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + /** + * @brief Returns a read/write iterator pointing to the first bucket + * element. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + /** + * @brief Returns a read/write iterator pointing to one past the last + * bucket elements. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_map tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_map maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_map. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_map maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_map for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, + const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + /** + * @brief A standard container composed of equivalent keys + * (possibly containing multiple of each key value) that associates + * values of another type with the keys. + * + * @ingroup unordered_associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to + * std::allocator>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * The resulting value type of the container is std::pair. + * + * Base is _Hashtable, dispatched at compile time via template + * alias __ummap_hashtable. + */ + template, + typename _Pred = equal_to<_Key>, + typename _Alloc = allocator>> + class unordered_multimap + { + typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::mapped_type mapped_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; +#endif + + //construct/destroy/copy + + /// Default constructor. + unordered_multimap() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Mnimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_multimap(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multimap consisting of copies of the elements + * from [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_multimap(const unordered_multimap&) = default; + + /// Move constructor. + unordered_multimap(unordered_multimap&&) = default; + + /** + * @brief Creates an %unordered_multimap with no elements. + * @param __a An allocator object. + */ + explicit + unordered_multimap(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_multimap to copy. + * @param __a An allocator object. + */ + unordered_multimap(const unordered_multimap& __ummap, + const allocator_type& __a) + : _M_h(__ummap._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_multimap to move. + * @param __a An allocator object. + */ + unordered_multimap(unordered_multimap&& __ummap, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__ummap._M_h), __a)) ) + : _M_h(std::move(__ummap._M_h), __a) + { } + + /** + * @brief Builds an %unordered_multimap from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multimap consisting of copies of the elements in + * the list. This is linear in N (where N is @a __l.size()). + */ + unordered_multimap(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) + { } + + unordered_multimap(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_multimap& + operator=(const unordered_multimap&) = default; + + /// Move assignment operator. + unordered_multimap& + operator=(unordered_multimap&&) = default; + + /** + * @brief %Unordered_multimap list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_multimap with copies of the + * elements in the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_multimap + * and that the resulting %unordered_multimap's size is the same as the + * number of elements assigned. + */ + unordered_multimap& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_multimap. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_multimap is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_multimap. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_multimap. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + /** + * Returns a read/write iterator that points to the first element in the + * %unordered_multimap. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multimap. + */ + const_iterator + begin() const noexcept + { return _M_h.begin(); } + + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + ///@} + + /** + * Returns a read/write iterator that points one past the last element in + * the %unordered_multimap. + */ + iterator + end() noexcept + { return _M_h.end(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multimap. + */ + const_iterator + end() const noexcept + { return _M_h.end(); } + + const_iterator + cend() const noexcept + { return _M_h.end(); } + ///@} + + // modifiers. + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_multimap. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return An iterator that points to the inserted pair. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_multimap. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_multimap. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Inserts a std::pair into the %unordered_multimap. + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return An iterator that points to the inserted pair. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const value_type& __x) + { return _M_h.insert(__x); } + + iterator + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(_Pair&& __x) + { return _M_h.emplace(std::forward<_Pair>(__x)); } + ///@} + + ///@{ + /** + * @brief Inserts a std::pair into the %unordered_multimap. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __hint, _Pair&& __x) + { return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the + * %unordered_multimap. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_multimap. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_multimap. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of elements to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_multimap. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an + * %unordered_multimap. + * Note that this function only erases the elements, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_multimap. + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_multimap. + * @param __x An %unordered_multimap of the same element and allocator + * types. + * + * This exchanges the elements between two %unordered_multimap in + * constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + */ + void + swap(unordered_multimap& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_multimap + /// was constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_multimap + /// was constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_multimap. + * @param __x Key to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Key to count. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_multimap. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_multimap. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + /** + * @brief Returns a read/write iterator pointing to the first bucket + * element. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + /** + * @brief Returns a read/write iterator pointing to one past the last + * bucket elements. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_multimap tries to keep + /// the load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_multimap maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_multimap. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_multimap maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_multimap for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_multimap<_Key1, _Tp1, + _Hash1, _Pred1, _Alloc1>&, + const unordered_multimap<_Key1, _Tp1, + _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, _Pred, + _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Hash, + _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Hash, _Allocator) + -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + template + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + template + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::unordered_map access to internals of compatible maps. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>; + template + using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>; + + friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + + static auto& + _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + }; + + // Allow std::unordered_multimap access to internals of compatible maps. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>; + template + using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>; + + friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + + static auto& + _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _UNORDERED_MAP_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..821f7160543bd9feb7f062dc60bd012ea6a0b2d7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_map.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h new file mode 100644 index 0000000000000000000000000000000000000000..d2fa2c511712e0afc4b031efbc21344e768e1c10 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h @@ -0,0 +1,1884 @@ +// unordered_set implementation -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unordered_set.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_set} + */ + +#ifndef _UNORDERED_SET_H +#define _UNORDERED_SET_H + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// Base types for unordered_set. + template + using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>; + + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value>, + typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>> + using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc, + __detail::_Identity, _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + /// Base types for unordered_multiset. + template + using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>; + + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value>, + typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>> + using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc, + __detail::_Identity, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + template + class unordered_multiset; + + /** + * @brief A standard container composed of unique keys (containing + * at most one of each key value) in which the elements' keys are + * the elements themselves. + * + * @ingroup unordered_associative_containers + * + * @tparam _Value Type of key objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + + * @tparam _Pred Predicate function object type, defaults to + * equal_to<_Value>. + * + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * Base is _Hashtable, dispatched at compile time via template + * alias __uset_hashtable. + */ + template, + typename _Pred = equal_to<_Value>, + typename _Alloc = allocator<_Value>> + class unordered_set + { + typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; + using insert_return_type = typename _Hashtable::insert_return_type; +#endif + + // construct/destroy/copy + + /// Default constructor. + unordered_set() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_set(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_set consisting of copies of the elements from + * [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_set(const unordered_set&) = default; + + /// Move constructor. + unordered_set(unordered_set&&) = default; + + /** + * @brief Creates an %unordered_set with no elements. + * @param __a An allocator object. + */ + explicit + unordered_set(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_set to copy. + * @param __a An allocator object. + */ + unordered_set(const unordered_set& __uset, + const allocator_type& __a) + : _M_h(__uset._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_set to move. + * @param __a An allocator object. + */ + unordered_set(unordered_set&& __uset, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__uset._M_h), __a)) ) + : _M_h(std::move(__uset._M_h), __a) + { } + + /** + * @brief Builds an %unordered_set from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_set consisting of copies of the elements in the + * list. This is linear in N (where N is @a __l.size()). + */ + unordered_set(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) + { } + + unordered_set(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_set(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_set& + operator=(const unordered_set&) = default; + + /// Move assignment operator. + unordered_set& + operator=(unordered_set&&) = default; + + /** + * @brief %Unordered_set list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_set with copies of the elements in + * the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_set and + * that the resulting %unordered_set's size is the same as the number + * of elements assigned. + */ + unordered_set& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_set. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_set is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_set. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_set. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_set. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + const_iterator + begin() const noexcept + { return _M_h.begin(); } + ///@} + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_set. + */ + iterator + end() noexcept + { return _M_h.end(); } + + const_iterator + end() const noexcept + { return _M_h.end(); } + ///@} + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_set. + */ + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_set. + */ + const_iterator + cend() const noexcept + { return _M_h.end(); } + + // modifiers. + + /** + * @brief Attempts to build and insert an element into the + * %unordered_set. + * @param __args Arguments used to generate an element. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to build and insert an element into the + * %unordered_set. An %unordered_set relies on unique keys and thus an + * element is only inserted if it is not already present in the + * %unordered_set. + * + * Insertion requires amortized constant time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the element with key equivalent to + * the one generated from @a __args (may or may not be the + * element itself). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __x Element to be inserted. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to insert an element into the %unordered_set. + * An %unordered_set relies on unique keys and thus an element is only + * inserted if it is not already present in the %unordered_set. + * + * Insertion requires amortized constant time. + */ + std::pair + insert(const value_type& __x) + { return _M_h.insert(__x); } + + std::pair + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + ///@} + + ///@{ + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __hint An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the element passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the %unordered_set. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator, node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)).position; } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_set. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_set. Note that this function only erases the + * element, and that if the element is itself a pointer, the pointed-to + * memory is not touched in any way. Managing the pointer is the user's + * responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_set. For an %unordered_set the result of this function + * can only be 0 (not present) or 1 (present). + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_set. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an %unordered_set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_set. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_set. + * @param __x An %unordered_set of the same element and allocator + * types. + * + * This exchanges the elements between two sets in constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + */ + void + swap(unordered_set& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_set was + /// constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_set was + /// constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __k) + -> decltype(_M_h._M_find_tr(__k)) + { return _M_h._M_find_tr(__k); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __k) const + -> decltype(_M_h._M_find_tr(__k)) + { return _M_h._M_find_tr(__k); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + * + * This function only makes sense for unordered_multisets; for + * unordered_set the result will either be 0 (not present) or 1 + * (present). + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __k) const + -> decltype(_M_h._M_count_tr(__k)) + { return _M_h._M_count_tr(__k); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __k) const + -> decltype(_M_h._M_find_tr(__k), void(), true) + { return _M_h._M_find_tr(__k) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __k) + -> decltype(_M_h._M_equal_range_tr(__k)) + { return _M_h._M_equal_range_tr(__k); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __k) const + -> decltype(_M_h._M_equal_range_tr(__k)) + { return _M_h._M_equal_range_tr(__k); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_set. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_set. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_set tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_set maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_set. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_set maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_set for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&, + const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, _Allocator) + -> unordered_set::value_type, + hash< + typename iterator_traits<_InputIterator>::value_type>, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, + _Hash, _Allocator) + -> unordered_set::value_type, + _Hash, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Allocator) + -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Hash, _Allocator) + -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + /** + * @brief A standard container composed of equivalent keys + * (possibly containing multiple of each key value) in which the + * elements' keys are the elements themselves. + * + * @ingroup unordered_associative_containers + * + * @tparam _Value Type of key objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * Base is _Hashtable, dispatched at compile time via template + * alias __umset_hashtable. + */ + template, + typename _Pred = equal_to<_Value>, + typename _Alloc = allocator<_Value>> + class unordered_multiset + { + typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; +#endif + + // construct/destroy/copy + + /// Default constructor. + unordered_multiset() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_multiset(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multiset consisting of copies of the elements + * from [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_multiset(const unordered_multiset&) = default; + + /// Move constructor. + unordered_multiset(unordered_multiset&&) = default; + + /** + * @brief Builds an %unordered_multiset from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multiset consisting of copies of the elements in + * the list. This is linear in N (where N is @a __l.size()). + */ + unordered_multiset(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + /// Copy assignment operator. + unordered_multiset& + operator=(const unordered_multiset&) = default; + + /// Move assignment operator. + unordered_multiset& + operator=(unordered_multiset&&) = default; + + /** + * @brief Creates an %unordered_multiset with no elements. + * @param __a An allocator object. + */ + explicit + unordered_multiset(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_multiset to copy. + * @param __a An allocator object. + */ + unordered_multiset(const unordered_multiset& __umset, + const allocator_type& __a) + : _M_h(__umset._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __umset Input %unordered_multiset to move. + * @param __a An allocator object. + */ + unordered_multiset(unordered_multiset&& __umset, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__umset._M_h), __a)) ) + : _M_h(std::move(__umset._M_h), __a) + { } + + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) + { } + + unordered_multiset(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__l, __n, __hf, key_equal(), __a) + { } + + /** + * @brief %Unordered_multiset list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_multiset with copies of the elements + * in the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_multiset + * and that the resulting %unordered_multiset's size is the same as the + * number of elements assigned. + */ + unordered_multiset& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_multiset. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_multiset is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_multiset. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_multiset. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multiset. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + const_iterator + begin() const noexcept + { return _M_h.begin(); } + ///@} + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multiset. + */ + iterator + end() noexcept + { return _M_h.end(); } + + const_iterator + end() const noexcept + { return _M_h.end(); } + ///@} + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multiset. + */ + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multiset. + */ + const_iterator + cend() const noexcept + { return _M_h.end(); } + + // modifiers. + + /** + * @brief Builds and insert an element into the %unordered_multiset. + * @param __args Arguments used to generate an element. + * @return An iterator that points to the inserted element. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the inserted element. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const value_type& __x) + { return _M_h.insert(__x); } + + iterator + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + ///@} + + ///@{ + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __hint An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + ///@} + + /** + * @brief A template function that inserts a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Inserts a list of elements into the %unordered_multiset. + * @param __l A std::initializer_list of elements to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_multiset. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_multiset. + * + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_multiset. + * + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_multiset. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an + * %unordered_multiset. + * + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_multiset. + * + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_multiset. + * @param __x An %unordered_multiset of the same element and allocator + * types. + * + * This exchanges the elements between two sets in constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + */ + void + swap(unordered_multiset& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_multiset + /// was constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_multiset + /// was constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_multiset. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) + -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_multiset. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_multiset. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_multiset tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_multiset maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_multiset. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_multiset maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_multiset for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&, + const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&); + }; + + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset::value_type, + hash::value_type>, + equal_to::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, + _Hash, _Allocator) + -> unordered_multiset::value_type, + _Hash, + equal_to< + typename + iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Hash, _Allocator) + -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + template + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + template + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::unordered_set access to internals of compatible sets. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2> + { + private: + template + using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; + template + using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; + + friend unordered_set<_Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + + static auto& + _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + }; + + // Allow std::unordered_multiset access to internals of compatible sets. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; + template + using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; + + friend unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + + static auto& + _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _UNORDERED_SET_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..070e70a19fee5d6a6171f14db5c0c54309772463 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@unordered_set.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..d3bf5e0f3b9fe16ffb14668078c196b9c2de6006 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h @@ -0,0 +1,197 @@ +// Uses-allocator Construction -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +#ifndef _USES_ALLOCATOR_H +#define _USES_ALLOCATOR_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +/// @cond undocumented + + // This is used for std::experimental::erased_type from Library Fundamentals. + struct __erased_type { }; + + // This also supports the "type-erased allocator" protocol from the + // Library Fundamentals TS, where allocator_type is erased_type. + // The second condition will always be false for types not using the TS. + template + using __is_erased_or_convertible + = __or_, is_same<_Tp, __erased_type>>; + + /// [allocator.tag] + struct allocator_arg_t { explicit allocator_arg_t() = default; }; + + _GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg = + allocator_arg_t(); + + template> + struct __uses_allocator_helper + : false_type { }; + + template + struct __uses_allocator_helper<_Tp, _Alloc, + __void_t> + : __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type + { }; + + /// [allocator.uses.trait] + template + struct uses_allocator + : __uses_allocator_helper<_Tp, _Alloc>::type + { }; + + struct __uses_alloc_base { }; + + struct __uses_alloc0 : __uses_alloc_base + { + struct _Sink { void _GLIBCXX20_CONSTEXPR operator=(const void*) { } } _M_a; + }; + + template + struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; }; + + template + struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; }; + + template + struct __uses_alloc; + + template + struct __uses_alloc + : __conditional_t< + is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value, + __uses_alloc1<_Alloc>, + __uses_alloc2<_Alloc>> + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2586. Wrong value category used in scoped_allocator_adaptor::construct + static_assert(__or_< + is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>, + is_constructible<_Tp, _Args..., const _Alloc&>>::value, + "construction with an allocator must be possible" + " if uses_allocator is true"); + }; + + template + struct __uses_alloc + : __uses_alloc0 { }; + + template + using __uses_alloc_t = + __uses_alloc::value, _Tp, _Alloc, _Args...>; + + template + _GLIBCXX20_CONSTEXPR + inline __uses_alloc_t<_Tp, _Alloc, _Args...> + __use_alloc(const _Alloc& __a) + { + __uses_alloc_t<_Tp, _Alloc, _Args...> __ret; + __ret._M_a = std::__addressof(__a); + return __ret; + } + + template + void + __use_alloc(const _Alloc&&) = delete; + +#if __cplusplus > 201402L + template + inline constexpr bool uses_allocator_v = + uses_allocator<_Tp, _Alloc>::value; +#endif // C++17 + + template class _Predicate, + typename _Tp, typename _Alloc, typename... _Args> + struct __is_uses_allocator_predicate + : __conditional_t::value, + __or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>, + _Predicate<_Tp, _Args..., _Alloc>>, + _Predicate<_Tp, _Args...>> { }; + + template + struct __is_uses_allocator_constructible + : __is_uses_allocator_predicate + { }; + +#if __cplusplus >= 201402L + template + _GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v = + __is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; +#endif // C++14 + + template + struct __is_nothrow_uses_allocator_constructible + : __is_uses_allocator_predicate + { }; + + +#if __cplusplus >= 201402L + template + _GLIBCXX17_INLINE constexpr bool + __is_nothrow_uses_allocator_constructible_v = + __is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; +#endif // C++14 + + template + void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr, + _Args&&... __args) + { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); } + + template + void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr, + _Args&&... __args) + { + ::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a, + std::forward<_Args>(__args)...); + } + + template + void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr, + _Args&&... __args) + { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); } + + template + void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr, + _Args&&... __args) + { + std::__uses_allocator_construct_impl( + std::__use_alloc<_Tp, _Alloc, _Args...>(__a), __ptr, + std::forward<_Args>(__args)...); + } + +/// @endcond +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e2dedea2f97db90d7a25503b533b83e98205ef4c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@uses_allocator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h new file mode 100644 index 0000000000000000000000000000000000000000..e0e40309a6d7a690ca8c49be339d06f3801ff4e9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h @@ -0,0 +1,270 @@ +// Utilities used throughout the library -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/utility.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + * + * This file contains the parts of `` needed by other headers, + * so they don't need to include the whole of ``. + */ + +#ifndef _GLIBCXX_UTILITY_H +#define _GLIBCXX_UTILITY_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Finds the size of a given tuple type. + template + struct tuple_size; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2313. tuple_size should always derive from integral_constant + // 2770. tuple_size specialization is not SFINAE compatible + + template::type, + typename = typename enable_if::value>::type, + size_t = tuple_size<_Tp>::value> + using __enable_if_has_tuple_size = _Tp; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + +#if __cplusplus >= 201703L + template + inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; +#endif + + /// Gives the type of the ith element of a given tuple type. + template + struct tuple_element; + + // Duplicate of C++14's tuple_element_t for internal use in C++11 mode + template + using __tuple_element_t = typename tuple_element<__i, _Tp>::type; + + template + struct tuple_element<__i, const _Tp> + { + typedef typename add_const<__tuple_element_t<__i, _Tp>>::type type; + }; + + template + struct tuple_element<__i, volatile _Tp> + { + typedef typename add_volatile<__tuple_element_t<__i, _Tp>>::type type; + }; + + template + struct tuple_element<__i, const volatile _Tp> + { + typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type; + }; + +#if __cplusplus >= 201402L + + // Return the index of _Tp in _Types, if it occurs exactly once. + // Otherwise, return sizeof...(_Types). + template + constexpr size_t + __find_uniq_type_in_pack() + { + constexpr size_t __sz = sizeof...(_Types); + constexpr bool __found[__sz] = { __is_same(_Tp, _Types) ... }; + size_t __n = __sz; + for (size_t __i = 0; __i < __sz; ++__i) + { + if (__found[__i]) + { + if (__n < __sz) // more than one _Tp found + return __sz; + __n = __i; + } + } + return __n; + } + +// The standard says this macro and alias template should be in but we +// define them here, to be available in , and too. +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// 3378. tuple_size_v/tuple_element_t should be available when +// tuple_size/tuple_element are +#define __cpp_lib_tuple_element_t 201402L + + template + using tuple_element_t = typename tuple_element<__i, _Tp>::type; +#endif // C++14 + + // Stores a tuple of indices. Used by tuple and pair, and by bind() to + // extract the elements in a tuple. + template struct _Index_tuple { }; + + // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. + template + struct _Build_index_tuple + { +#if __has_builtin(__make_integer_seq) + template + using _IdxTuple = _Index_tuple<_Indices...>; + + // Clang defines __make_integer_seq for this purpose. + using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; +#else + // For GCC and other compilers, use __integer_pack instead. + using __type = _Index_tuple<__integer_pack(_Num)...>; +#endif + }; + +#if __cplusplus >= 201402L + +#define __cpp_lib_integer_sequence 201304L + + /// Class template integer_sequence + template + struct integer_sequence + { + typedef _Tp value_type; + static constexpr size_t size() noexcept { return sizeof...(_Idx); } + }; + + /// Alias template make_integer_sequence + template + using make_integer_sequence +#if __has_builtin(__make_integer_seq) + = __make_integer_seq; +#else + = integer_sequence<_Tp, __integer_pack(_Num)...>; +#endif + + /// Alias template index_sequence + template + using index_sequence = integer_sequence; + + /// Alias template make_index_sequence + template + using make_index_sequence = make_integer_sequence; + + /// Alias template index_sequence_for + template + using index_sequence_for = make_index_sequence; + +#if __cplusplus >= 201703L + + struct in_place_t { + explicit in_place_t() = default; + }; + + inline constexpr in_place_t in_place{}; + + template struct in_place_type_t + { + explicit in_place_type_t() = default; + }; + + template + inline constexpr in_place_type_t<_Tp> in_place_type{}; + + template struct in_place_index_t + { + explicit in_place_index_t() = default; + }; + + template + inline constexpr in_place_index_t<_Idx> in_place_index{}; + + template + inline constexpr bool __is_in_place_type_v = false; + + template + inline constexpr bool __is_in_place_type_v> = true; + + template + using __is_in_place_type = bool_constant<__is_in_place_type_v<_Tp>>; + +#endif // C++17 +#endif // C++14 + + template + struct _Nth_type + { }; + + template + struct _Nth_type<0, _Tp0, _Rest...> + { using type = _Tp0; }; + + template + struct _Nth_type<1, _Tp0, _Tp1, _Rest...> + { using type = _Tp1; }; + + template + struct _Nth_type<2, _Tp0, _Tp1, _Tp2, _Rest...> + { using type = _Tp2; }; + + template +#if __cpp_concepts + requires (_Np >= 3) +#endif + struct _Nth_type<_Np, _Tp0, _Tp1, _Tp2, _Rest...> + : _Nth_type<_Np - 3, _Rest...> + { }; + +#if ! __cpp_concepts // Need additional specializations to avoid ambiguities. + template + struct _Nth_type<0, _Tp0, _Tp1, _Rest...> + { using type = _Tp0; }; + + template + struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...> + { using type = _Tp0; }; + + template + struct _Nth_type<1, _Tp0, _Tp1, _Tp2, _Rest...> + { using type = _Tp1; }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif /* _GLIBCXX_UTILITY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d69232dcfae704c8f56bea2e591cf75e880a7c9d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@utility.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h new file mode 100644 index 0000000000000000000000000000000000000000..3c4afc231d385eff87ac2757137ea65b07a0b95a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h @@ -0,0 +1,556 @@ +// The template and inlines for the -*- C++ -*- internal _Meta class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_after.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_AFTER_H +#define _VALARRAY_AFTER_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + // + // gslice_array closure. + // + template + class _GBase + { + public: + typedef typename _Dom::value_type value_type; + + _GBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const valarray& _M_index; + }; + + template + class _GBase<_Array<_Tp> > + { + public: + typedef _Tp value_type; + + _GBase (_Array<_Tp> __a, const valarray& __i) + : _M_array (__a), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } + + private: + const _Array<_Tp> _M_array; + const valarray& _M_index; + }; + + template + struct _GClos<_Expr, _Dom> + : _GBase<_Dom> + { + typedef _GBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _GClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} + }; + + template + struct _GClos<_ValArray, _Tp> + : _GBase<_Array<_Tp> > + { + typedef _GBase<_Array<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _GClos (_Array<_Tp> __a, const valarray& __i) + : _Base (__a, __i) {} + }; + + // + // indirect_array closure + // + template + class _IBase + { + public: + typedef typename _Dom::value_type value_type; + + _IBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index (__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size() const + { return _M_index.size(); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const valarray& _M_index; + }; + + template + struct _IClos<_Expr, _Dom> + : _IBase<_Dom> + { + typedef _IBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _IClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} + }; + + template + struct _IClos<_ValArray, _Tp> + : _IBase > + { + typedef _IBase > _Base; + typedef _Tp value_type; + + _IClos (const valarray<_Tp>& __a, const valarray& __i) + : _Base (__a, __i) {} + }; +} // namespace __detail + + // + // class _Expr + // + template + class _Expr + { + public: + typedef _Tp value_type; + + _Expr(const _Clos&); + + const _Clos& operator()() const; + + value_type operator[](size_t) const; + valarray operator[](slice) const; + valarray operator[](const gslice&) const; + valarray operator[](const valarray&) const; + valarray operator[](const valarray&) const; + + _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type> + operator+() const; + + _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type> + operator-() const; + + _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type> + operator~() const; + + _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool> + operator!() const; + + size_t size() const; + value_type sum() const; + + valarray shift(int) const; + valarray cshift(int) const; + + value_type min() const; + value_type max() const; + + valarray apply(value_type (*)(const value_type&)) const; + valarray apply(value_type (*)(value_type)) const; + + private: + const _Clos _M_closure; + }; + + template + inline + _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} + + template + inline const _Clos& + _Expr<_Clos, _Tp>::operator()() const + { return _M_closure; } + + template + inline _Tp + _Expr<_Clos, _Tp>::operator[](size_t __i) const + { return _M_closure[__i]; } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](slice __s) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__s]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__gs]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const valarray& __m) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__m]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const valarray& __i) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__i]; + return __v; + } + + template + inline size_t + _Expr<_Clos, _Tp>::size() const + { return _M_closure.size(); } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::shift(int __n) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::cshift(int __n) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } + + // XXX: replace this with a more robust summation algorithm. + template + inline _Tp + _Expr<_Clos, _Tp>::sum() const + { + size_t __n = _M_closure.size(); + if (__n == 0) + return _Tp(); + else + { + _Tp __s = _M_closure[--__n]; + while (__n != 0) + __s += _M_closure[--__n]; + return __s; + } + } + + template + inline _Tp + _Expr<_Clos, _Tp>::min() const + { return __valarray_min(_M_closure); } + + template + inline _Tp + _Expr<_Clos, _Tp>::max() const + { return __valarray_max(_M_closure); } + + template + inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool> + _Expr<_Dom, _Tp>::operator!() const + { + typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure; + return _Expr<_Closure, bool>(_Closure(this->_M_closure)); + } + +#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ + template \ + inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \ + _Expr<_Dom, _Tp>::operator _Op() const \ + { \ + typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \ + } + + _DEFINE_EXPR_UNARY_OPERATOR(+, struct std::__unary_plus) + _DEFINE_EXPR_UNARY_OPERATOR(-, struct std::__negate) + _DEFINE_EXPR_UNARY_OPERATOR(~, struct std::__bitwise_not) + +#undef _DEFINE_EXPR_UNARY_OPERATOR + +#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \ + typename __fun<_Name, typename _Dom1::value_type>::result_type> \ + operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __w) \ + { \ + typedef typename _Dom1::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \ + const typename _Dom::value_type& __t) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__t, __v())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _ValArray, \ + _Dom, typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ + const valarray& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const valarray& __v, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef typename __fun<_Name, _Tp>::result_type _Value; \ + typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \ + } + + _DEFINE_EXPR_BINARY_OPERATOR(+, struct std::__plus) + _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) + _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) + _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) + _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) + _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor) + _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) + _DEFINE_EXPR_BINARY_OPERATOR(|, struct std::__bitwise_or) + _DEFINE_EXPR_BINARY_OPERATOR(<<, struct std::__shift_left) + _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right) + _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) + _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or) + _DEFINE_EXPR_BINARY_OPERATOR(==, struct std::__equal_to) + _DEFINE_EXPR_BINARY_OPERATOR(!=, struct std::__not_equal_to) + _DEFINE_EXPR_BINARY_OPERATOR(<, struct std::__less) + _DEFINE_EXPR_BINARY_OPERATOR(>, struct std::__greater) + _DEFINE_EXPR_BINARY_OPERATOR(<=, struct std::__less_equal) + _DEFINE_EXPR_BINARY_OPERATOR(>=, struct std::__greater_equal) + +#undef _DEFINE_EXPR_BINARY_OPERATOR + +#define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName) \ + template \ + inline _Expr<_UnClos<_UName, _Expr, _Dom>, \ + typename _Dom::value_type> \ + _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _UnClos<_UName, _Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e())); \ + } \ + \ + template \ + inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp> \ + _Name(const valarray<_Tp>& __v) \ + { \ + typedef _UnClos<_UName, _ValArray, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v)); \ + } + + _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) + _DEFINE_EXPR_UNARY_FUNCTION(cos, struct std::_Cos) + _DEFINE_EXPR_UNARY_FUNCTION(acos, struct std::_Acos) + _DEFINE_EXPR_UNARY_FUNCTION(cosh, struct std::_Cosh) + _DEFINE_EXPR_UNARY_FUNCTION(sin, struct std::_Sin) + _DEFINE_EXPR_UNARY_FUNCTION(asin, struct std::_Asin) + _DEFINE_EXPR_UNARY_FUNCTION(sinh, struct std::_Sinh) + _DEFINE_EXPR_UNARY_FUNCTION(tan, struct std::_Tan) + _DEFINE_EXPR_UNARY_FUNCTION(tanh, struct std::_Tanh) + _DEFINE_EXPR_UNARY_FUNCTION(atan, struct std::_Atan) + _DEFINE_EXPR_UNARY_FUNCTION(exp, struct std::_Exp) + _DEFINE_EXPR_UNARY_FUNCTION(log, struct std::_Log) + _DEFINE_EXPR_UNARY_FUNCTION(log10, struct std::_Log10) + _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt) + +#undef _DEFINE_EXPR_UNARY_FUNCTION + +#define _DEFINE_EXPR_BINARY_FUNCTION(_Fun, _UFun) \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2>, \ + typename _Dom1::value_type> \ + _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \ + { \ + typedef typename _Dom1::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _ValArray, _Dom, \ + typename _Dom::value_type>, \ + typename _Dom::value_type> \ + _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ + const valarray& __v) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _ValArray, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename _Dom::value_type> \ + _Fun(const valarray& __v, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + typename _Dom::value_type> \ + _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ + const typename _Dom::value_type& __t) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _Constant, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename _Dom::value_type> \ + _Fun(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Constant, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \ + _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ + { \ + typedef _BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \ + _Fun(const valarray<_Tp>& __v, \ + const typename valarray<_Tp>::value_type& __t) \ + { \ + typedef _BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \ + _Fun(const typename valarray<_Tp>::value_type& __t, \ + const valarray<_Tp>& __v) \ + { \ + typedef _BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ + } + +_DEFINE_EXPR_BINARY_FUNCTION(atan2, struct std::_Atan2) +_DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow) + +#undef _DEFINE_EXPR_BINARY_FUNCTION + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _CPP_VALARRAY_AFTER_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..e84b23dee51847a98dfed87f9aabef439b65b0f7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_after.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h new file mode 100644 index 0000000000000000000000000000000000000000..3601dcf61e460ec5beb0f3e52e2b7c663b382c1c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h @@ -0,0 +1,677 @@ +// The template and inlines for the -*- C++ -*- internal _Array helper class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_ARRAY_H +#define _VALARRAY_ARRAY_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // + // Helper functions on raw pointers + // + + // We get memory the old fashioned way + template + _Tp* + __valarray_get_storage(size_t) __attribute__((__malloc__)); + + template + inline _Tp* + __valarray_get_storage(size_t __n) + { return static_cast<_Tp*>(operator new(__n * sizeof(_Tp))); } + + // Return memory to the system + inline void + __valarray_release_memory(void* __p) + { operator delete(__p); } + + // Turn a raw-memory into an array of _Tp filled with _Tp() + // This is required in 'valarray v(n);' + template + struct _Array_default_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __b, _Tp* __e) + { + while (__b != __e) + new(__b++) _Tp(); + } + }; + + template + struct _Array_default_ctor<_Tp, true> + { + // For fundamental types, it suffices to say 'memset()' + inline static void + _S_do_it(_Tp* __b, _Tp* __e) + { __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); } + }; + + template + inline void + __valarray_default_construct(_Tp* __b, _Tp* __e) + { + _Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e); + } + + // Turn a raw-memory into an array of _Tp filled with __t + // This is the required in valarray v(n, t). Also + // used in valarray<>::resize(). + template + struct _Array_init_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t) + { + while (__b != __e) + new(__b++) _Tp(__t); + } + }; + + template + struct _Array_init_ctor<_Tp, true> + { + inline static void + _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t) + { + while (__b != __e) + *__b++ = __t; + } + }; + + template + inline void + __valarray_fill_construct(_Tp* __b, _Tp* __e, const _Tp __t) + { + _Array_init_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __t); + } + + // + // copy-construct raw array [__o, *) from plain array [__b, __e) + // We can't just say 'memcpy()' + // + template + struct _Array_copy_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o) + { + while (__b != __e) + new(__o++) _Tp(*__b++); + } + }; + + template + struct _Array_copy_ctor<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o) + { + if (__b) + __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); + } + }; + + template + inline void + __valarray_copy_construct(const _Tp* __b, const _Tp* __e, + _Tp* __restrict__ __o) + { + _Array_copy_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __o); + } + + // copy-construct raw array [__o, *) from strided array __a[<__n : __s>] + template + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, + size_t __s, _Tp* __restrict__ __o) + { + if (__is_trivial(_Tp)) + while (__n--) + { + *__o++ = *__a; + __a += __s; + } + else + while (__n--) + { + new(__o++) _Tp(*__a); + __a += __s; + } + } + + // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]] + template + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __o, size_t __n) + { + if (__is_trivial(_Tp)) + while (__n--) + *__o++ = __a[*__i++]; + else + while (__n--) + new (__o++) _Tp(__a[*__i++]); + } + + // Do the necessary cleanup when we're done with arrays. + template + inline void + __valarray_destroy_elements(_Tp* __b, _Tp* __e) + { + if (!__is_trivial(_Tp)) + while (__b != __e) + { + __b->~_Tp(); + ++__b; + } + } + + // Fill a plain array __a[<__n>] with __t + template + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t) + { + while (__n--) + *__a++ = __t; + } + + // fill strided array __a[<__n-1 : __s>] with __t + template + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, + size_t __s, const _Tp& __t) + { + for (size_t __i = 0; __i < __n; ++__i, __a += __s) + *__a = __t; + } + + // fill indirect array __a[__i[<__n>]] with __i + template + inline void + __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, + size_t __n, const _Tp& __t) + { + for (size_t __j = 0; __j < __n; ++__j, ++__i) + __a[*__i] = __t; + } + + // copy plain array __a[<__n>] in __b[<__n>] + // For non-fundamental types, it is wrong to say 'memcpy()' + template + struct _Array_copier + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { + while(__n--) + *__b++ = *__a++; + } + }; + + template + struct _Array_copier<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { + if (__n != 0) + __builtin_memcpy(__b, __a, __n * sizeof (_Tp)); + } + }; + + // Copy a plain array __a[<__n>] into a play array __b[<>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b) + { + _Array_copier<_Tp, __is_trivial(_Tp)>::_S_do_it(__a, __n, __b); + } + + // Copy strided array __a[<__n : __s>] in plain __b[<__n>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, + _Tp* __restrict__ __b) + { + for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s) + *__b = *__a; + } + + // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, + size_t __n, size_t __s) + { + for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s) + *__b = *__a; + } + + // Copy strided array __src[<__n : __s1>] into another + // strided array __dst[< : __s2>]. Their sizes must match. + template + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1, + _Tp* __restrict__ __dst, size_t __s2) + { + for (size_t __i = 0; __i < __n; ++__i) + __dst[__i * __s2] = __src[__i * __s1]; + } + + // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __b, size_t __n) + { + for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i) + *__b = __a[*__i]; + } + + // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b, const size_t* __restrict__ __i) + { + for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i) + __b[*__i] = *__a; + } + + // Copy the __n first elements of an indexed array __src[<__i>] into + // another indexed array __dst[<__j>]. + template + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, + const size_t* __restrict__ __i, + _Tp* __restrict__ __dst, const size_t* __restrict__ __j) + { + for (size_t __k = 0; __k < __n; ++__k) + __dst[*__j++] = __src[*__i++]; + } + + // + // Compute the sum of elements in range [__f, __l) which must not be empty. + // This is a naive algorithm. It suffers from cancelling. + // In the future try to specialize for _Tp = float, double, long double + // using a more accurate algorithm. + // + template + inline _Tp + __valarray_sum(const _Tp* __f, const _Tp* __l) + { + _Tp __r = *__f++; + while (__f != __l) + __r += *__f++; + return __r; + } + + // Compute the min/max of an array-expression + template + inline typename _Ta::value_type + __valarray_min(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t < __r) + __r = __t; + } + return __r; + } + + template + inline typename _Ta::value_type + __valarray_max(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t > __r) + __r = __t; + } + return __r; + } + + // + // Helper class _Array, first layer of valarray abstraction. + // All operations on valarray should be forwarded to this class + // whenever possible. -- gdr + // + + template + struct _Array + { + explicit _Array(_Tp* const __restrict__); + explicit _Array(const valarray<_Tp>&); + _Array(const _Tp* __restrict__, size_t); + + _Tp* begin() const; + + _Tp* const __restrict__ _M_data; + }; + + + // Copy-construct plain array __b[<__n>] from indexed array __a[__i[<__n>]] + template + inline void + __valarray_copy_construct(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy_construct(__a._M_data, __i._M_data, + __b._M_data, __n); } + + // Copy-construct plain array __b[<__n>] from strided array __a[<__n : __s>] + template + inline void + __valarray_copy_construct(_Array<_Tp> __a, size_t __n, size_t __s, + _Array<_Tp> __b) + { std::__valarray_copy_construct(__a._M_data, __n, __s, __b._M_data); } + + template + inline void + __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __t); } + + template + inline void + __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __s, __t); } + + template + inline void + __valarray_fill(_Array<_Tp> __a, _Array __i, + size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); } + + // Copy a plain array __a[<__n>] into a play array __b[<>] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __b._M_data); } + + // Copy strided array __a[<__n : __s>] in plain __b[<__n>] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); } + + // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] + template + inline void + __valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s) + { __valarray_copy(__a._M_data, __b._M_data, __n, __s); } + + // Copy strided array __src[<__n : __s1>] into another + // strided array __dst[< : __s2>]. Their sizes must match. + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1, + _Array<_Tp> __b, size_t __s2) + { std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); } + + // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] + template + inline void + __valarray_copy(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); } + + // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, + _Array __i) + { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); } + + // Copy the __n first elements of an indexed array __src[<__i>] into + // another indexed array __dst[<__j>]. + template + inline void + __valarray_copy(_Array<_Tp> __src, size_t __n, _Array __i, + _Array<_Tp> __dst, _Array __j) + { + std::__valarray_copy(__src._M_data, __n, __i._M_data, + __dst._M_data, __j._M_data); + } + + template + inline + _Array<_Tp>::_Array(_Tp* const __restrict__ __p) + : _M_data (__p) {} + + template + inline + _Array<_Tp>::_Array(const valarray<_Tp>& __v) + : _M_data (__v._M_data) {} + + template + inline + _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s) + : _M_data(__valarray_get_storage<_Tp>(__s)) + { std::__valarray_copy_construct(__b, __s, _M_data); } + + template + inline _Tp* + _Array<_Tp>::begin () const + { return _M_data; } + +#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \ + { \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \ + *__p _Op##= __t; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ + { \ + _Tp* __p = __a._M_data; \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__p) \ + *__p _Op##= __e[__i]; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \ + _Array<_Tp> __b) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \ + __p += __s, ++__q) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \ + size_t __n, size_t __s) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, __q += __s) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, __p += __s) \ + *__p _Op##= __e[__i]; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + _Array<_Tp> __b, size_t __n) \ + { \ + _Tp* __q(__b._M_data); \ + for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \ + ++__j, ++__q) \ + __a._M_data[*__j] _Op##= *__q; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __i) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \ + ++__j, ++__p) \ + *__p _Op##= __b._M_data[*__j]; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + size_t* __j(__i._M_data); \ + for (size_t __k = 0; __k<__n; ++__k, ++__j) \ + __a._M_data[*__j] _Op##= __e[__k]; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + _Array<_Tp> __b, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \ + ++__q, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= *__q; \ + } \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __m) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, ++__ok, ++__q) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__q; \ + } \ + *__p _Op##= *__q; \ + } \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= __e[__i]; \ + } \ + } + + _DEFINE_ARRAY_FUNCTION(+, __plus) + _DEFINE_ARRAY_FUNCTION(-, __minus) + _DEFINE_ARRAY_FUNCTION(*, __multiplies) + _DEFINE_ARRAY_FUNCTION(/, __divides) + _DEFINE_ARRAY_FUNCTION(%, __modulus) + _DEFINE_ARRAY_FUNCTION(^, __bitwise_xor) + _DEFINE_ARRAY_FUNCTION(|, __bitwise_or) + _DEFINE_ARRAY_FUNCTION(&, __bitwise_and) + _DEFINE_ARRAY_FUNCTION(<<, __shift_left) + _DEFINE_ARRAY_FUNCTION(>>, __shift_right) + +#undef _DEFINE_ARRAY_FUNCTION + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +# include + +#endif /* _ARRAY_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d754244cfaceb0ec91387dd090df02dd2b25b74a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc new file mode 100644 index 0000000000000000000000000000000000000000..bff239cf428a83db33db3ae044b2d5675bd1e40b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc @@ -0,0 +1,244 @@ +// The template and inlines for the -*- C++ -*- internal _Array helper class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_array.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_ARRAY_TCC +#define _VALARRAY_ARRAY_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + __valarray_fill(_Array<_Tp> __a, size_t __n, _Array __m, + const _Tp& __t) + { + _Tp* __p = __a._M_data; + bool* __ok (__m._M_data); + for (size_t __i=0; __i < __n; ++__i, ++__ok, ++__p) + { + while (!*__ok) + { + ++__ok; + ++__p; + } + *__p = __t; + } + } + + // Copy n elements of a into consecutive elements of b. When m is + // false, the corresponding element of a is skipped. m must contain + // at least n true elements. a must contain at least n elements and + // enough elements to match up with m through the nth true element + // of m. I.e. if n is 10, m has 15 elements with 5 false followed + // by 10 true, a must have 15 elements. + template + void + __valarray_copy(_Array<_Tp> __a, _Array __m, _Array<_Tp> __b, + size_t __n) + { + _Tp* __p (__a._M_data); + bool* __ok (__m._M_data); + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; + ++__q, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + *__q = *__p; + } + } + + // Copy n consecutive elements from a into elements of b. Elements + // of b are skipped if the corresponding element of m is false. m + // must contain at least n true elements. b must have at least as + // many elements as the index of the nth true element of m. I.e. if + // m has 15 elements with 5 false followed by 10 true, b must have + // at least 15 elements. + template + void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, + _Array __m) + { + _Tp* __q (__b._M_data); + bool* __ok (__m._M_data); + for (_Tp* __p = __a._M_data; __p < __a._M_data+__n; + ++__p, ++__ok, ++__q) + { + while (! *__ok) + { + ++__ok; + ++__q; + } + *__q = *__p; + } + } + + // Copy n elements from a into elements of b. Elements of a are + // skipped if the corresponding element of m is false. Elements of + // b are skipped if the corresponding element of k is false. m and + // k must contain at least n true elements. a and b must have at + // least as many elements as the index of the nth true element of m. + template + void + __valarray_copy(_Array<_Tp> __a, _Array __m, size_t __n, + _Array<_Tp> __b, _Array __k) + { + _Tp* __p (__a._M_data); + _Tp* __q (__b._M_data); + bool* __srcok (__m._M_data); + bool* __dstok (__k._M_data); + for (size_t __i = 0; __i < __n; + ++__srcok, ++__p, ++__dstok, ++__q, ++__i) + { + while (! *__srcok) + { + ++__srcok; + ++__p; + } + while (! *__dstok) + { + ++__dstok; + ++__q; + } + *__q = *__p; + } + } + + // Copy n consecutive elements of e into consecutive elements of a. + // I.e. a[i] = e[i]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__p) + *__p = __e[__i]; + } + + // Copy n consecutive elements of e into elements of a using stride + // s. I.e., a[0] = e[0], a[s] = e[1], a[2*s] = e[2]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, size_t __s) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, __p += __s) + *__p = __e[__i]; + } + + // Copy n consecutive elements of e into elements of a indexed by + // contents of i. I.e., a[i[0]] = e[0]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, _Array __i) + { + size_t* __j (__i._M_data); + for (size_t __k = 0; __k < __n; ++__k, ++__j) + __a._M_data[*__j] = __e[__k]; + } + + // Copy n elements of e indexed by contents of f into elements of a + // indexed by contents of i. I.e., a[i[0]] = e[f[0]]. + template + void + __valarray_copy(_Array<_Tp> __e, _Array __f, + size_t __n, + _Array<_Tp> __a, _Array __i) + { + size_t* __g (__f._M_data); + size_t* __j (__i._M_data); + for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g) + __a._M_data[*__j] = __e._M_data[*__g]; + } + + // Copy n consecutive elements of e into elements of a. Elements of + // a are skipped if the corresponding element of m is false. m must + // have at least n true elements and a must have at least as many + // elements as the index of the nth true element of m. I.e. if m + // has 5 false followed by 10 true elements and n == 10, a must have + // at least 15 elements. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, _Array __m) + { + bool* __ok (__m._M_data); + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + *__p = __e[__i]; + } + } + + + template + void + __valarray_copy_construct(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__p) + new (__p) _Tp(__e[__i]); + } + + + template + void + __valarray_copy_construct(_Array<_Tp> __a, _Array __m, + _Array<_Tp> __b, size_t __n) + { + _Tp* __p (__a._M_data); + bool* __ok (__m._M_data); + for (_Tp* __q = __b._M_data; __q < __b._M_data+__n; ++__q, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + new (__q) _Tp(*__p); + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _VALARRAY_ARRAY_TCC */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..b6665cdd6044d384dafbe97fffe19c83b38a2ca0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_array.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h new file mode 100644 index 0000000000000000000000000000000000000000..401d4f70830f8de7a54a06b46bafbd3c88fdb6e1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h @@ -0,0 +1,758 @@ +// The template and inlines for the -*- C++ -*- internal _Meta class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_before.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_BEFORE_H +#define _VALARRAY_BEFORE_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // + // Implementing a loosened valarray return value is tricky. + // First we need to meet 26.3.1/3: we should not add more than + // two levels of template nesting. Therefore we resort to template + // template to "flatten" loosened return value types. + // At some point we use partial specialization to remove one level + // template nesting due to _Expr<> + // + + // This class is NOT defined. It doesn't need to. + template class _Constant; + + // Implementations of unary functions applied to valarray<>s. + // I use hard-coded object functions here instead of a generic + // approach like pointers to function: + // 1) correctness: some functions take references, others values. + // we can't deduce the correct type afterwards. + // 2) efficiency -- object functions can be easily inlined + // 3) be Koenig-lookup-friendly + + struct _Abs + { + template + _Tp operator()(const _Tp& __t) const + { return abs(__t); } + }; + + struct _Cos + { + template + _Tp operator()(const _Tp& __t) const + { return cos(__t); } + }; + + struct _Acos + { + template + _Tp operator()(const _Tp& __t) const + { return acos(__t); } + }; + + struct _Cosh + { + template + _Tp operator()(const _Tp& __t) const + { return cosh(__t); } + }; + + struct _Sin + { + template + _Tp operator()(const _Tp& __t) const + { return sin(__t); } + }; + + struct _Asin + { + template + _Tp operator()(const _Tp& __t) const + { return asin(__t); } + }; + + struct _Sinh + { + template + _Tp operator()(const _Tp& __t) const + { return sinh(__t); } + }; + + struct _Tan + { + template + _Tp operator()(const _Tp& __t) const + { return tan(__t); } + }; + + struct _Atan + { + template + _Tp operator()(const _Tp& __t) const + { return atan(__t); } + }; + + struct _Tanh + { + template + _Tp operator()(const _Tp& __t) const + { return tanh(__t); } + }; + + struct _Exp + { + template + _Tp operator()(const _Tp& __t) const + { return exp(__t); } + }; + + struct _Log + { + template + _Tp operator()(const _Tp& __t) const + { return log(__t); } + }; + + struct _Log10 + { + template + _Tp operator()(const _Tp& __t) const + { return log10(__t); } + }; + + struct _Sqrt + { + template + _Tp operator()(const _Tp& __t) const + { return sqrt(__t); } + }; + + // In the past, we used to tailor operator applications semantics + // to the specialization of standard function objects (i.e. plus<>, etc.) + // That is incorrect. Therefore we provide our own surrogates. + + struct __unary_plus + { + template + _Tp operator()(const _Tp& __t) const + { return +__t; } + }; + + struct __negate + { + template + _Tp operator()(const _Tp& __t) const + { return -__t; } + }; + + struct __bitwise_not + { + template + _Tp operator()(const _Tp& __t) const + { return ~__t; } + }; + + struct __plus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x + __y; } + }; + + struct __minus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x - __y; } + }; + + struct __multiplies + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x * __y; } + }; + + struct __divides + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x / __y; } + }; + + struct __modulus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x % __y; } + }; + + struct __bitwise_xor + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x ^ __y; } + }; + + struct __bitwise_and + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x & __y; } + }; + + struct __bitwise_or + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x | __y; } + }; + + struct __shift_left + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x << __y; } + }; + + struct __shift_right + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x >> __y; } + }; + + struct __logical_and + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x && __y; } + }; + + struct __logical_or + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x || __y; } + }; + + struct __logical_not + { + template + bool operator()(const _Tp& __x) const + { return !__x; } + }; + + struct __equal_to + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x == __y; } + }; + + struct __not_equal_to + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x != __y; } + }; + + struct __less + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x < __y; } + }; + + struct __greater + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x > __y; } + }; + + struct __less_equal + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x <= __y; } + }; + + struct __greater_equal + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x >= __y; } + }; + + // The few binary functions we miss. + struct _Atan2 + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return atan2(__x, __y); } + }; + + struct _Pow + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return pow(__x, __y); } + }; + + template + struct __fun_with_valarray + { + typedef _Tp result_type; + }; + + template + struct __fun_with_valarray<_Tp, false> + { + // No result type defined for invalid value types. + }; + + // We need these bits in order to recover the return type of + // some functions/operators now that we're no longer using + // function templates. + template + struct __fun : __fun_with_valarray<_Tp> + { + }; + + // several specializations for relational operators. + template + struct __fun<__logical_not, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__logical_and, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__logical_or, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__less, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__greater, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__less_equal, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__greater_equal, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__equal_to, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__not_equal_to, _Tp> + { + typedef bool result_type; + }; + +namespace __detail +{ + // Closure types already have reference semantics and are often short-lived, + // so store them by value to avoid (some cases of) dangling references to + // out-of-scope temporaries. + template + struct _ValArrayRef + { typedef const _Tp __type; }; + + // Use real references for std::valarray objects. + template + struct _ValArrayRef< valarray<_Tp> > + { typedef const valarray<_Tp>& __type; }; + + // + // Apply function taking a value/const reference closure + // + + template + class _FunBase + { + public: + typedef typename _Dom::value_type value_type; + + _FunBase(const _Dom& __e, value_type __f(_Arg)) + : _M_expr(__e), _M_func(__f) {} + + value_type operator[](size_t __i) const + { return _M_func (_M_expr[__i]); } + + size_t size() const { return _M_expr.size ();} + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + value_type (*_M_func)(_Arg); + }; + + template + struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type> + { + typedef _FunBase<_Dom, typename _Dom::value_type> _Base; + typedef typename _Base::value_type value_type; + typedef value_type _Tp; + + _ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {} + }; + + template + struct _ValFunClos<_ValArray,_Tp> : _FunBase, _Tp> + { + typedef _FunBase, _Tp> _Base; + typedef _Tp value_type; + + _ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {} + }; + + template + struct _RefFunClos<_Expr, _Dom> + : _FunBase<_Dom, const typename _Dom::value_type&> + { + typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base; + typedef typename _Base::value_type value_type; + typedef value_type _Tp; + + _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&)) + : _Base(__e, __f) {} + }; + + template + struct _RefFunClos<_ValArray, _Tp> + : _FunBase, const _Tp&> + { + typedef _FunBase, const _Tp&> _Base; + typedef _Tp value_type; + + _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&)) + : _Base(__v, __f) {} + }; + + // + // Unary expression closure. + // + + template + class _UnBase + { + public: + typedef typename _Arg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _UnBase(const _Arg& __e) : _M_expr(__e) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr[__i]); } + + size_t size() const { return _M_expr.size(); } + + private: + typename _ValArrayRef<_Arg>::__type _M_expr; + }; + + template + struct _UnClos<_Oper, _Expr, _Dom> + : _UnBase<_Oper, _Dom> + { + typedef _Dom _Arg; + typedef _UnBase<_Oper, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _UnClos(const _Arg& __e) : _Base(__e) {} + }; + + template + struct _UnClos<_Oper, _ValArray, _Tp> + : _UnBase<_Oper, valarray<_Tp> > + { + typedef valarray<_Tp> _Arg; + typedef _UnBase<_Oper, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _UnClos(const _Arg& __e) : _Base(__e) {} + }; + + + // + // Binary expression closure. + // + + template + class _BinBase + { + public: + typedef typename _FirstArg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase(const _FirstArg& __e1, const _SecondArg& __e2) + : _M_expr1(__e1), _M_expr2(__e2) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1[__i], _M_expr2[__i]); } + + size_t size() const { return _M_expr1.size(); } + + private: + typename _ValArrayRef<_FirstArg>::__type _M_expr1; + typename _ValArrayRef<_SecondArg>::__type _M_expr2; + }; + + + template + class _BinBase2 + { + public: + typedef typename _Clos::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase2(const _Clos& __e, const _Vt& __t) + : _M_expr1(__e), _M_expr2(__t) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1[__i], _M_expr2); } + + size_t size() const { return _M_expr1.size(); } + + private: + typename _ValArrayRef<_Clos>::__type _M_expr1; + _Vt _M_expr2; + }; + + template + class _BinBase1 + { + public: + typedef typename _Clos::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase1(const _Vt& __t, const _Clos& __e) + : _M_expr1(__t), _M_expr2(__e) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1, _M_expr2[__i]); } + + size_t size() const { return _M_expr2.size(); } + + private: + _Vt _M_expr1; + typename _ValArrayRef<_Clos>::__type _M_expr2; + }; + + template + struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2> + : _BinBase<_Oper, _Dom1, _Dom2> + { + typedef _BinBase<_Oper, _Dom1, _Dom2> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _ValArray, _Tp, _Tp> + : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > + { + typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) + : _Base(__v, __w) {} + }; + + template + struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type> + : _BinBase<_Oper, _Dom, valarray > + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2) + : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom> + : _BinBase<_Oper, valarray,_Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2) + : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type> + : _BinBase2<_Oper, _Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase2<_Oper,_Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom> + : _BinBase1<_Oper, _Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase1<_Oper, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp> + : _BinBase2<_Oper, valarray<_Tp> > + { + typedef _BinBase2<_Oper,valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {} + }; + + template + struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp> + : _BinBase1<_Oper, valarray<_Tp> > + { + typedef _BinBase1<_Oper, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {} + }; + + // + // slice_array closure. + // + template + class _SBase + { + public: + typedef typename _Dom::value_type value_type; + + _SBase (const _Dom& __e, const slice& __s) + : _M_expr (__e), _M_slice (__s) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } + + size_t + size() const + { return _M_slice.size (); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const slice& _M_slice; + }; + + template + class _SBase<_Array<_Tp> > + { + public: + typedef _Tp value_type; + + _SBase (_Array<_Tp> __a, const slice& __s) + : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), + _M_stride (__s.stride()) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[__i * _M_stride]; } + + size_t + size() const + { return _M_size; } + + private: + const _Array<_Tp> _M_array; + const size_t _M_size; + const size_t _M_stride; + }; + + template + struct _SClos<_Expr, _Dom> + : _SBase<_Dom> + { + typedef _SBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} + }; + + template + struct _SClos<_ValArray, _Tp> + : _SBase<_Array<_Tp> > + { + typedef _SBase<_Array<_Tp> > _Base; + typedef _Tp value_type; + + _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} + }; +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _CPP_VALARRAY_BEFORE_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..38770a3ccbe873b0de0bf7d23d599e1ba9af3593 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@valarray_before.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc new file mode 100644 index 0000000000000000000000000000000000000000..33faabf2eae572e8068838374ab8745b33a342ac --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc @@ -0,0 +1,1036 @@ +// Vector implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/vector.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _VECTOR_TCC +#define _VECTOR_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + reserve(size_type __n) + { + if (__n > this->max_size()) + __throw_length_error(__N("vector::reserve")); + if (this->capacity() < __n) + { + const size_type __old_size = size(); + pointer __tmp; +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __tmp = this->_M_allocate(__n); + _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, + __tmp, _M_get_Tp_allocator()); + } + else +#endif + { + __tmp = _M_allocate_and_copy(__n, + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start), + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish)); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_finish = __tmp + __old_size; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + } + } + +#if __cplusplus >= 201103L + template + template +#if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR + typename vector<_Tp, _Alloc>::reference +#else + void +#endif + vector<_Tp, _Alloc>:: + emplace_back(_Args&&... __args) + { + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_realloc_insert(end(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + + template + _GLIBCXX20_CONSTEXPR + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + const size_type __n = __position - begin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == end()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + __x); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + { +#if __cplusplus >= 201103L + const auto __pos = begin() + (__position - cbegin()); + // __x could be an existing element of this vector, so make a + // copy of it before _M_insert_aux moves elements around. + _Temporary_value __x_copy(this, __x); + _M_insert_aux(__pos, std::move(__x_copy._M_val())); +#else + _M_insert_aux(__position, __x); +#endif + } + else +#if __cplusplus >= 201103L + _M_realloc_insert(begin() + (__position - cbegin()), __x); +#else + _M_realloc_insert(__position, __x); +#endif + + return iterator(this->_M_impl._M_start + __n); + } + + template + _GLIBCXX20_CONSTEXPR + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: + _M_erase(iterator __position) + { + if (__position + 1 != end()) + _GLIBCXX_MOVE3(__position + 1, end(), __position); + --this->_M_impl._M_finish; + _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); + _GLIBCXX_ASAN_ANNOTATE_SHRINK(1); + return __position; + } + + template + _GLIBCXX20_CONSTEXPR + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: + _M_erase(iterator __first, iterator __last) + { + if (__first != __last) + { + if (__last != end()) + _GLIBCXX_MOVE3(__last, end(), __first); + _M_erase_at_end(__first.base() + (end() - __last)); + } + return __first; + } + + template + _GLIBCXX20_CONSTEXPR + vector<_Tp, _Alloc>& + vector<_Tp, _Alloc>:: + operator=(const vector<_Tp, _Alloc>& __x) + { + if (std::__addressof(__x) != this) + { + _GLIBCXX_ASAN_ANNOTATE_REINIT; +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() + && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) + { + // replacement allocator cannot free existing storage + this->clear(); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = nullptr; + this->_M_impl._M_finish = nullptr; + this->_M_impl._M_end_of_storage = nullptr; + } + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } +#endif + const size_type __xlen = __x.size(); + if (__xlen > capacity()) + { + pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), + __x.end()); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen; + } + else if (size() >= __xlen) + { + std::_Destroy(std::copy(__x.begin(), __x.end(), begin()), + end(), _M_get_Tp_allocator()); + } + else + { + std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(), + this->_M_impl._M_start); + std::__uninitialized_copy_a(__x._M_impl._M_start + size(), + __x._M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + this->_M_impl._M_finish = this->_M_impl._M_start + __xlen; + } + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_fill_assign(size_t __n, const value_type& __val) + { + if (__n > capacity()) + { + vector __tmp(__n, __val, _M_get_Tp_allocator()); + __tmp._M_impl._M_swap_data(this->_M_impl); + } + else if (__n > size()) + { + std::fill(begin(), end(), __val); + const size_type __add = __n - size(); + _GLIBCXX_ASAN_ANNOTATE_GROW(__add); + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __add, __val, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__add); + } + else + _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val)); + } + + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + pointer __cur(this->_M_impl._M_start); + for (; __first != __last && __cur != this->_M_impl._M_finish; + ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + _M_range_insert(end(), __first, __last, + std::__iterator_category(__first)); + } + + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + + if (__len > capacity()) + { + _S_check_init_len(__len, _M_get_Tp_allocator()); + pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_finish = this->_M_impl._M_start + __len; + this->_M_impl._M_end_of_storage = this->_M_impl._M_finish; + } + else if (size() >= __len) + _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start)); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, this->_M_impl._M_start); + const size_type __attribute__((__unused__)) __n = __len - size(); + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + } + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + auto + vector<_Tp, _Alloc>:: + _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator + { + const auto __n = __position - cbegin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == cend()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::move(__v)); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_insert_aux(begin() + __n, std::move(__v)); + else + _M_realloc_insert(begin() + __n, std::move(__v)); + + return iterator(this->_M_impl._M_start + __n); + } + + template + template + _GLIBCXX20_CONSTEXPR + auto + vector<_Tp, _Alloc>:: + _M_emplace_aux(const_iterator __position, _Args&&... __args) + -> iterator + { + const auto __n = __position - cbegin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == cend()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + { + // We need to construct a temporary because something in __args... + // could alias one of the elements of the container and so we + // need to use it before _M_insert_aux moves elements around. + _Temporary_value __tmp(this, std::forward<_Args>(__args)...); + _M_insert_aux(begin() + __n, std::move(__tmp._M_val())); + } + else + _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...); + + return iterator(this->_M_impl._M_start + __n); + } + + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_insert_aux(iterator __position, _Arg&& __arg) +#else + template + void + vector<_Tp, _Alloc>:: + _M_insert_aux(iterator __position, const _Tp& __x) +#endif + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1))); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); +#if __cplusplus < 201103L + _Tp __x_copy = __x; +#endif + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + this->_M_impl._M_finish - 2, + this->_M_impl._M_finish - 1); +#if __cplusplus < 201103L + *__position = __x_copy; +#else + *__position = std::forward<_Arg>(__arg); +#endif + } + +#if __cplusplus >= 201103L + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_realloc_insert(iterator __position, _Args&&... __args) +#else + template + void + vector<_Tp, _Alloc>:: + _M_realloc_insert(iterator __position, const _Tp& __x) +#endif + { + const size_type __len = + _M_check_len(size_type(1), "vector::_M_realloc_insert"); + pointer __old_start = this->_M_impl._M_start; + pointer __old_finish = this->_M_impl._M_finish; + const size_type __elems_before = __position - begin(); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + // The order of the three operations is dictated by the C++11 + // case, where the moves could alter a new element belonging + // to the existing vector. This is an issue only for callers + // taking the element by lvalue ref (see last bullet of C++11 + // [res.on.arguments]). + _Alloc_traits::construct(this->_M_impl, + __new_start + __elems_before, +#if __cplusplus >= 201103L + std::forward<_Args>(__args)...); +#else + __x); +#endif + __new_finish = pointer(); + +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __new_finish = _S_relocate(__old_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + ++__new_finish; + + __new_finish = _S_relocate(__position.base(), __old_finish, + __new_finish, _M_get_Tp_allocator()); + } + else +#endif + { + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__old_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + ++__new_finish; + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), __old_finish, + __new_finish, _M_get_Tp_allocator()); + } + } + __catch(...) + { + if (!__new_finish) + _Alloc_traits::destroy(this->_M_impl, + __new_start + __elems_before); + else + std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (!_S_use_relocate()) +#endif + std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(__old_start, + this->_M_impl._M_end_of_storage - __old_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_fill_insert(iterator __position, size_type __n, const value_type& __x) + { + if (__n != 0) + { + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { +#if __cplusplus < 201103L + value_type __x_copy = __x; +#else + _Temporary_value __tmp(this, __x); + value_type& __x_copy = __tmp._M_val(); +#endif + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_move_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + __old_finish - __n, __old_finish); + std::fill(__position.base(), __position.base() + __n, + __x_copy); + } + else + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __n - __elems_after, + __x_copy, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after); + std::__uninitialized_move_a(__position.base(), __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after); + std::fill(__position.base(), __old_finish, __x_copy); + } + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_fill_insert"); + const size_type __elems_before = __position - begin(); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + // See _M_realloc_insert above. + std::__uninitialized_fill_n_a(__new_start + __elems_before, + __n, __x, + _M_get_Tp_allocator()); + __new_finish = pointer(); + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (this->_M_impl._M_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + __new_finish += __n; + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), this->_M_impl._M_finish, + __new_finish, _M_get_Tp_allocator()); + } + __catch(...) + { + if (!__new_finish) + std::_Destroy(__new_start + __elems_before, + __new_start + __elems_before + __n, + _M_get_Tp_allocator()); + else + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + if (__n != 0) + { + const size_type __size = size(); + size_type __navail = size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish); + + if (__size > max_size() || __navail > max_size() - __size) + __builtin_unreachable(); + + if (__navail >= __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_default_n_a(this->_M_impl._M_finish, + __n, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_default_append"); + pointer __new_start(this->_M_allocate(__len)); + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __try + { + std::__uninitialized_default_n_a(__new_start + __size, + __n, _M_get_Tp_allocator()); + } + __catch(...) + { + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, + __new_start, _M_get_Tp_allocator()); + } + else + { + pointer __destroy_from = pointer(); + __try + { + std::__uninitialized_default_n_a(__new_start + __size, + __n, _M_get_Tp_allocator()); + __destroy_from = __new_start + __size; + std::__uninitialized_move_if_noexcept_a( + this->_M_impl._M_start, this->_M_impl._M_finish, + __new_start, _M_get_Tp_allocator()); + } + __catch(...) + { + if (__destroy_from) + std::_Destroy(__destroy_from, __destroy_from + __n, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_start + __size + __n; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + + template + _GLIBCXX20_CONSTEXPR + bool + vector<_Tp, _Alloc>:: + _M_shrink_to_fit() + { + if (capacity() == size()) + return false; + _GLIBCXX_ASAN_ANNOTATE_REINIT; + return std::__shrink_to_fit_aux::_S_do_it(*this); + } +#endif + + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + if (__pos == end()) + { + for (; __first != __last; ++__first) + insert(end(), *__first); + } + else if (__first != __last) + { + vector __tmp(__first, __last, _M_get_Tp_allocator()); + insert(__pos, + _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()), + _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end())); + } + } + + template + template + _GLIBCXX20_CONSTEXPR + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + const size_type __n = std::distance(__first, __last); + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_move_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + __old_finish - __n, __old_finish); + std::copy(__first, __last, __position); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, __elems_after); + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n - __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after); + std::__uninitialized_move_a(__position.base(), + __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after); + std::copy(__first, __mid, __position); + } + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_range_insert"); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + __new_finish + = std::__uninitialized_move_if_noexcept_a + (this->_M_impl._M_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + __new_finish + = std::__uninitialized_copy_a(__first, __last, + __new_finish, + _M_get_Tp_allocator()); + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), this->_M_impl._M_finish, + __new_finish, _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + + + // vector + template + _GLIBCXX20_CONSTEXPR + void + vector:: + _M_reallocate(size_type __n) + { + _Bit_pointer __q = this->_M_allocate(__n); + iterator __start(std::__addressof(*__q), 0); + iterator __finish(_M_copy_aligned(begin(), end(), __start)); + this->_M_deallocate(); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + this->_M_impl._M_end_of_storage = __q + _S_nword(__n); + } + + template + _GLIBCXX20_CONSTEXPR + void + vector:: + _M_fill_insert(iterator __position, size_type __n, bool __x) + { + if (__n == 0) + return; + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + difference_type(__n)); + std::fill(__position, __position + difference_type(__n), __x); + this->_M_impl._M_finish += difference_type(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_fill_insert"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + std::fill(__i, __i + difference_type(__n), __x); + iterator __finish = std::copy(__position, end(), + __i + difference_type(__n)); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + + template + template + _GLIBCXX20_CONSTEXPR + void + vector:: + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + size_type __n = std::distance(__first, __last); + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + + difference_type(__n)); + std::copy(__first, __last, __position); + this->_M_impl._M_finish += difference_type(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_insert_range"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + __i = std::copy(__first, __last, __i); + iterator __finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + } + + template + _GLIBCXX20_CONSTEXPR + void + vector:: + _M_insert_aux(iterator __position, bool __x) + { + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) + { + std::copy_backward(__position, this->_M_impl._M_finish, + this->_M_impl._M_finish + 1); + *__position = __x; + ++this->_M_impl._M_finish; + } + else + { + const size_type __len = + _M_check_len(size_type(1), "vector::_M_insert_aux"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + *__i++ = __x; + iterator __finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + + template + _GLIBCXX20_CONSTEXPR + typename vector::iterator + vector:: + _M_erase(iterator __position) + { + if (__position + 1 != end()) + std::copy(__position + 1, end(), __position); + --this->_M_impl._M_finish; + return __position; + } + + template + _GLIBCXX20_CONSTEXPR + typename vector::iterator + vector:: + _M_erase(iterator __first, iterator __last) + { + if (__first != __last) + _M_erase_at_end(std::copy(__last, end(), __first)); + return __first; + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + vector:: + _M_shrink_to_fit() + { + if (capacity() - size() < int(_S_word_bit)) + return false; + __try + { + if (size_type __n = size()) + _M_reallocate(__n); + else + { + this->_M_deallocate(); + this->_M_impl._M_reset(); + } + return true; + } + __catch(...) + { return false; } + } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + size_t + hash<_GLIBCXX_STD_C::vector>:: + operator()(const _GLIBCXX_STD_C::vector& __b) const noexcept + { + size_t __hash = 0; + const size_t __words = __b.size() / _S_word_bit; + if (__words) + { + const size_t __clength = __words * sizeof(_Bit_type); + __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength); + } + + const size_t __extrabits = __b.size() % _S_word_bit; + if (__extrabits) + { + _Bit_type __hiword = *__b._M_impl._M_finish._M_p; + __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits); + + const size_t __clength + = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__; + if (__words) + __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash); + else + __hash = std::_Hash_impl::hash(&__hiword, __clength); + } + + return __hash; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#undef _GLIBCXX_ASAN_ANNOTATE_REINIT +#undef _GLIBCXX_ASAN_ANNOTATE_GROW +#undef _GLIBCXX_ASAN_ANNOTATE_GREW +#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK + +#endif /* _VECTOR_TCC */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc.blob new file mode 100644 index 0000000000000000000000000000000000000000..b760cb1dc6d39cfae930a2c716793ea981c82335 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bits@vector.tcc.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset new file mode 100644 index 0000000000000000000000000000000000000000..438c2f7efe9281c4dec5a9e37960be569da12045 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset @@ -0,0 +1,1598 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/bitset + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BITSET +#define _GLIBCXX_BITSET 1 + +#pragma GCC system_header + +#include +#include // For invalid_argument, out_of_range, + // overflow_error +#include +#include + +#if __cplusplus >= 201103L +# include +#endif + +#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__) +#define _GLIBCXX_BITSET_WORDS(__n) \ + ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \ + ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1)) + +#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * Base class, general case. It is a class invariant that _Nw will be + * nonnegative. + * + * See documentation for bitset. + */ + template + struct _Base_bitset + { + typedef unsigned long _WordT; + + /// 0 is the least significant word. + _WordT _M_w[_Nw]; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + : _M_w() { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long __val) noexcept + : _M_w{ _WordT(__val) +#if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ + , _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD) +#endif + } { } +#else + _Base_bitset(unsigned long __val) + : _M_w() + { _M_w[0] = __val; } +#endif + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t __pos) _GLIBCXX_NOEXCEPT + { return _M_w[_S_whichword(__pos)]; } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT + { return _M_w[_S_whichword(__pos)]; } + +#if __cplusplus >= 201103L + const _WordT* + _M_getdata() const noexcept + { return _M_w; } +#endif + + _WordT& + _M_hiword() _GLIBCXX_NOEXCEPT + { return _M_w[_Nw - 1]; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return _M_w[_Nw - 1]; } + + void + _M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] &= __x._M_w[__i]; + } + + void + _M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] |= __x._M_w[__i]; + } + + void + _M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] ^= __x._M_w[__i]; + } + + void + _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT; + + void + _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT; + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~_M_w[__i]; + } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~static_cast<_WordT>(0); + } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } + + bool + _M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; ++__i) + if (_M_w[__i] != __x._M_w[__i]) + return false; + return true; + } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw - 1; __i++) + if (_M_w[__i] != ~static_cast<_WordT>(0)) + return false; + return _M_hiword() == (~static_cast<_WordT>(0) + >> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD + - _Nb)); + } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + if (_M_w[__i] != static_cast<_WordT>(0)) + return true; + return false; + } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { + size_t __result = 0; + for (size_t __i = 0; __i < _Nw; __i++) + __result += __builtin_popcountl(_M_w[__i]); + return __result; + } + + unsigned long + _M_do_to_ulong() const; + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const; +#endif + + // find first "on" bit + size_t + _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT; + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT; + }; + + // Definitions of non-inline functions from _Base_bitset. + template + void + _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + + if (__offset == 0) + for (size_t __n = _Nw - 1; __n >= __wshift; --__n) + _M_w[__n] = _M_w[__n - __wshift]; + else + { + const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD + - __offset); + for (size_t __n = _Nw - 1; __n > __wshift; --__n) + _M_w[__n] = ((_M_w[__n - __wshift] << __offset) + | (_M_w[__n - __wshift - 1] >> __sub_offset)); + _M_w[__wshift] = _M_w[0] << __offset; + } + + std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); + } + } + + template + void + _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __limit = _Nw - __wshift - 1; + + if (__offset == 0) + for (size_t __n = 0; __n <= __limit; ++__n) + _M_w[__n] = _M_w[__n + __wshift]; + else + { + const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD + - __offset); + for (size_t __n = 0; __n < __limit; ++__n) + _M_w[__n] = ((_M_w[__n + __wshift] >> __offset) + | (_M_w[__n + __wshift + 1] << __sub_offset)); + _M_w[__limit] = _M_w[_Nw-1] >> __offset; + } + + std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); + } + } + + template + unsigned long + _Base_bitset<_Nw>::_M_do_to_ulong() const + { + for (size_t __i = 1; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong")); + return _M_w[0]; + } + +#if __cplusplus >= 201103L + template + unsigned long long + _Base_bitset<_Nw>::_M_do_to_ullong() const + { + const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long); + for (size_t __i = 1 + __dw; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong")); + + if (__dw) + return _M_w[0] + (static_cast(_M_w[1]) + << _GLIBCXX_BITSET_BITS_PER_WORD); + return _M_w[0]; + } +#endif + + template + size_t + _Base_bitset<_Nw>:: + _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + { + _WordT __thisword = _M_w[__i]; + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + } + // not found, so return an indication of failure. + return __not_found; + } + + template + size_t + _Base_bitset<_Nw>:: + _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT + { + // make bound inclusive + ++__prev; + + // check out of bounds + if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD) + return __not_found; + + // search first word + size_t __i = _S_whichword(__prev); + _WordT __thisword = _M_w[__i]; + + // mask off bits below bound + __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); + + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + + // check subsequent words + __i++; + for (; __i < _Nw; __i++) + { + __thisword = _M_w[__i]; + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + } + // not found, so return an indication of failure. + return __not_found; + } // end _M_do_find_next + + /** + * Base class, specialization for a single word. + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<1> + { + typedef unsigned long _WordT; + _WordT _M_w; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + : _M_w(0) + { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long __val) noexcept +#else + _Base_bitset(unsigned long __val) +#endif + : _M_w(__val) + { } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t) _GLIBCXX_NOEXCEPT + { return _M_w; } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t) const _GLIBCXX_NOEXCEPT + { return _M_w; } + +#if __cplusplus >= 201103L + const _WordT* + _M_getdata() const noexcept + { return &_M_w; } +#endif + + _WordT& + _M_hiword() _GLIBCXX_NOEXCEPT + { return _M_w; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return _M_w; } + + void + _M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w &= __x._M_w; } + + void + _M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w |= __x._M_w; } + + void + _M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w ^= __x._M_w; } + + void + _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { _M_w <<= __shift; } + + void + _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { _M_w >>= __shift; } + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { _M_w = ~_M_w; } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { _M_w = ~static_cast<_WordT>(0); } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { _M_w = 0; } + + bool + _M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT + { return _M_w == __x._M_w; } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { return _M_w == (~static_cast<_WordT>(0) + >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { return _M_w != 0; } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { return __builtin_popcountl(_M_w); } + + unsigned long + _M_do_to_ulong() const _GLIBCXX_NOEXCEPT + { return _M_w; } + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const noexcept + { return _M_w; } +#endif + + size_t + _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT + { + if (_M_w != 0) + return __builtin_ctzl(_M_w); + else + return __not_found; + } + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t __prev, size_t __not_found) const + _GLIBCXX_NOEXCEPT + { + ++__prev; + if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD)) + return __not_found; + + _WordT __x = _M_w >> __prev; + if (__x != 0) + return __builtin_ctzl(__x) + __prev; + else + return __not_found; + } + }; + + /** + * Base class, specialization for no storage (zero-length %bitset). + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<0> + { + typedef unsigned long _WordT; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long) noexcept +#else + _Base_bitset(unsigned long) +#endif + { } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + // This would normally give access to the data. The bounds-checking + // in the bitset class will prevent the user from getting this far, + // but (1) it must still return an lvalue to compile, and (2) the + // user might call _Unchecked_set directly, in which case this /needs/ + // to fail. Let's not penalize zero-length users unless they actually + // make an unchecked call; all the memory ugliness is therefore + // localized to this single should-never-get-this-far function. + _WordT& + _M_getword(size_t) _GLIBCXX_NOEXCEPT + { + __throw_out_of_range(__N("_Base_bitset::_M_getword")); + return *new _WordT; + } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return 0; } + + void + _M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { } + + // Are all empty bitsets equal to each other? Are they equal to + // themselves? How to compare a thing which has no state? What is + // the sound of one zero-length bitset clapping? + bool + _M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT + { return true; } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { return true; } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { return false; } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { return 0; } + + unsigned long + _M_do_to_ulong() const _GLIBCXX_NOEXCEPT + { return 0; } + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const noexcept + { return 0; } +#endif + + // Normally "not found" is the size, but that could also be + // misinterpreted as an index in this corner case. Oh well. + size_t + _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + + size_t + _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + }; + + + // Helper class to zero out the unused high-order bits in the highest word. + template + struct _Sanitize + { + typedef unsigned long _WordT; + + static void + _S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT + { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); } + }; + + template<> + struct _Sanitize<0> + { + typedef unsigned long _WordT; + + static void + _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } + }; + +#if __cplusplus >= 201103L + template + struct _Sanitize_val + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val; } + }; + + template + struct _Sanitize_val<_Nb, true> + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val & ~((~static_cast(0)) << _Nb); } + }; +#endif + + /** + * @brief The %bitset class represents a @e fixed-size sequence of bits. + * @ingroup utilities + * + * (Note that %bitset does @e not meet the formal requirements of a + * container. Mainly, it lacks iterators.) + * + * The template argument, @a Nb, may be any non-negative number, + * specifying the number of bits (e.g., "0", "12", "1024*1024"). + * + * In the general unoptimized case, storage is allocated in word-sized + * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B + * words will be used for storage. B - Nb%B bits are unused. (They are + * the high-order bits in the highest word.) It is a class invariant + * that those unused bits are always zero. + * + * If you think of %bitset as a simple array of bits, be + * aware that your mental picture is reversed: a %bitset behaves + * the same way as bits in integers do, with the bit at index 0 in + * the least significant / right-hand position, and the bit at + * index Nb-1 in the most significant / left-hand position. + * Thus, unlike other containers, a %bitset's index counts from + * right to left, to put it very loosely. + * + * This behavior is preserved when translating to and from strings. For + * example, the first line of the following program probably prints + * b('a') is 0001100001 on a modern ASCII system. + * + * @code + * #include + * #include + * #include + * + * using namespace std; + * + * int main() + * { + * long a = 'a'; + * bitset<10> b(a); + * + * cout << "b('a') is " << b << endl; + * + * ostringstream s; + * s << b; + * string str = s.str(); + * cout << "index 3 in the string is " << str[3] << " but\n" + * << "index 3 in the bitset is " << b[3] << endl; + * } + * @endcode + * + * Also see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_containers.html + * for a description of extensions. + * + * Most of the actual code isn't contained in %bitset<> itself, but in the + * base class _Base_bitset. The base class works with whole words, not with + * individual bits. This allows us to specialize _Base_bitset for the + * important special case where the %bitset is only a single word. + * + * Extra confusion can result due to the fact that the storage for + * _Base_bitset @e is a regular array, and is indexed as such. This is + * carefully encapsulated. + */ + template + class bitset + : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> + { + private: + typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base; + typedef unsigned long _WordT; + + template + void + _M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position) const + { + if (__position > __s.size()) + __throw_out_of_range_fmt(__N("bitset::bitset: __position " + "(which is %zu) > __s.size() " + "(which is %zu)"), + __position, __s.size()); + } + + void _M_check(size_t __position, const char *__s) const + { + if (__position >= _Nb) + __throw_out_of_range_fmt(__N("%s: __position (which is %zu) " + ">= _Nb (which is %zu)"), + __s, __position, _Nb); + } + + void + _M_do_sanitize() _GLIBCXX_NOEXCEPT + { + typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type; + __sanitize_type::_S_do_sanitize(this->_M_hiword()); + } + +#if __cplusplus >= 201103L + friend struct std::hash; +#endif + + public: + /** + * This encapsulates the concept of a single bit. An instance of this + * class is a proxy for an actual bit; this way the individual bit + * operations are done as faster word-size bitwise instructions. + * + * Most users will never need to use this class directly; conversions + * to and from bool are automatic and should be transparent. Overloaded + * operators help to preserve the illusion. + * + * (On a typical system, this bit %reference is 64 + * times the size of an actual bit. Ha.) + */ + class reference + { + friend class bitset; + + _WordT* _M_wp; + size_t _M_bpos; + + // left undefined + reference(); + + public: + reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT + { + _M_wp = &__b._M_getword(__pos); + _M_bpos = _Base::_S_whichbit(__pos); + } + +#if __cplusplus >= 201103L + reference(const reference&) = default; +#endif + + ~reference() _GLIBCXX_NOEXCEPT + { } + + // For b[i] = __x; + reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + if (__x) + *_M_wp |= _Base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Base::_S_maskbit(_M_bpos); + return *this; + } + + // For b[i] = b[__j]; + reference& + operator=(const reference& __j) _GLIBCXX_NOEXCEPT + { + if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos))) + *_M_wp |= _Base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Base::_S_maskbit(_M_bpos); + return *this; + } + + // Flips the bit + bool + operator~() const _GLIBCXX_NOEXCEPT + { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } + + // For __x = b[i]; + operator bool() const _GLIBCXX_NOEXCEPT + { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } + + // For b[i].flip(); + reference& + flip() _GLIBCXX_NOEXCEPT + { + *_M_wp ^= _Base::_S_maskbit(_M_bpos); + return *this; + } + }; + friend class reference; + + // 23.3.5.1 constructors: + /// All bits set to zero. + _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT + { } + + /// Initial bits bitwise-copied from a single word (others set to zero). +#if __cplusplus >= 201103L + constexpr bitset(unsigned long long __val) noexcept + : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { } +#else + bitset(unsigned long __val) + : _Base(__val) + { _M_do_sanitize(); } +#endif + + /** + * Use a subset of a string. + * @param __s A string of @a 0 and @a 1 characters. + * @param __position Index of the first character in @a __s to use; + * defaults to zero. + * @throw std::out_of_range If @a pos is bigger the size of @a __s. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a 0 nor @a 1. + */ + template + explicit + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position = 0) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, + std::basic_string<_CharT, _Traits, _Alloc>::npos, + _CharT('0'), _CharT('1')); + } + + /** + * Use a subset of a string. + * @param __s A string of @a 0 and @a 1 characters. + * @param __position Index of the first character in @a __s to use. + * @param __n The number of characters to copy. + * @throw std::out_of_range If @a __position is bigger the size + * of @a __s. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a 0 nor @a 1. + */ + template + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position, size_t __n) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1')); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position, size_t __n, + _CharT __zero, _CharT __one = _CharT('1')) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, __n, __zero, __one); + } + +#if __cplusplus >= 201103L + /** + * Construct from a character %array. + * @param __str An %array of characters @a zero and @a one. + * @param __n The number of characters to use. + * @param __zero The character corresponding to the value 0. + * @param __one The character corresponding to the value 1. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a __zero nor @a __one. + */ + template + explicit + bitset(const _CharT* __str, + typename std::basic_string<_CharT>::size_type __n + = std::basic_string<_CharT>::npos, + _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) + : _Base() + { + if (!__str) + __throw_logic_error(__N("bitset::bitset(const _CharT*, ...)")); + + if (__n == std::basic_string<_CharT>::npos) + __n = std::char_traits<_CharT>::length(__str); + _M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0, + __n, __zero, + __one); + } +#endif + + // 23.3.5.2 bitset operations: + ///@{ + /** + * Operations on bitsets. + * @param __rhs A same-sized bitset. + * + * These should be self-explanatory. + */ + bitset<_Nb>& + operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_and(__rhs); + return *this; + } + + bitset<_Nb>& + operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_or(__rhs); + return *this; + } + + bitset<_Nb>& + operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_xor(__rhs); + return *this; + } + ///@} + + ///@{ + /** + * Operations on bitsets. + * @param __position The number of places to shift. + * + * These should be self-explanatory. + */ + bitset<_Nb>& + operator<<=(size_t __position) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__position < _Nb, 1)) + { + this->_M_do_left_shift(__position); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); + return *this; + } + + bitset<_Nb>& + operator>>=(size_t __position) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__position < _Nb, 1)) + { + this->_M_do_right_shift(__position); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); + return *this; + } + ///@} + + ///@{ + /** + * These versions of single-bit set, reset, flip, and test are + * extensions from the SGI version. They do no range checking. + * @ingroup SGIextensions + */ + bitset<_Nb>& + _Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT + { + if (__val) + this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); + else + this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); + return *this; + } + + _GLIBCXX_CONSTEXPR bool + _Unchecked_test(size_t __pos) const _GLIBCXX_NOEXCEPT + { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) + != static_cast<_WordT>(0)); } + ///@} + + // Set, reset, and flip. + /** + * @brief Sets every bit to true. + */ + bitset<_Nb>& + set() _GLIBCXX_NOEXCEPT + { + this->_M_do_set(); + this->_M_do_sanitize(); + return *this; + } + + /** + * @brief Sets a given bit to a particular value. + * @param __position The index of the bit. + * @param __val Either true or false, defaults to true. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bitset<_Nb>& + set(size_t __position, bool __val = true) + { + this->_M_check(__position, __N("bitset::set")); + return _Unchecked_set(__position, __val); + } + + /** + * @brief Sets every bit to false. + */ + bitset<_Nb>& + reset() _GLIBCXX_NOEXCEPT + { + this->_M_do_reset(); + return *this; + } + + /** + * @brief Sets a given bit to false. + * @param __position The index of the bit. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + * + * Same as writing @c set(pos,false). + */ + bitset<_Nb>& + reset(size_t __position) + { + this->_M_check(__position, __N("bitset::reset")); + return _Unchecked_reset(__position); + } + + /** + * @brief Toggles every bit to its opposite value. + */ + bitset<_Nb>& + flip() _GLIBCXX_NOEXCEPT + { + this->_M_do_flip(); + this->_M_do_sanitize(); + return *this; + } + + /** + * @brief Toggles a given bit to its opposite value. + * @param __position The index of the bit. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bitset<_Nb>& + flip(size_t __position) + { + this->_M_check(__position, __N("bitset::flip")); + return _Unchecked_flip(__position); + } + + /// See the no-argument flip(). + bitset<_Nb> + operator~() const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this).flip(); } + + ///@{ + /** + * @brief Array-indexing support. + * @param __position Index into the %bitset. + * @return A bool for a const %bitset. For non-const + * bitsets, an instance of the reference proxy class. + * @note These operators do no range checking and throw no exceptions, + * as required by DR 11 to the standard. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already + * resolves DR 11 (items 1 and 2), but does not do the range-checking + * required by that DR's resolution. -pme + * The DR has since been changed: range-checking is a precondition + * (users' responsibility), and these functions must not throw. -pme + */ + reference + operator[](size_t __position) + { return reference(*this, __position); } + + _GLIBCXX_CONSTEXPR bool + operator[](size_t __position) const + { return _Unchecked_test(__position); } + ///@} + + /** + * @brief Returns a numerical interpretation of the %bitset. + * @return The integral equivalent of the bits. + * @throw std::overflow_error If there are too many bits to be + * represented in an @c unsigned @c long. + */ + unsigned long + to_ulong() const + { return this->_M_do_to_ulong(); } + +#if __cplusplus >= 201103L + unsigned long long + to_ullong() const + { return this->_M_do_to_ullong(); } +#endif + + /** + * @brief Returns a character interpretation of the %bitset. + * @return The string equivalent of the bits. + * + * Note the ordering of the bits: decreasing character positions + * correspond to increasing bit positions (see the main class notes for + * an example). + */ + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string() const + { + std::basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result, _CharT('0'), _CharT('1')); + return __result; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + std::basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result, __zero, __one); + return __result; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 853. to_string needs updating with zero and one. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { return to_string<_CharT, _Traits, + std::allocator<_CharT> >(__zero, __one); } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string() const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(); + } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(__zero, __one); + } + + std::basic_string, std::allocator > + to_string() const + { + return to_string, + std::allocator >(); + } + + std::basic_string, std::allocator > + to_string(char __zero, char __one = '1') const + { + return to_string, + std::allocator >(__zero, __one); + } + + // Helper functions for string operations. + template + void + _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, + _CharT, _CharT); + + template + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n, + _CharT __zero, _CharT __one) + { _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n, + __zero, __one); } + + template + void + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&, + _CharT, _CharT) const; + + // NB: Backward compat. + template + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n) + { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); } + + template + void + _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const + { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); } + + /// Returns the number of bits which are set. + size_t + count() const _GLIBCXX_NOEXCEPT + { return this->_M_do_count(); } + + /// Returns the total number of bits. + _GLIBCXX_CONSTEXPR size_t + size() const _GLIBCXX_NOEXCEPT + { return _Nb; } + + ///@{ + /// These comparisons for equality/inequality are, well, @e bitwise. + bool + operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return this->_M_is_equal(__rhs); } + +#if __cpp_impl_three_way_comparison < 201907L + bool + operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return !this->_M_is_equal(__rhs); } +#endif + ///@} + + /** + * @brief Tests the value of a bit. + * @param __position The index of a bit. + * @return The value at @a pos. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bool + test(size_t __position) const + { + this->_M_check(__position, __N("bitset::test")); + return _Unchecked_test(__position); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 693. std::bitset::all() missing. + /** + * @brief Tests whether all the bits are on. + * @return True if all the bits are set. + */ + bool + all() const _GLIBCXX_NOEXCEPT + { return this->template _M_are_all<_Nb>(); } + + /** + * @brief Tests whether any of the bits are on. + * @return True if at least one bit is set. + */ + bool + any() const _GLIBCXX_NOEXCEPT + { return this->_M_is_any(); } + + /** + * @brief Tests whether any of the bits are on. + * @return True if none of the bits are set. + */ + bool + none() const _GLIBCXX_NOEXCEPT + { return !this->_M_is_any(); } + + ///@{ + /// Self-explanatory. + bitset<_Nb> + operator<<(size_t __position) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this) <<= __position; } + + bitset<_Nb> + operator>>(size_t __position) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this) >>= __position; } + ///@} + + /** + * @brief Finds the index of the first "on" bit. + * @return The index of the first bit set, or size() if not found. + * @ingroup SGIextensions + * @sa _Find_next + */ + size_t + _Find_first() const _GLIBCXX_NOEXCEPT + { return this->_M_do_find_first(_Nb); } + + /** + * @brief Finds the index of the next "on" bit after prev. + * @return The index of the next bit set, or size() if not found. + * @param __prev Where to start searching. + * @ingroup SGIextensions + * @sa _Find_first + */ + size_t + _Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT + { return this->_M_do_find_next(__prev, _Nb); } + }; + + // Definitions of non-inline member functions. + template + template + void + bitset<_Nb>:: + _M_copy_from_ptr(const _CharT* __s, size_t __len, + size_t __pos, size_t __n, _CharT __zero, _CharT __one) + { + reset(); + const size_t __nbits = std::min(_Nb, std::min(__n, size_t(__len - __pos))); + for (size_t __i = __nbits; __i > 0; --__i) + { + const _CharT __c = __s[__pos + __nbits - __i]; + if (_Traits::eq(__c, __zero)) + ; + else if (_Traits::eq(__c, __one)) + _Unchecked_set(__i - 1); + else + __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); + } + } + + template + template + void + bitset<_Nb>:: + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s, + _CharT __zero, _CharT __one) const + { + __s.assign(_Nb, __zero); + for (size_t __i = _Nb; __i > 0; --__i) + if (_Unchecked_test(__i - 1)) + _Traits::assign(__s[_Nb - __i], __one); + } + + // 23.3.5.3 bitset operations: + ///@{ + /** + * @brief Global bitwise operations on bitsets. + * @param __x A bitset. + * @param __y A bitset of the same size as @a __x. + * @return A new bitset. + * + * These should be self-explanatory. + */ + template + inline bitset<_Nb> + operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result &= __y; + return __result; + } + + template + inline bitset<_Nb> + operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result |= __y; + return __result; + } + + template + inline bitset<_Nb> + operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result ^= __y; + return __result; + } + ///@} + + ///@{ + /** + * @brief Global I/O operators for bitsets. + * + * Direct I/O between streams and bitsets is supported. Output is + * straightforward. Input will skip whitespace, only accept @a 0 and @a 1 + * characters, and will only extract as many digits as the %bitset will + * hold. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) + { + typedef typename _Traits::char_type char_type; + typedef std::basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::ios_base __ios_base; + + std::basic_string<_CharT, _Traits> __tmp; + __tmp.reserve(_Nb); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 303. Bitset input operator underspecified + const char_type __zero = __is.widen('0'); + const char_type __one = __is.widen('1'); + + typename __ios_base::iostate __state = __ios_base::goodbit; + typename __istream_type::sentry __sentry(__is); + if (__sentry) + { + __try + { + for (size_t __i = _Nb; __i > 0; --__i) + { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) + { + __state |= __ios_base::eofbit; + break; + } + else + { + const char_type __c2 = _Traits::to_char_type(__c1); + if (_Traits::eq(__c2, __zero)) + __tmp.push_back(__zero); + else if (_Traits::eq(__c2, __one)) + __tmp.push_back(__one); + else if (_Traits:: + eq_int_type(__is.rdbuf()->sputbackc(__c2), + __eof)) + { + __state |= __ios_base::failbit; + break; + } + } + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + __is._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __is._M_setstate(__ios_base::badbit); } + } + + if (__tmp.empty() && _Nb) + __state |= __ios_base::failbit; + else + __x._M_copy_from_string(__tmp, static_cast(0), _Nb, + __zero, __one); + if (__state) + __is.setstate(__state); + return __is; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) + { + std::basic_string<_CharT, _Traits> __tmp; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + const ctype<_CharT>& __ct = use_facet >(__os.getloc()); + __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1')); + return __os << __tmp; + } + ///@} + +_GLIBCXX_END_NAMESPACE_CONTAINER +} // namespace std + +#undef _GLIBCXX_BITSET_WORDS +#undef _GLIBCXX_BITSET_BITS_PER_WORD +#undef _GLIBCXX_BITSET_BITS_PER_ULL + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // DR 1182. + /// std::hash specialization for bitset. + template + struct hash<_GLIBCXX_STD_C::bitset<_Nb>> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept + { + const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__; + return std::_Hash_impl::hash(__b._M_getdata(), __clength); + } + }; + + template<> + struct hash<_GLIBCXX_STD_C::bitset<0>> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept + { return 0; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#endif /* _GLIBCXX_BITSET */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset.blob new file mode 100644 index 0000000000000000000000000000000000000000..1327cf4e791c969875c568a270785990a8cfe6b8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@bitset.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert new file mode 100644 index 0000000000000000000000000000000000000000..9f525c6d1f4b833130514360627885f7ac0c5035 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert @@ -0,0 +1,44 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cassert + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c assert.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 19.2 Assertions +// + +// No include guards on this header... + +#pragma GCC system_header + +#include +#include diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert.blob new file mode 100644 index 0000000000000000000000000000000000000000..5db2b5005aa0eeee1346bb29956247e25dfa27cd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cassert.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex new file mode 100644 index 0000000000000000000000000000000000000000..c950b8771fc873b866e86f1b6a0d4847353f3779 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex @@ -0,0 +1,42 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ccomplex + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CCOMPLEX +#define _GLIBCXX_CCOMPLEX 1 + +#if __cplusplus < 201103L +# include +#endif + +extern "C++" { +#include +} + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex.blob new file mode 100644 index 0000000000000000000000000000000000000000..7f326e854cca2be827752e9faf85e38249525aef Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ccomplex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype new file mode 100644 index 0000000000000000000000000000000000000000..b7af41a182f962aa2cc823f03d38e45ebe27984a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype @@ -0,0 +1,94 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cctype + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c ctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CCTYPE +#define _GLIBCXX_CCTYPE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef isalnum +#undef isalpha +#undef iscntrl +#undef isdigit +#undef isgraph +#undef islower +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isxdigit +#undef tolower +#undef toupper + +namespace std +{ + using ::isalnum; + using ::isalpha; + using ::iscntrl; + using ::isdigit; + using ::isgraph; + using ::islower; + using ::isprint; + using ::ispunct; + using ::isspace; + using ::isupper; + using ::isxdigit; + using ::tolower; + using ::toupper; +} // namespace std + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_C99_CTYPE_TR1 + +#undef isblank + +namespace std +{ + using ::isblank; +} // namespace std + +#endif // _GLIBCXX_USE_C99_CTYPE_TR1 + +#endif // C++11 + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype.blob new file mode 100644 index 0000000000000000000000000000000000000000..29971c5a471118069756973661ff5217edd8e027 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cctype.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno new file mode 100644 index 0000000000000000000000000000000000000000..afaeae68a6106d9de39158fe6138eee2313bd853 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno @@ -0,0 +1,52 @@ +// The -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cerrno + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c errno.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 19.3 Error numbers +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CERRNO +#define _GLIBCXX_CERRNO 1 + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef errno +#define errno errno +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno.blob new file mode 100644 index 0000000000000000000000000000000000000000..0a94ed4438d7afe292bf82432e9fcc393db4d797 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cerrno.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv new file mode 100644 index 0000000000000000000000000000000000000000..d415d47ea4583dec543988e2a85f67a1548b30ac --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv @@ -0,0 +1,84 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cfenv + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CFENV +#define _GLIBCXX_CFENV 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +#if _GLIBCXX_HAVE_FENV_H +# include +#endif + +#ifdef _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +namespace std +{ + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; +} // namespace std + +#endif // _GLIBCXX_USE_C99_FENV_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_CFENV diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv.blob new file mode 100644 index 0000000000000000000000000000000000000000..402ecaa8100c24ebf1c26b4b087d2480937f7c8f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfenv.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat new file mode 100644 index 0000000000000000000000000000000000000000..b07d894a9918e76bdb487b59f07060074e82855a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat @@ -0,0 +1,56 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cfloat + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c float.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CFLOAT +#define _GLIBCXX_CFLOAT 1 + +#if __cplusplus >= 201103L +# ifndef DECIMAL_DIG +# define DECIMAL_DIG __DECIMAL_DIG__ +# endif +# ifndef FLT_EVAL_METHOD +# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# endif +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat.blob new file mode 100644 index 0000000000000000000000000000000000000000..42ddd350117ecbc51daab3d7f7363365955c85dd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cfloat.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono new file mode 100644 index 0000000000000000000000000000000000000000..3732a40962acd292f00e4257e47e315b1eb336dc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono @@ -0,0 +1,2186 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/chrono + * This is a Standard C++ Library header. + * @ingroup chrono + */ + +#ifndef _GLIBCXX_CHRONO +#define _GLIBCXX_CHRONO 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#if __cplusplus > 201703L +# include // ostringstream +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup chrono Time + * @ingroup utilities + * + * Classes and functions for time. + * + * @since C++11 + */ + + /** @namespace std::chrono + * @brief ISO C++ 2011 namespace for date and time utilities + * @ingroup chrono + */ + namespace chrono + { +#if __cplusplus >= 202002L + /// @addtogroup chrono + /// @{ + struct local_t { }; + template + using local_time = time_point; + using local_seconds = local_time; + using local_days = local_time; + + class utc_clock; + class tai_clock; + class gps_clock; + + template + using utc_time = time_point; + using utc_seconds = utc_time; + + template + using tai_time = time_point; + using tai_seconds = tai_time; + + template + using gps_time = time_point; + using gps_seconds = gps_time; + + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + + struct leap_second_info + { + bool is_leap_second; + seconds elapsed; + }; + + // CALENDRICAL TYPES + + // CLASS DECLARATIONS + class day; + class month; + class year; + class weekday; + class weekday_indexed; + class weekday_last; + class month_day; + class month_day_last; + class month_weekday; + class month_weekday_last; + class year_month; + class year_month_day; + class year_month_day_last; + class year_month_weekday; + class year_month_weekday_last; + + struct last_spec + { + explicit last_spec() = default; + + friend constexpr month_day_last + operator/(int __m, last_spec) noexcept; + + friend constexpr month_day_last + operator/(last_spec, int __m) noexcept; + }; + + inline constexpr last_spec last{}; + + namespace __detail + { + // Compute the remainder of the Euclidean division of __n divided by __d. + // Euclidean division truncates toward negative infinity and always + // produces a remainder in the range of [0,__d-1] (whereas standard + // division truncates toward zero and yields a nonpositive remainder + // for negative __n). + constexpr unsigned + __modulo(long long __n, unsigned __d) + { + if (__n >= 0) + return __n % __d; + else + return (__d + (__n % __d)) % __d; + } + + inline constexpr unsigned __days_per_month[12] + = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + } + + // DAY + + class day + { + private: + unsigned char _M_d; + + public: + day() = default; + + explicit constexpr + day(unsigned __d) noexcept + : _M_d(__d) + { } + + constexpr day& + operator++() noexcept + { + ++_M_d; + return *this; + } + + constexpr day + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr day& + operator--() noexcept + { + --_M_d; + return *this; + } + + constexpr day + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr day& + operator+=(const days& __d) noexcept + { + *this = *this + __d; + return *this; + } + + constexpr day& + operator-=(const days& __d) noexcept + { + *this = *this - __d; + return *this; + } + + constexpr explicit + operator unsigned() const noexcept + { return _M_d; } + + constexpr bool + ok() const noexcept + { return 1 <= _M_d && _M_d <= 31; } + + friend constexpr bool + operator==(const day& __x, const day& __y) noexcept + { return unsigned{__x} == unsigned{__y}; } + + friend constexpr strong_ordering + operator<=>(const day& __x, const day& __y) noexcept + { return unsigned{__x} <=> unsigned{__y}; } + + friend constexpr day + operator+(const day& __x, const days& __y) noexcept + { return day(unsigned{__x} + __y.count()); } + + friend constexpr day + operator+(const days& __x, const day& __y) noexcept + { return __y + __x; } + + friend constexpr day + operator-(const day& __x, const days& __y) noexcept + { return __x + -__y; } + + friend constexpr days + operator-(const day& __x, const day& __y) noexcept + { return days{int(unsigned{__x}) - int(unsigned{__y})}; } + + friend constexpr month_day + operator/(const month& __m, const day& __d) noexcept; + + friend constexpr month_day + operator/(int __m, const day& __d) noexcept; + + friend constexpr month_day + operator/(const day& __d, const month& __m) noexcept; + + friend constexpr month_day + operator/(const day& __d, int __m) noexcept; + + friend constexpr year_month_day + operator/(const year_month& __ym, const day& __d) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + // MONTH + + class month + { + private: + unsigned char _M_m; + + public: + month() = default; + + explicit constexpr + month(unsigned __m) noexcept + : _M_m(__m) + { } + + constexpr month& + operator++() noexcept + { + *this += months{1}; + return *this; + } + + constexpr month + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr month& + operator--() noexcept + { + *this -= months{1}; + return *this; + } + + constexpr month + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr month& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + constexpr month& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + explicit constexpr + operator unsigned() const noexcept + { return _M_m; } + + constexpr bool + ok() const noexcept + { return 1 <= _M_m && _M_m <= 12; } + + friend constexpr bool + operator==(const month& __x, const month& __y) noexcept + { return unsigned{__x} == unsigned{__y}; } + + friend constexpr strong_ordering + operator<=>(const month& __x, const month& __y) noexcept + { return unsigned{__x} <=> unsigned{__y}; } + + friend constexpr month + operator+(const month& __x, const months& __y) noexcept + { + auto __n = static_cast(unsigned{__x}) + (__y.count() - 1); + return month{__detail::__modulo(__n, 12) + 1}; + } + + friend constexpr month + operator+(const months& __x, const month& __y) noexcept + { return __y + __x; } + + friend constexpr month + operator-(const month& __x, const months& __y) noexcept + { return __x + -__y; } + + friend constexpr months + operator-(const month& __x, const month& __y) noexcept + { + const auto __dm = int(unsigned(__x)) - int(unsigned(__y)); + return months{__dm < 0 ? 12 + __dm : __dm}; + } + + friend constexpr year_month + operator/(const year& __y, const month& __m) noexcept; + + friend constexpr month_day + operator/(const month& __m, int __d) noexcept; + + friend constexpr month_day_last + operator/(const month& __m, last_spec) noexcept; + + friend constexpr month_day_last + operator/(last_spec, const month& __m) noexcept; + + friend constexpr month_weekday + operator/(const month& __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, const month& __m) noexcept; + + friend constexpr month_weekday_last + operator/(const month& __m, const weekday_last& __wdl) noexcept; + + friend constexpr month_weekday_last + operator/(const weekday_last& __wdl, const month& __m) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + inline constexpr month January{1}; + inline constexpr month February{2}; + inline constexpr month March{3}; + inline constexpr month April{4}; + inline constexpr month May{5}; + inline constexpr month June{6}; + inline constexpr month July{7}; + inline constexpr month August{8}; + inline constexpr month September{9}; + inline constexpr month October{10}; + inline constexpr month November{11}; + inline constexpr month December{12}; + + // YEAR + + class year + { + private: + short _M_y; + + public: + year() = default; + + explicit constexpr + year(int __y) noexcept + : _M_y{static_cast(__y)} + { } + + static constexpr year + min() noexcept + { return year{-32767}; } + + static constexpr year + max() noexcept + { return year{32767}; } + + constexpr year& + operator++() noexcept + { + ++_M_y; + return *this; + } + + constexpr year + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr year& + operator--() noexcept + { + --_M_y; + return *this; + } + + constexpr year + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr year& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr year + operator+() const noexcept + { return *this; } + + constexpr year + operator-() const noexcept + { return year{-_M_y}; } + + constexpr bool + is_leap() const noexcept + { + // Testing divisibility by 100 first gives better performance, that is, + // return (_M_y % 100 != 0 || _M_y % 400 == 0) && _M_y % 4 == 0; + + // It gets even faster if _M_y is in [-536870800, 536870999] + // (which is the case here) and _M_y % 100 is replaced by + // __is_multiple_of_100 below. + + // References: + // [1] https://github.com/cassioneri/calendar + // [2] https://accu.org/journals/overload/28/155/overload155.pdf#page=16 + + // Furthermore, if y%100 == 0, then y%400==0 is equivalent to y%16==0, + // so we can simplify it to (!mult_100 && y % 4 == 0) || y % 16 == 0, + // which is equivalent to (y & (mult_100 ? 15 : 3)) == 0. + // See https://gcc.gnu.org/pipermail/libstdc++/2021-June/052815.html + + constexpr uint32_t __multiplier = 42949673; + constexpr uint32_t __bound = 42949669; + constexpr uint32_t __max_dividend = 1073741799; + constexpr uint32_t __offset = __max_dividend / 2 / 100 * 100; + const bool __is_multiple_of_100 + = __multiplier * (_M_y + __offset) < __bound; + return (_M_y & (__is_multiple_of_100 ? 15 : 3)) == 0; + } + + explicit constexpr + operator int() const noexcept + { return _M_y; } + + constexpr bool + ok() const noexcept + { return min()._M_y <= _M_y && _M_y <= max()._M_y; } + + friend constexpr bool + operator==(const year& __x, const year& __y) noexcept + { return int{__x} == int{__y}; } + + friend constexpr strong_ordering + operator<=>(const year& __x, const year& __y) noexcept + { return int{__x} <=> int{__y}; } + + friend constexpr year + operator+(const year& __x, const years& __y) noexcept + { return year{int{__x} + static_cast(__y.count())}; } + + friend constexpr year + operator+(const years& __x, const year& __y) noexcept + { return __y + __x; } + + friend constexpr year + operator-(const year& __x, const years& __y) noexcept + { return __x + -__y; } + + friend constexpr years + operator-(const year& __x, const year& __y) noexcept + { return years{int{__x} - int{__y}}; } + + friend constexpr year_month + operator/(const year& __y, int __m) noexcept; + + friend constexpr year_month_day + operator/(const year& __y, const month_day& __md) noexcept; + + friend constexpr year_month_day + operator/(const month_day& __md, const year& __y) noexcept; + + friend constexpr year_month_day_last + operator/(const year& __y, const month_day_last& __mdl) noexcept; + + friend constexpr year_month_day_last + operator/(const month_day_last& __mdl, const year& __y) noexcept; + + friend constexpr year_month_weekday + operator/(const year& __y, const month_weekday& __mwd) noexcept; + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, const year& __y) noexcept; + + friend constexpr year_month_weekday_last + operator/(const year& __y, const month_weekday_last& __mwdl) noexcept; + + friend constexpr year_month_weekday_last + operator/(const month_weekday_last& __mwdl, const year& __y) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + // WEEKDAY + + class weekday + { + private: + unsigned char _M_wd; + + static constexpr weekday + _S_from_days(const days& __d) + { + auto __n = __d.count(); + return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6); + } + + public: + weekday() = default; + + explicit constexpr + weekday(unsigned __wd) noexcept + : _M_wd(__wd == 7 ? 0 : __wd) // __wd % 7 ? + { } + + constexpr + weekday(const sys_days& __dp) noexcept + : weekday{_S_from_days(__dp.time_since_epoch())} + { } + + explicit constexpr + weekday(const local_days& __dp) noexcept + : weekday{sys_days{__dp.time_since_epoch()}} + { } + + constexpr weekday& + operator++() noexcept + { + *this += days{1}; + return *this; + } + + constexpr weekday + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr weekday& + operator--() noexcept + { + *this -= days{1}; + return *this; + } + + constexpr weekday + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr weekday& + operator+=(const days& __d) noexcept + { + *this = *this + __d; + return *this; + } + + constexpr weekday& + operator-=(const days& __d) noexcept + { + *this = *this - __d; + return *this; + } + + constexpr unsigned + c_encoding() const noexcept + { return _M_wd; } + + constexpr unsigned + iso_encoding() const noexcept + { return _M_wd == 0u ? 7u : _M_wd; } + + constexpr bool + ok() const noexcept + { return _M_wd <= 6; } + + constexpr weekday_indexed + operator[](unsigned __index) const noexcept; + + constexpr weekday_last + operator[](last_spec) const noexcept; + + friend constexpr bool + operator==(const weekday& __x, const weekday& __y) noexcept + { return __x._M_wd == __y._M_wd; } + + friend constexpr weekday + operator+(const weekday& __x, const days& __y) noexcept + { + auto __n = static_cast(__x._M_wd) + __y.count(); + return weekday{__detail::__modulo(__n, 7)}; + } + + friend constexpr weekday + operator+(const days& __x, const weekday& __y) noexcept + { return __y + __x; } + + friend constexpr weekday + operator-(const weekday& __x, const days& __y) noexcept + { return __x + -__y; } + + friend constexpr days + operator-(const weekday& __x, const weekday& __y) noexcept + { + auto __n = static_cast(__x._M_wd) - __y._M_wd; + return days{__detail::__modulo(__n, 7)}; + } + + // TODO: operator<<, from_stream. + }; + + inline constexpr weekday Sunday{0}; + inline constexpr weekday Monday{1}; + inline constexpr weekday Tuesday{2}; + inline constexpr weekday Wednesday{3}; + inline constexpr weekday Thursday{4}; + inline constexpr weekday Friday{5}; + inline constexpr weekday Saturday{6}; + + // WEEKDAY_INDEXED + + class weekday_indexed + { + private: + chrono::weekday _M_wd; + unsigned char _M_index; + + public: + weekday_indexed() = default; + + constexpr + weekday_indexed(const chrono::weekday& __wd, unsigned __index) noexcept + : _M_wd(__wd), _M_index(__index) + { } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wd; } + + constexpr unsigned + index() const noexcept + { return _M_index; }; + + constexpr bool + ok() const noexcept + { return _M_wd.ok() && 1 <= _M_index && _M_index <= 5; } + + friend constexpr bool + operator==(const weekday_indexed& __x, const weekday_indexed& __y) noexcept + { return __x.weekday() == __y.weekday() && __x.index() == __y.index(); } + + friend constexpr month_weekday + operator/(const month& __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(int __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, const month& __m) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, int __m) noexcept; + + friend constexpr year_month_weekday + operator/(const year_month& __ym, const weekday_indexed& __wdi) noexcept; + + // TODO: Implement operator<<. + }; + + constexpr weekday_indexed + weekday::operator[](unsigned __index) const noexcept + { return {*this, __index}; } + + // WEEKDAY_LAST + + class weekday_last + { + private: + chrono::weekday _M_wd; + + public: + explicit constexpr + weekday_last(const chrono::weekday& __wd) noexcept + : _M_wd{__wd} + { } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wd; } + + constexpr bool + ok() const noexcept + { return _M_wd.ok(); } + + friend constexpr bool + operator==(const weekday_last& __x, const weekday_last& __y) noexcept + { return __x.weekday() == __y.weekday(); } + + friend constexpr month_weekday_last + operator/(int __m, const weekday_last& __wdl) noexcept; + + friend constexpr month_weekday_last + operator/(const weekday_last& __wdl, int __m) noexcept; + + friend constexpr year_month_weekday_last + operator/(const year_month& __ym, const weekday_last& __wdl) noexcept; + + // TODO: Implement operator<<. + }; + + constexpr weekday_last + weekday::operator[](last_spec) const noexcept + { return weekday_last{*this}; } + + // MONTH_DAY + + class month_day + { + private: + chrono::month _M_m; + chrono::day _M_d; + + public: + month_day() = default; + + constexpr + month_day(const chrono::month& __m, const chrono::day& __d) noexcept + : _M_m{__m}, _M_d{__d} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::day + day() const noexcept + { return _M_d; } + + constexpr bool + ok() const noexcept + { + return _M_m.ok() + && 1u <= unsigned(_M_d) + && unsigned(_M_d) <= __detail::__days_per_month[unsigned(_M_m) - 1]; + } + + friend constexpr bool + operator==(const month_day& __x, const month_day& __y) noexcept + { return __x.month() == __y.month() && __x.day() == __y.day(); } + + friend constexpr strong_ordering + operator<=>(const month_day& __x, const month_day& __y) noexcept + = default; + + friend constexpr month_day + operator/(const chrono::month& __m, const chrono::day& __d) noexcept + { return {__m, __d}; } + + friend constexpr month_day + operator/(const chrono::month& __m, int __d) noexcept + { return {__m, chrono::day(unsigned(__d))}; } + + friend constexpr month_day + operator/(int __m, const chrono::day& __d) noexcept + { return {chrono::month(unsigned(__m)), __d}; } + + friend constexpr month_day + operator/(const chrono::day& __d, const chrono::month& __m) noexcept + { return {__m, __d}; } + + friend constexpr month_day + operator/(const chrono::day& __d, int __m) noexcept + { return {chrono::month(unsigned(__m)), __d}; } + + friend constexpr year_month_day + operator/(int __y, const month_day& __md) noexcept; + + friend constexpr year_month_day + operator/(const month_day& __md, int __y) noexcept; + + // TODO: Implement operator<<, from_stream. + }; + + // MONTH_DAY_LAST + + class month_day_last + { + private: + chrono::month _M_m; + + public: + explicit constexpr + month_day_last(const chrono::month& __m) noexcept + : _M_m{__m} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr bool + ok() const noexcept + { return _M_m.ok(); } + + friend constexpr bool + operator==(const month_day_last& __x, const month_day_last& __y) noexcept + { return __x.month() == __y.month(); } + + friend constexpr strong_ordering + operator<=>(const month_day_last& __x, const month_day_last& __y) noexcept + = default; + + friend constexpr month_day_last + operator/(const chrono::month& __m, last_spec) noexcept + { return month_day_last{__m}; } + + friend constexpr month_day_last + operator/(int __m, last_spec) noexcept + { return chrono::month(unsigned(__m)) / last; } + + friend constexpr month_day_last + operator/(last_spec, const chrono::month& __m) noexcept + { return __m / last; } + + friend constexpr month_day_last + operator/(last_spec, int __m) noexcept + { return __m / last; } + + friend constexpr year_month_day_last + operator/(int __y, const month_day_last& __mdl) noexcept; + + friend constexpr year_month_day_last + operator/(const month_day_last& __mdl, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // MONTH_WEEKDAY + + class month_weekday + { + private: + chrono::month _M_m; + chrono::weekday_indexed _M_wdi; + + public: + constexpr + month_weekday(const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + : _M_m{__m}, _M_wdi{__wdi} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday_indexed + weekday_indexed() const noexcept + { return _M_wdi; } + + constexpr bool + ok() const noexcept + { return _M_m.ok() && _M_wdi.ok(); } + + friend constexpr bool + operator==(const month_weekday& __x, const month_weekday& __y) noexcept + { + return __x.month() == __y.month() + && __x.weekday_indexed() == __y.weekday_indexed(); + } + + friend constexpr month_weekday + operator/(const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + { return {__m, __wdi}; } + + friend constexpr month_weekday + operator/(int __m, const chrono::weekday_indexed& __wdi) noexcept + { return chrono::month(unsigned(__m)) / __wdi; } + + friend constexpr month_weekday + operator/(const chrono::weekday_indexed& __wdi, + const chrono::month& __m) noexcept + { return __m / __wdi; } + + friend constexpr month_weekday + operator/(const chrono::weekday_indexed& __wdi, int __m) noexcept + { return __m / __wdi; } + + friend constexpr year_month_weekday + operator/(int __y, const month_weekday& __mwd) noexcept; + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // MONTH_WEEKDAY_LAST + + class month_weekday_last + { + private: + chrono::month _M_m; + chrono::weekday_last _M_wdl; + + public: + constexpr + month_weekday_last(const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + :_M_m{__m}, _M_wdl{__wdl} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday_last + weekday_last() const noexcept + { return _M_wdl; } + + constexpr bool + ok() const noexcept + { return _M_m.ok() && _M_wdl.ok(); } + + friend constexpr bool + operator==(const month_weekday_last& __x, + const month_weekday_last& __y) noexcept + { + return __x.month() == __y.month() + && __x.weekday_last() == __y.weekday_last(); + } + + friend constexpr month_weekday_last + operator/(const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + { return {__m, __wdl}; } + + friend constexpr month_weekday_last + operator/(int __m, const chrono::weekday_last& __wdl) noexcept + { return chrono::month(unsigned(__m)) / __wdl; } + + friend constexpr month_weekday_last + operator/(const chrono::weekday_last& __wdl, + const chrono::month& __m) noexcept + { return __m / __wdl; } + + friend constexpr month_weekday_last + operator/(const chrono::weekday_last& __wdl, int __m) noexcept + { return chrono::month(unsigned(__m)) / __wdl; } + + friend constexpr year_month_weekday_last + operator/(int __y, const month_weekday_last& __mwdl) noexcept; + + friend constexpr year_month_weekday_last + operator/(const month_weekday_last& __mwdl, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // YEAR_MONTH + + namespace __detail + { + // [time.cal.ym], [time.cal.ymd], etc constrain the 'months'-based + // addition/subtraction operator overloads like so: + // + // Constraints: if the argument supplied by the caller for the months + // parameter is convertible to years, its implicit conversion sequence + // to years is worse than its implicit conversion sequence to months. + // + // We realize this constraint by templatizing the 'months'-based + // overloads (using a dummy defaulted template parameter), so that + // overload resolution doesn't select the 'months'-based overload unless + // the implicit conversion sequence to 'months' is better than that to + // 'years'. + using __months_years_conversion_disambiguator = void; + } + + class year_month + { + private: + chrono::year _M_y; + chrono::month _M_m; + + public: + year_month() = default; + + constexpr + year_month(const chrono::year& __y, const chrono::month& __m) noexcept + : _M_y{__y}, _M_m{__m} + { } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + template + constexpr year_month& + operator+=(const months& __dm) noexcept + { + *this = *this + __dm; + return *this; + } + + template + constexpr year_month& + operator-=(const months& __dm) noexcept + { + *this = *this - __dm; + return *this; + } + + constexpr year_month& + operator+=(const years& __dy) noexcept + { + *this = *this + __dy; + return *this; + } + + constexpr year_month& + operator-=(const years& __dy) noexcept + { + *this = *this - __dy; + return *this; + } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_m.ok(); } + + friend constexpr bool + operator==(const year_month& __x, const year_month& __y) noexcept + { return __x.year() == __y.year() && __x.month() == __y.month(); } + + friend constexpr strong_ordering + operator<=>(const year_month& __x, const year_month& __y) noexcept + = default; + + template + friend constexpr year_month + operator+(const year_month& __ym, const months& __dm) noexcept + { + // TODO: Optimize? + auto __m = __ym.month() + __dm; + auto __i = int(unsigned(__ym.month())) - 1 + __dm.count(); + auto __y = (__i < 0 + ? __ym.year() + years{(__i - 11) / 12} + : __ym.year() + years{__i / 12}); + return __y / __m; + } + + template + friend constexpr year_month + operator+(const months& __dm, const year_month& __ym) noexcept + { return __ym + __dm; } + + template + friend constexpr year_month + operator-(const year_month& __ym, const months& __dm) noexcept + { return __ym + -__dm; } + + friend constexpr months + operator-(const year_month& __x, const year_month& __y) noexcept + { + return (__x.year() - __y.year() + + months{static_cast(unsigned{__x.month()}) + - static_cast(unsigned{__y.month()})}); + } + + friend constexpr year_month + operator+(const year_month& __ym, const years& __dy) noexcept + { return (__ym.year() + __dy) / __ym.month(); } + + friend constexpr year_month + operator+(const years& __dy, const year_month& __ym) noexcept + { return __ym + __dy; } + + friend constexpr year_month + operator-(const year_month& __ym, const years& __dy) noexcept + { return __ym + -__dy; } + + friend constexpr year_month + operator/(const chrono::year& __y, const chrono::month& __m) noexcept + { return {__y, __m}; } + + friend constexpr year_month + operator/(const chrono::year& __y, int __m) noexcept + { return {__y, chrono::month(unsigned(__m))}; } + + friend constexpr year_month_day + operator/(const year_month& __ym, int __d) noexcept; + + friend constexpr year_month_day_last + operator/(const year_month& __ym, last_spec) noexcept; + + // TODO: Implement operator<<, from_stream. + }; + + // YEAR_MONTH_DAY + + class year_month_day + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::day _M_d; + + static constexpr year_month_day _S_from_days(const days& __dp) noexcept; + + constexpr days _M_days_since_epoch() const noexcept; + + public: + year_month_day() = default; + + constexpr + year_month_day(const chrono::year& __y, const chrono::month& __m, + const chrono::day& __d) noexcept + : _M_y{__y}, _M_m{__m}, _M_d{__d} + { } + + constexpr + year_month_day(const year_month_day_last& __ymdl) noexcept; + + constexpr + year_month_day(const sys_days& __dp) noexcept + : year_month_day(_S_from_days(__dp.time_since_epoch())) + { } + + explicit constexpr + year_month_day(const local_days& __dp) noexcept + : year_month_day(sys_days{__dp.time_since_epoch()}) + { } + + template + constexpr year_month_day& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_day& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_day& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_day& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::day + day() const noexcept + { return _M_d; } + + constexpr + operator sys_days() const noexcept + { return sys_days{_M_days_since_epoch()}; } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool ok() const noexcept; + + friend constexpr bool + operator==(const year_month_day& __x, const year_month_day& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.day() == __y.day(); + } + + friend constexpr strong_ordering + operator<=>(const year_month_day& __x, const year_month_day& __y) noexcept + = default; + + template + friend constexpr year_month_day + operator+(const year_month_day& __ymd, const months& __dm) noexcept + { return (__ymd.year() / __ymd.month() + __dm) / __ymd.day(); } + + template + friend constexpr year_month_day + operator+(const months& __dm, const year_month_day& __ymd) noexcept + { return __ymd + __dm; } + + friend constexpr year_month_day + operator+(const year_month_day& __ymd, const years& __dy) noexcept + { return (__ymd.year() + __dy) / __ymd.month() / __ymd.day(); } + + friend constexpr year_month_day + operator+(const years& __dy, const year_month_day& __ymd) noexcept + { return __ymd + __dy; } + + template + friend constexpr year_month_day + operator-(const year_month_day& __ymd, const months& __dm) noexcept + { return __ymd + -__dm; } + + friend constexpr year_month_day + operator-(const year_month_day& __ymd, const years& __dy) noexcept + { return __ymd + -__dy; } + + friend constexpr year_month_day + operator/(const year_month& __ym, const chrono::day& __d) noexcept + { return {__ym.year(), __ym.month(), __d}; } + + friend constexpr year_month_day + operator/(const year_month& __ym, int __d) noexcept + { return __ym / chrono::day{unsigned(__d)}; } + + friend constexpr year_month_day + operator/(const chrono::year& __y, const month_day& __md) noexcept + { return __y / __md.month() / __md.day(); } + + friend constexpr year_month_day + operator/(int __y, const month_day& __md) noexcept + { return chrono::year{__y} / __md; } + + friend constexpr year_month_day + operator/(const month_day& __md, const chrono::year& __y) noexcept + { return __y / __md; } + + friend constexpr year_month_day + operator/(const month_day& __md, int __y) noexcept + { return chrono::year(__y) / __md; } + + // TODO: Implement operator<<, from_stream. + }; + + // Construct from days since 1970/01/01. + // Proposition 6.3 of Neri and Schneider, + // "Euclidean Affine Functions and Applications to Calendar Algorithms". + // https://arxiv.org/abs/2102.06959 + constexpr year_month_day + year_month_day::_S_from_days(const days& __dp) noexcept + { + constexpr auto __z2 = static_cast(-1468000); + constexpr auto __r2_e3 = static_cast(536895458); + + const auto __r0 = static_cast(__dp.count()) + __r2_e3; + + const auto __n1 = 4 * __r0 + 3; + const auto __q1 = __n1 / 146097; + const auto __r1 = __n1 % 146097 / 4; + + constexpr auto __p32 = static_cast(1) << 32; + const auto __n2 = 4 * __r1 + 3; + const auto __u2 = static_cast(2939745) * __n2; + const auto __q2 = static_cast(__u2 / __p32); + const auto __r2 = static_cast(__u2 % __p32) / 2939745 / 4; + + constexpr auto __p16 = static_cast(1) << 16; + const auto __n3 = 2141 * __r2 + 197913; + const auto __q3 = __n3 / __p16; + const auto __r3 = __n3 % __p16 / 2141; + + const auto __y0 = 100 * __q1 + __q2; + const auto __m0 = __q3; + const auto __d0 = __r3; + + const auto __j = __r2 >= 306; + const auto __y1 = __y0 + __j; + const auto __m1 = __j ? __m0 - 12 : __m0; + const auto __d1 = __d0 + 1; + + return year_month_day{chrono::year{static_cast(__y1 + __z2)}, + chrono::month{__m1}, chrono::day{__d1}}; + } + + // Days since 1970/01/01. + // Proposition 6.2 of Neri and Schneider, + // "Euclidean Affine Functions and Applications to Calendar Algorithms". + // https://arxiv.org/abs/2102.06959 + constexpr days + year_month_day::_M_days_since_epoch() const noexcept + { + auto constexpr __z2 = static_cast(-1468000); + auto constexpr __r2_e3 = static_cast(536895458); + + const auto __y1 = static_cast(static_cast(_M_y)) - __z2; + const auto __m1 = static_cast(static_cast(_M_m)); + const auto __d1 = static_cast(static_cast(_M_d)); + + const auto __j = static_cast(__m1 < 3); + const auto __y0 = __y1 - __j; + const auto __m0 = __j ? __m1 + 12 : __m1; + const auto __d0 = __d1 - 1; + + const auto __q1 = __y0 / 100; + const auto __yc = 1461 * __y0 / 4 - __q1 + __q1 / 4; + const auto __mc = (979 *__m0 - 2919) / 32; + const auto __dc = __d0; + + return days{static_cast(__yc + __mc + __dc - __r2_e3)}; + } + + // YEAR_MONTH_DAY_LAST + + class year_month_day_last + { + private: + chrono::year _M_y; + chrono::month_day_last _M_mdl; + + public: + constexpr + year_month_day_last(const chrono::year& __y, + const chrono::month_day_last& __mdl) noexcept + : _M_y{__y}, _M_mdl{__mdl} + { } + + template + constexpr year_month_day_last& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_day_last& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_day_last& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_day_last& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_mdl.month(); } + + constexpr chrono::month_day_last + month_day_last() const noexcept + { return _M_mdl; } + + // Return A day representing the last day of this year, month pair. + constexpr chrono::day + day() const noexcept + { + const auto __m = static_cast(month()); + + // Excluding February, the last day of month __m is either 30 or 31 or, + // in another words, it is 30 + b = 30 | b, where b is in {0, 1}. + + // If __m in {1, 3, 4, 5, 6, 7}, then b is 1 if, and only if __m is odd. + // Hence, b = __m & 1 = (__m ^ 0) & 1. + + // If __m in {8, 9, 10, 11, 12}, then b is 1 if, and only if __m is even. + // Hence, b = (__m ^ 1) & 1. + + // Therefore, b = (__m ^ c) & 1, where c = 0, if __m < 8, or c = 1 if + // __m >= 8, that is, c = __m >> 3. + + // The above mathematically justifies this implementation whose + // performance does not depend on look-up tables being on the L1 cache. + return chrono::day{__m != 2 ? ((__m ^ (__m >> 3)) & 1) | 30 + : _M_y.is_leap() ? 29 : 28}; + } + + constexpr + operator sys_days() const noexcept + { return sys_days{year() / month() / day()}; } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_mdl.ok(); } + + friend constexpr bool + operator==(const year_month_day_last& __x, + const year_month_day_last& __y) noexcept + { + return __x.year() == __y.year() + && __x.month_day_last() == __y.month_day_last(); + } + + friend constexpr strong_ordering + operator<=>(const year_month_day_last& __x, + const year_month_day_last& __y) noexcept + = default; + + template + friend constexpr year_month_day_last + operator+(const year_month_day_last& __ymdl, + const months& __dm) noexcept + { return (__ymdl.year() / __ymdl.month() + __dm) / last; } + + template + friend constexpr year_month_day_last + operator+(const months& __dm, + const year_month_day_last& __ymdl) noexcept + { return __ymdl + __dm; } + + template + friend constexpr year_month_day_last + operator-(const year_month_day_last& __ymdl, + const months& __dm) noexcept + { return __ymdl + -__dm; } + + friend constexpr year_month_day_last + operator+(const year_month_day_last& __ymdl, + const years& __dy) noexcept + { return {__ymdl.year() + __dy, __ymdl.month_day_last()}; } + + friend constexpr year_month_day_last + operator+(const years& __dy, + const year_month_day_last& __ymdl) noexcept + { return __ymdl + __dy; } + + friend constexpr year_month_day_last + operator-(const year_month_day_last& __ymdl, + const years& __dy) noexcept + { return __ymdl + -__dy; } + + friend constexpr year_month_day_last + operator/(const year_month& __ym, last_spec) noexcept + { return {__ym.year(), chrono::month_day_last{__ym.month()}}; } + + friend constexpr year_month_day_last + operator/(const chrono::year& __y, + const chrono::month_day_last& __mdl) noexcept + { return {__y, __mdl}; } + + friend constexpr year_month_day_last + operator/(int __y, const chrono::month_day_last& __mdl) noexcept + { return chrono::year(__y) / __mdl; } + + friend constexpr year_month_day_last + operator/(const chrono::month_day_last& __mdl, + const chrono::year& __y) noexcept + { return __y / __mdl; } + + friend constexpr year_month_day_last + operator/(const chrono::month_day_last& __mdl, int __y) noexcept + { return chrono::year(__y) / __mdl; } + + // TODO: Implement operator<<. + }; + + // year_month_day ctor from year_month_day_last + constexpr + year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept + : _M_y{__ymdl.year()}, _M_m{__ymdl.month()}, _M_d{__ymdl.day()} + { } + + constexpr bool + year_month_day::ok() const noexcept + { + if (!_M_y.ok() || !_M_m.ok()) + return false; + return chrono::day{1} <= _M_d && _M_d <= (_M_y / _M_m / last).day(); + } + + // YEAR_MONTH_WEEKDAY + + class year_month_weekday + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::weekday_indexed _M_wdi; + + static constexpr year_month_weekday + _S_from_sys_days(const sys_days& __dp) + { + year_month_day __ymd{__dp}; + chrono::weekday __wd{__dp}; + auto __index = __wd[(unsigned{__ymd.day()} - 1) / 7 + 1]; + return {__ymd.year(), __ymd.month(), __index}; + } + + public: + year_month_weekday() = default; + + constexpr + year_month_weekday(const chrono::year& __y, const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + : _M_y{__y}, _M_m{__m}, _M_wdi{__wdi} + { } + + constexpr + year_month_weekday(const sys_days& __dp) noexcept + : year_month_weekday{_S_from_sys_days(__dp)} + { } + + explicit constexpr + year_month_weekday(const local_days& __dp) noexcept + : year_month_weekday{sys_days{__dp.time_since_epoch()}} + { } + + template + constexpr year_month_weekday& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_weekday& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_weekday& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_weekday& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wdi.weekday(); } + + constexpr unsigned + index() const noexcept + { return _M_wdi.index(); } + + constexpr chrono::weekday_indexed + weekday_indexed() const noexcept + { return _M_wdi; } + + constexpr + operator sys_days() const noexcept + { + auto __d = sys_days{year() / month() / 1}; + return __d + (weekday() - chrono::weekday(__d) + + days{(static_cast(index())-1)*7}); + } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { + if (!_M_y.ok() || !_M_m.ok() || !_M_wdi.ok()) + return false; + if (_M_wdi.index() <= 4) + return true; + days __d = (_M_wdi.weekday() + - chrono::weekday{sys_days{_M_y / _M_m / 1}} + + days((_M_wdi.index()-1)*7 + 1)); + __glibcxx_assert(__d.count() >= 1); + return __d.count() <= unsigned{(_M_y / _M_m / last).day()}; + } + + friend constexpr bool + operator==(const year_month_weekday& __x, + const year_month_weekday& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.weekday_indexed() == __y.weekday_indexed(); + } + + template + friend constexpr year_month_weekday + operator+(const year_month_weekday& __ymwd, const months& __dm) noexcept + { + return ((__ymwd.year() / __ymwd.month() + __dm) + / __ymwd.weekday_indexed()); + } + + template + friend constexpr year_month_weekday + operator+(const months& __dm, const year_month_weekday& __ymwd) noexcept + { return __ymwd + __dm; } + + friend constexpr year_month_weekday + operator+(const year_month_weekday& __ymwd, const years& __dy) noexcept + { return {__ymwd.year() + __dy, __ymwd.month(), __ymwd.weekday_indexed()}; } + + friend constexpr year_month_weekday + operator+(const years& __dy, const year_month_weekday& __ymwd) noexcept + { return __ymwd + __dy; } + + template + friend constexpr year_month_weekday + operator-(const year_month_weekday& __ymwd, const months& __dm) noexcept + { return __ymwd + -__dm; } + + friend constexpr year_month_weekday + operator-(const year_month_weekday& __ymwd, const years& __dy) noexcept + { return __ymwd + -__dy; } + + friend constexpr year_month_weekday + operator/(const year_month& __ym, + const chrono::weekday_indexed& __wdi) noexcept + { return {__ym.year(), __ym.month(), __wdi}; } + + friend constexpr year_month_weekday + operator/(const chrono::year& __y, const month_weekday& __mwd) noexcept + { return {__y, __mwd.month(), __mwd.weekday_indexed()}; } + + friend constexpr year_month_weekday + operator/(int __y, const month_weekday& __mwd) noexcept + { return chrono::year(__y) / __mwd; } + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, const chrono::year& __y) noexcept + { return __y / __mwd; } + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, int __y) noexcept + { return chrono::year(__y) / __mwd; } + + // TODO: Implement operator<<. + }; + + // YEAR_MONTH_WEEKDAY_LAST + + class year_month_weekday_last + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::weekday_last _M_wdl; + + public: + constexpr + year_month_weekday_last(const chrono::year& __y, const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + : _M_y{__y}, _M_m{__m}, _M_wdl{__wdl} + { } + + template + constexpr year_month_weekday_last& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_weekday_last& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_weekday_last& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_weekday_last& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wdl.weekday(); } + + constexpr chrono::weekday_last + weekday_last() const noexcept + { return _M_wdl; } + + constexpr + operator sys_days() const noexcept + { + const auto __d = sys_days{_M_y / _M_m / last}; + return sys_days{(__d - (chrono::weekday{__d} + - _M_wdl.weekday())).time_since_epoch()}; + } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_m.ok() && _M_wdl.ok(); } + + friend constexpr bool + operator==(const year_month_weekday_last& __x, + const year_month_weekday_last& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.weekday_last() == __y.weekday_last(); + } + + template + friend constexpr year_month_weekday_last + operator+(const year_month_weekday_last& __ymwdl, + const months& __dm) noexcept + { + return ((__ymwdl.year() / __ymwdl.month() + __dm) + / __ymwdl.weekday_last()); + } + + template + friend constexpr year_month_weekday_last + operator+(const months& __dm, + const year_month_weekday_last& __ymwdl) noexcept + { return __ymwdl + __dm; } + + friend constexpr year_month_weekday_last + operator+(const year_month_weekday_last& __ymwdl, + const years& __dy) noexcept + { return {__ymwdl.year() + __dy, __ymwdl.month(), __ymwdl.weekday_last()}; } + + friend constexpr year_month_weekday_last + operator+(const years& __dy, + const year_month_weekday_last& __ymwdl) noexcept + { return __ymwdl + __dy; } + + template + friend constexpr year_month_weekday_last + operator-(const year_month_weekday_last& __ymwdl, + const months& __dm) noexcept + { return __ymwdl + -__dm; } + + friend constexpr year_month_weekday_last + operator-(const year_month_weekday_last& __ymwdl, + const years& __dy) noexcept + { return __ymwdl + -__dy; } + + friend constexpr year_month_weekday_last + operator/(const year_month& __ym, + const chrono::weekday_last& __wdl) noexcept + { return {__ym.year(), __ym.month(), __wdl}; } + + friend constexpr year_month_weekday_last + operator/(const chrono::year& __y, + const chrono::month_weekday_last& __mwdl) noexcept + { return {__y, __mwdl.month(), __mwdl.weekday_last()}; } + + friend constexpr year_month_weekday_last + operator/(int __y, const chrono::month_weekday_last& __mwdl) noexcept + { return chrono::year(__y) / __mwdl; } + + friend constexpr year_month_weekday_last + operator/(const chrono::month_weekday_last& __mwdl, + const chrono::year& __y) noexcept + { return __y / __mwdl; } + + friend constexpr year_month_weekday_last + operator/(const chrono::month_weekday_last& __mwdl, int __y) noexcept + { return chrono::year(__y) / __mwdl; } + + // TODO: Implement operator<<. + }; + + // HH_MM_SS + + namespace __detail + { + consteval long long + __pow10(unsigned __n) + { + long long __r = 1; + while (__n-- > 0) + __r *= 10; + return __r; + } + } + + template + class hh_mm_ss + { + private: + static constexpr int + _S_fractional_width() + { + int __multiplicity_2 = 0; + int __multiplicity_5 = 0; + auto __den = _Duration::period::den; + while ((__den % 2) == 0) + { + ++__multiplicity_2; + __den /= 2; + } + while ((__den % 5) == 0) + { + ++__multiplicity_5; + __den /= 5; + } + if (__den != 1) + return 6; + + int __width = (__multiplicity_2 > __multiplicity_5 + ? __multiplicity_2 : __multiplicity_5); + if (__width > 18) + __width = 18; + return __width; + } + + public: + static constexpr unsigned fractional_width = {_S_fractional_width()}; + + using precision + = duration, + ratio<1, __detail::__pow10(fractional_width)>>; + + constexpr + hh_mm_ss() noexcept + : hh_mm_ss{_Duration::zero()} + { } + + constexpr explicit + hh_mm_ss(_Duration __d) noexcept + : _M_is_neg (__d < _Duration::zero()), + _M_h (duration_cast(abs(__d))), + _M_m (duration_cast(abs(__d) - hours())), + _M_s (duration_cast(abs(__d) - hours() - minutes())) + { + if constexpr (treat_as_floating_point_v) + _M_ss = abs(__d) - hours() - minutes() - seconds(); + else + _M_ss = duration_cast(abs(__d) - hours() + - minutes() - seconds()); + } + + constexpr bool + is_negative() const noexcept + { return _M_is_neg; } + + constexpr chrono::hours + hours() const noexcept + { return _M_h; } + + constexpr chrono::minutes + minutes() const noexcept + { return _M_m; } + + constexpr chrono::seconds + seconds() const noexcept + { return _M_s; } + + constexpr precision + subseconds() const noexcept + { return _M_ss; } + + constexpr explicit + operator precision() const noexcept + { return to_duration(); } + + constexpr precision + to_duration() const noexcept + { + if (_M_is_neg) + return -(_M_h + _M_m + _M_s + _M_ss); + else + return _M_h + _M_m + _M_s + _M_ss; + } + + // TODO: Implement operator<<. + + private: + bool _M_is_neg; + chrono::hours _M_h; + chrono::minutes _M_m; + chrono::seconds _M_s; + precision _M_ss; + }; + + // 12/24 HOURS FUNCTIONS + + constexpr bool + is_am(const hours& __h) noexcept + { return 0h <= __h && __h <= 11h; } + + constexpr bool + is_pm(const hours& __h) noexcept + { return 12h <= __h && __h <= 23h; } + + constexpr hours + make12(const hours& __h) noexcept + { + if (__h == 0h) + return 12h; + else if (__h > 12h) + return __h - 12h; + return __h; + } + + constexpr hours + make24(const hours& __h, bool __is_pm) noexcept + { + if (!__is_pm) + { + if (__h == 12h) + return 0h; + else + return __h; + } + else + { + if (__h == 12h) + return __h; + else + return __h + 12h; + } + } + /// @} group chrono +#endif // C++20 + } // namespace chrono + +#if __cplusplus >= 202002L + inline namespace literals + { + inline namespace chrono_literals + { + /// @addtogroup chrono + /// @{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + /// Literal suffix for creating chrono::day objects. + /// @since C++20 + constexpr chrono::day + operator""d(unsigned long long __d) noexcept + { return chrono::day{static_cast(__d)}; } + + /// Literal suffix for creating chrono::year objects. + /// @since C++20 + constexpr chrono::year + operator""y(unsigned long long __y) noexcept + { return chrono::year{static_cast(__y)}; } +#pragma GCC diagnostic pop + /// @} + } // inline namespace chrono_literals + } // inline namespace literals + + namespace chrono + { + /// @addtogroup chrono + /// @{ + + /// @cond undocumented + namespace __detail + { + template + const char* + __units_suffix_misc(char* __buf, size_t __n) noexcept + { + namespace __tc = std::__detail; + char* __p = __buf; + __p[0] = '['; + unsigned __nlen = __tc::__to_chars_len((uintmax_t)_Period::num); + __tc::__to_chars_10_impl(__p + 1, __nlen, (uintmax_t)_Period::num); + __p += 1 + __nlen; + if constexpr (_Period::den != 1) + { + __p[0] = '/'; + unsigned __dlen = __tc::__to_chars_len((uintmax_t)_Period::den); + __tc::__to_chars_10_impl(__p + 1, __dlen, (uintmax_t)_Period::den); + __p += 1 + __dlen; + } + __p[0] = ']'; + __p[1] = 's'; + __p[2] = '\0'; + return __buf; + } + + template + auto + __units_suffix(char* __buf, size_t __n) noexcept + { +#define _GLIBCXX_UNITS_SUFFIX(period, suffix) \ + if constexpr (is_same_v<_Period, period>) \ + { \ + if constexpr (is_same_v<_CharT, wchar_t>) \ + return L##suffix; \ + else \ + return suffix; \ + } \ + else + + _GLIBCXX_UNITS_SUFFIX(atto, "as") + _GLIBCXX_UNITS_SUFFIX(femto, "fs") + _GLIBCXX_UNITS_SUFFIX(pico, "ps") + _GLIBCXX_UNITS_SUFFIX(nano, "ns") + _GLIBCXX_UNITS_SUFFIX(micro, "\u00b5s") + _GLIBCXX_UNITS_SUFFIX(milli, "ms") + _GLIBCXX_UNITS_SUFFIX(centi, "cs") + _GLIBCXX_UNITS_SUFFIX(deci, "ds") + _GLIBCXX_UNITS_SUFFIX(ratio<1>, "s") + _GLIBCXX_UNITS_SUFFIX(deca, "das") + _GLIBCXX_UNITS_SUFFIX(hecto, "hs") + _GLIBCXX_UNITS_SUFFIX(kilo, "ks") + _GLIBCXX_UNITS_SUFFIX(mega, "Ms") + _GLIBCXX_UNITS_SUFFIX(giga, "Gs") + _GLIBCXX_UNITS_SUFFIX(tera, "Ts") + _GLIBCXX_UNITS_SUFFIX(tera, "Ts") + _GLIBCXX_UNITS_SUFFIX(peta, "Ps") + _GLIBCXX_UNITS_SUFFIX(exa, "Es") + _GLIBCXX_UNITS_SUFFIX(ratio<60>, "min") + _GLIBCXX_UNITS_SUFFIX(ratio<3600>, "h") + _GLIBCXX_UNITS_SUFFIX(ratio<86400>, "d") +#undef _GLIBCXX_UNITS_SUFFIX + return __detail::__units_suffix_misc<_Period>(__buf, __n); + } + } // namespace __detail + /// @endcond + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const duration<_Rep, _Period>& __d) + { + using period = typename _Period::type; + char __buf[sizeof("[/]s") + 2 * numeric_limits::digits10]; + std::basic_ostringstream<_CharT, _Traits> __s; + __s.flags(__os.flags()); + __s.imbue(__os.getloc()); + __s.precision(__os.precision()); + __s << __d.count(); + __s << __detail::__units_suffix(__buf, sizeof(__buf)); + __os << std::move(__s).str(); + return __os; + } + + // TODO: from_stream for duration + + /// @} group chrono + } // namespace chrono +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif //_GLIBCXX_CHRONO diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono.blob new file mode 100644 index 0000000000000000000000000000000000000000..39b3fa59a6ddf431fe80c92a695f49ad62ea69e4 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@chrono.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes new file mode 100644 index 0000000000000000000000000000000000000000..01c64e50f340e962d2b95e71b97774ab24397fb2 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes @@ -0,0 +1,81 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cinttypes + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CINTTYPES +#define _GLIBCXX_CINTTYPES 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +// For 27.9.2/3 (see C99, Note 184) +#if _GLIBCXX_HAVE_INTTYPES_H +# ifndef __STDC_FORMAT_MACROS +# define _UNDEF__STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +# endif +# include +# ifdef _UNDEF__STDC_FORMAT_MACROS +# undef __STDC_FORMAT_MACROS +# undef _UNDEF__STDC_FORMAT_MACROS +# endif +#endif + +#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1 + +namespace std +{ + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + using ::imaxdiv; + + // GCC does not support extended integer types + // intmax_t abs(intmax_t) + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + using ::wcstoimax; + using ::wcstoumax; +#endif +} // namespace std + +#endif // _GLIBCXX_USE_C99_INTTYPES_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_CINTTYPES diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes.blob new file mode 100644 index 0000000000000000000000000000000000000000..51749a612d1c0ccd580e7ea2cad26f5fe8c8194c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cinttypes.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646 b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646 new file mode 100644 index 0000000000000000000000000000000000000000..04db985efc78010c71e6a97e396aee664e978ed7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646 @@ -0,0 +1,38 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ciso646 + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c iso646.h, + * which is empty in C++. + */ +#ifndef _GLIBCXX_CISO646 +#define _GLIBCXX_CISO646 + +#pragma GCC system_header + +#include +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646.blob new file mode 100644 index 0000000000000000000000000000000000000000..f159351c90bfc13e16e048a1edfb870579fc3a51 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ciso646.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits new file mode 100644 index 0000000000000000000000000000000000000000..53452a10f5b15b73176bd52a05fa5711b2b6bba1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits @@ -0,0 +1,59 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/climits + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c limits.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CLIMITS +#define _GLIBCXX_CLIMITS 1 + +#ifndef LLONG_MIN +#define LLONG_MIN (-__LONG_LONG_MAX__ - 1) +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX __LONG_LONG_MAX__ +#endif + +#ifndef ULLONG_MAX +#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1) +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits.blob new file mode 100644 index 0000000000000000000000000000000000000000..5ac258df469a6984998ee836353b3852ff06edd5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@climits.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale new file mode 100644 index 0000000000000000000000000000000000000000..75fb0cf392c0c8eb3a6d2107e0b6d58439a73a09 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file clocale + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c locale.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CLOCALE +#define _GLIBCXX_CLOCALE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef setlocale +#undef localeconv + +namespace std +{ + using ::lconv; + using ::setlocale; + using ::localeconv; +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale.blob new file mode 100644 index 0000000000000000000000000000000000000000..80e9b8dc84cf7576f6707a9c772011c7228347b0 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@clocale.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath new file mode 100644 index 0000000000000000000000000000000000000000..1b993f30330450add628905b243361d782156bf4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath @@ -0,0 +1,1940 @@ +// -*- C++ -*- C forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cmath + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c math.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 26.5 C library +// + +#pragma GCC system_header + +#include +#include +#include +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include + +#ifndef _GLIBCXX_CMATH +#define _GLIBCXX_CMATH 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef div +#undef acos +#undef asin +#undef atan +#undef atan2 +#undef ceil +#undef cos +#undef cosh +#undef exp +#undef fabs +#undef floor +#undef fmod +#undef frexp +#undef ldexp +#undef log +#undef log10 +#undef modf +#undef pow +#undef sin +#undef sinh +#undef sqrt +#undef tan +#undef tanh + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::acos; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + acos(float __x) + { return __builtin_acosf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + acos(long double __x) + { return __builtin_acosl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + acos(_Tp __x) + { return __builtin_acos(__x); } + + using ::asin; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + asin(float __x) + { return __builtin_asinf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + asin(long double __x) + { return __builtin_asinl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + asin(_Tp __x) + { return __builtin_asin(__x); } + + using ::atan; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + atan(float __x) + { return __builtin_atanf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + atan(long double __x) + { return __builtin_atanl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + atan(_Tp __x) + { return __builtin_atan(__x); } + + using ::atan2; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + atan2(float __y, float __x) + { return __builtin_atan2f(__y, __x); } + + inline _GLIBCXX_CONSTEXPR long double + atan2(long double __y, long double __x) + { return __builtin_atan2l(__y, __x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + atan2(_Tp __y, _Up __x) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return atan2(__type(__y), __type(__x)); + } + + using ::ceil; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + ceil(float __x) + { return __builtin_ceilf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + ceil(long double __x) + { return __builtin_ceill(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + ceil(_Tp __x) + { return __builtin_ceil(__x); } + + using ::cos; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + cos(float __x) + { return __builtin_cosf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + cos(long double __x) + { return __builtin_cosl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cos(_Tp __x) + { return __builtin_cos(__x); } + + using ::cosh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + cosh(float __x) + { return __builtin_coshf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + cosh(long double __x) + { return __builtin_coshl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cosh(_Tp __x) + { return __builtin_cosh(__x); } + + using ::exp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + exp(float __x) + { return __builtin_expf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + exp(long double __x) + { return __builtin_expl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + exp(_Tp __x) + { return __builtin_exp(__x); } + + using ::fabs; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + fabs(float __x) + { return __builtin_fabsf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + fabs(long double __x) + { return __builtin_fabsl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + fabs(_Tp __x) + { return __builtin_fabs(__x); } + + using ::floor; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + floor(float __x) + { return __builtin_floorf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + floor(long double __x) + { return __builtin_floorl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + floor(_Tp __x) + { return __builtin_floor(__x); } + + using ::fmod; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + fmod(float __x, float __y) + { return __builtin_fmodf(__x, __y); } + + inline _GLIBCXX_CONSTEXPR long double + fmod(long double __x, long double __y) + { return __builtin_fmodl(__x, __y); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmod(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmod(__type(__x), __type(__y)); + } + + using ::frexp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline float + frexp(float __x, int* __exp) + { return __builtin_frexpf(__x, __exp); } + + inline long double + frexp(long double __x, int* __exp) + { return __builtin_frexpl(__x, __exp); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + frexp(_Tp __x, int* __exp) + { return __builtin_frexp(__x, __exp); } + + using ::ldexp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + ldexp(float __x, int __exp) + { return __builtin_ldexpf(__x, __exp); } + + inline _GLIBCXX_CONSTEXPR long double + ldexp(long double __x, int __exp) + { return __builtin_ldexpl(__x, __exp); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + ldexp(_Tp __x, int __exp) + { return __builtin_ldexp(__x, __exp); } + + using ::log; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + log(float __x) + { return __builtin_logf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + log(long double __x) + { return __builtin_logl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log(_Tp __x) + { return __builtin_log(__x); } + + using ::log10; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + log10(float __x) + { return __builtin_log10f(__x); } + + inline _GLIBCXX_CONSTEXPR long double + log10(long double __x) + { return __builtin_log10l(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log10(_Tp __x) + { return __builtin_log10(__x); } + + using ::modf; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline float + modf(float __x, float* __iptr) + { return __builtin_modff(__x, __iptr); } + + inline long double + modf(long double __x, long double* __iptr) + { return __builtin_modfl(__x, __iptr); } +#endif + + using ::pow; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + pow(float __x, float __y) + { return __builtin_powf(__x, __y); } + + inline _GLIBCXX_CONSTEXPR long double + pow(long double __x, long double __y) + { return __builtin_powl(__x, __y); } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 550. What should the return type of pow(float,int) be? + inline double + pow(double __x, int __i) + { return __builtin_powi(__x, __i); } + + inline float + pow(float __x, int __n) + { return __builtin_powif(__x, __n); } + + inline long double + pow(long double __x, int __n) + { return __builtin_powil(__x, __n); } +#endif +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + pow(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return pow(__type(__x), __type(__y)); + } + + using ::sin; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sin(float __x) + { return __builtin_sinf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sin(long double __x) + { return __builtin_sinl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sin(_Tp __x) + { return __builtin_sin(__x); } + + using ::sinh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sinh(float __x) + { return __builtin_sinhf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sinh(long double __x) + { return __builtin_sinhl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sinh(_Tp __x) + { return __builtin_sinh(__x); } + + using ::sqrt; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sqrt(float __x) + { return __builtin_sqrtf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sqrt(long double __x) + { return __builtin_sqrtl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sqrt(_Tp __x) + { return __builtin_sqrt(__x); } + + using ::tan; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + tan(float __x) + { return __builtin_tanf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + tan(long double __x) + { return __builtin_tanl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tan(_Tp __x) + { return __builtin_tan(__x); } + + using ::tanh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + tanh(float __x) + { return __builtin_tanhf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + tanh(long double __x) + { return __builtin_tanhl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tanh(_Tp __x) + { return __builtin_tanh(__x); } + +#if _GLIBCXX_USE_C99_MATH +#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + +// These are possible macros imported from C99-land. +#undef fpclassify +#undef isfinite +#undef isinf +#undef isnan +#undef isnormal +#undef signbit +#undef isgreater +#undef isgreaterequal +#undef isless +#undef islessequal +#undef islessgreater +#undef isunordered + +#if __cplusplus >= 201103L + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr int + fpclassify(float __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr int + fpclassify(double __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr int + fpclassify(long double __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type + fpclassify(_Tp __x) + { return __x != 0 ? FP_NORMAL : FP_ZERO; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isfinite(float __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isfinite(double __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isfinite(long double __x) + { return __builtin_isfinite(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isfinite(_Tp __x) + { return true; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isinf(float __x) + { return __builtin_isinf(__x); } + +#if _GLIBCXX_HAVE_OBSOLETE_ISINF \ + && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC + using ::isinf; +#else + constexpr bool + isinf(double __x) + { return __builtin_isinf(__x); } +#endif + + constexpr bool + isinf(long double __x) + { return __builtin_isinf(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isinf(_Tp __x) + { return false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isnan(float __x) + { return __builtin_isnan(__x); } + +#if _GLIBCXX_HAVE_OBSOLETE_ISNAN \ + && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC + using ::isnan; +#else + constexpr bool + isnan(double __x) + { return __builtin_isnan(__x); } +#endif + + constexpr bool + isnan(long double __x) + { return __builtin_isnan(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isnan(_Tp __x) + { return false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isnormal(float __x) + { return __builtin_isnormal(__x); } + + constexpr bool + isnormal(double __x) + { return __builtin_isnormal(__x); } + + constexpr bool + isnormal(long double __x) + { return __builtin_isnormal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isnormal(_Tp __x) + { return __x != 0 ? true : false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. + constexpr bool + signbit(float __x) + { return __builtin_signbit(__x); } + + constexpr bool + signbit(double __x) + { return __builtin_signbit(__x); } + + constexpr bool + signbit(long double __x) + { return __builtin_signbit(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + signbit(_Tp __x) + { return __x < 0 ? true : false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isgreater(float __x, float __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreater(double __x, double __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreater(long double __x, long double __y) + { return __builtin_isgreater(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isgreater(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isgreater(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isgreaterequal(float __x, float __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isgreaterequal(double __x, double __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isgreaterequal(long double __x, long double __y) + { return __builtin_isgreaterequal(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isgreaterequal(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isgreaterequal(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isless(float __x, float __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + isless(double __x, double __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + isless(long double __x, long double __y) + { return __builtin_isless(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isless(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isless(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + islessequal(float __x, float __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessequal(double __x, double __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessequal(long double __x, long double __y) + { return __builtin_islessequal(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + islessequal(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_islessequal(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + islessgreater(float __x, float __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + islessgreater(double __x, double __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + islessgreater(long double __x, long double __y) + { return __builtin_islessgreater(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + islessgreater(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_islessgreater(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isunordered(float __x, float __y) + { return __builtin_isunordered(__x, __y); } + + constexpr bool + isunordered(double __x, double __y) + { return __builtin_isunordered(__x, __y); } + + constexpr bool + isunordered(long double __x, long double __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isunordered(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isunordered(__type(__x), __type(__y)); + } +#endif + +#else + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + fpclassify(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isfinite(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isfinite(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isinf(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isinf(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnan(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnan(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnormal(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnormal(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + signbit(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_signbit(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreater(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreaterequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreaterequal(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isless(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isless(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessequal(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessgreater(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isunordered(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isunordered(__type(__f1), __type(__f2)); + } + +#endif // C++11 +#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ +#endif /* _GLIBCXX_USE_C99_MATH */ + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +#undef acosh +#undef acoshf +#undef acoshl +#undef asinh +#undef asinhf +#undef asinhl +#undef atanh +#undef atanhf +#undef atanhl +#undef cbrt +#undef cbrtf +#undef cbrtl +#undef copysign +#undef copysignf +#undef copysignl +#undef erf +#undef erff +#undef erfl +#undef erfc +#undef erfcf +#undef erfcl +#undef exp2 +#undef exp2f +#undef exp2l +#undef expm1 +#undef expm1f +#undef expm1l +#undef fdim +#undef fdimf +#undef fdiml +#undef fma +#undef fmaf +#undef fmal +#undef fmax +#undef fmaxf +#undef fmaxl +#undef fmin +#undef fminf +#undef fminl +#undef hypot +#undef hypotf +#undef hypotl +#undef ilogb +#undef ilogbf +#undef ilogbl +#undef lgamma +#undef lgammaf +#undef lgammal +#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS +#undef llrint +#undef llrintf +#undef llrintl +#undef llround +#undef llroundf +#undef llroundl +#endif +#undef log1p +#undef log1pf +#undef log1pl +#undef log2 +#undef log2f +#undef log2l +#undef logb +#undef logbf +#undef logbl +#undef lrint +#undef lrintf +#undef lrintl +#undef lround +#undef lroundf +#undef lroundl +#undef nan +#undef nanf +#undef nanl +#undef nearbyint +#undef nearbyintf +#undef nearbyintl +#undef nextafter +#undef nextafterf +#undef nextafterl +#undef nexttoward +#undef nexttowardf +#undef nexttowardl +#undef remainder +#undef remainderf +#undef remainderl +#undef remquo +#undef remquof +#undef remquol +#undef rint +#undef rintf +#undef rintl +#undef round +#undef roundf +#undef roundl +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef scalbn +#undef scalbnf +#undef scalbnl +#undef tgamma +#undef tgammaf +#undef tgammal +#undef trunc +#undef truncf +#undef truncl + + // types + using ::double_t; + using ::float_t; + + // functions + using ::acosh; + using ::acoshf; + using ::acoshl; + + using ::asinh; + using ::asinhf; + using ::asinhl; + + using ::atanh; + using ::atanhf; + using ::atanhl; + + using ::cbrt; + using ::cbrtf; + using ::cbrtl; + + using ::copysign; + using ::copysignf; + using ::copysignl; + + using ::erf; + using ::erff; + using ::erfl; + + using ::erfc; + using ::erfcf; + using ::erfcl; + + using ::exp2; + using ::exp2f; + using ::exp2l; + + using ::expm1; + using ::expm1f; + using ::expm1l; + + using ::fdim; + using ::fdimf; + using ::fdiml; + + using ::fma; + using ::fmaf; + using ::fmal; + + using ::fmax; + using ::fmaxf; + using ::fmaxl; + + using ::fmin; + using ::fminf; + using ::fminl; + + using ::hypot; + using ::hypotf; + using ::hypotl; + + using ::ilogb; + using ::ilogbf; + using ::ilogbl; + + using ::lgamma; + using ::lgammaf; + using ::lgammal; + +#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS + using ::llrint; + using ::llrintf; + using ::llrintl; + + using ::llround; + using ::llroundf; + using ::llroundl; +#endif + + using ::log1p; + using ::log1pf; + using ::log1pl; + + using ::log2; + using ::log2f; + using ::log2l; + + using ::logb; + using ::logbf; + using ::logbl; + + using ::lrint; + using ::lrintf; + using ::lrintl; + + using ::lround; + using ::lroundf; + using ::lroundl; + + using ::nan; + using ::nanf; + using ::nanl; + + using ::nearbyint; + using ::nearbyintf; + using ::nearbyintl; + + using ::nextafter; + using ::nextafterf; + using ::nextafterl; + + using ::nexttoward; + using ::nexttowardf; + using ::nexttowardl; + + using ::remainder; + using ::remainderf; + using ::remainderl; + + using ::remquo; + using ::remquof; + using ::remquol; + + using ::rint; + using ::rintf; + using ::rintl; + + using ::round; + using ::roundf; + using ::roundl; + + using ::scalbln; + using ::scalblnf; + using ::scalblnl; + + using ::scalbn; + using ::scalbnf; + using ::scalbnl; + + using ::tgamma; + using ::tgammaf; + using ::tgammal; + + using ::trunc; + using ::truncf; + using ::truncl; + + /// Additional overloads. +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + acosh(float __x) + { return __builtin_acoshf(__x); } + + constexpr long double + acosh(long double __x) + { return __builtin_acoshl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + acosh(_Tp __x) + { return __builtin_acosh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + asinh(float __x) + { return __builtin_asinhf(__x); } + + constexpr long double + asinh(long double __x) + { return __builtin_asinhl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + asinh(_Tp __x) + { return __builtin_asinh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + atanh(float __x) + { return __builtin_atanhf(__x); } + + constexpr long double + atanh(long double __x) + { return __builtin_atanhl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + atanh(_Tp __x) + { return __builtin_atanh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + cbrt(float __x) + { return __builtin_cbrtf(__x); } + + constexpr long double + cbrt(long double __x) + { return __builtin_cbrtl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cbrt(_Tp __x) + { return __builtin_cbrt(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + copysign(float __x, float __y) + { return __builtin_copysignf(__x, __y); } + + constexpr long double + copysign(long double __x, long double __y) + { return __builtin_copysignl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + copysign(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return copysign(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + erf(float __x) + { return __builtin_erff(__x); } + + constexpr long double + erf(long double __x) + { return __builtin_erfl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + erf(_Tp __x) + { return __builtin_erf(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + erfc(float __x) + { return __builtin_erfcf(__x); } + + constexpr long double + erfc(long double __x) + { return __builtin_erfcl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + erfc(_Tp __x) + { return __builtin_erfc(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + exp2(float __x) + { return __builtin_exp2f(__x); } + + constexpr long double + exp2(long double __x) + { return __builtin_exp2l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + exp2(_Tp __x) + { return __builtin_exp2(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + expm1(float __x) + { return __builtin_expm1f(__x); } + + constexpr long double + expm1(long double __x) + { return __builtin_expm1l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + expm1(_Tp __x) + { return __builtin_expm1(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fdim(float __x, float __y) + { return __builtin_fdimf(__x, __y); } + + constexpr long double + fdim(long double __x, long double __y) + { return __builtin_fdiml(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fdim(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fdim(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fma(float __x, float __y, float __z) + { return __builtin_fmaf(__x, __y, __z); } + + constexpr long double + fma(long double __x, long double __y, long double __z) + { return __builtin_fmal(__x, __y, __z); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + fma(_Tp __x, _Up __y, _Vp __z) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; + return fma(__type(__x), __type(__y), __type(__z)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fmax(float __x, float __y) + { return __builtin_fmaxf(__x, __y); } + + constexpr long double + fmax(long double __x, long double __y) + { return __builtin_fmaxl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmax(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmax(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fmin(float __x, float __y) + { return __builtin_fminf(__x, __y); } + + constexpr long double + fmin(long double __x, long double __y) + { return __builtin_fminl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmin(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmin(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + hypot(float __x, float __y) + { return __builtin_hypotf(__x, __y); } + + constexpr long double + hypot(long double __x, long double __y) + { return __builtin_hypotl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + hypot(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return hypot(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr int + ilogb(float __x) + { return __builtin_ilogbf(__x); } + + constexpr int + ilogb(long double __x) + { return __builtin_ilogbl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type + ilogb(_Tp __x) + { return __builtin_ilogb(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + lgamma(float __x) + { return __builtin_lgammaf(__x); } + + constexpr long double + lgamma(long double __x) + { return __builtin_lgammal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + lgamma(_Tp __x) + { return __builtin_lgamma(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long long + llrint(float __x) + { return __builtin_llrintf(__x); } + + constexpr long long + llrint(long double __x) + { return __builtin_llrintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type + llrint(_Tp __x) + { return __builtin_llrint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long long + llround(float __x) + { return __builtin_llroundf(__x); } + + constexpr long long + llround(long double __x) + { return __builtin_llroundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type + llround(_Tp __x) + { return __builtin_llround(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + log1p(float __x) + { return __builtin_log1pf(__x); } + + constexpr long double + log1p(long double __x) + { return __builtin_log1pl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log1p(_Tp __x) + { return __builtin_log1p(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + // DR 568. + constexpr float + log2(float __x) + { return __builtin_log2f(__x); } + + constexpr long double + log2(long double __x) + { return __builtin_log2l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log2(_Tp __x) + { return __builtin_log2(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + logb(float __x) + { return __builtin_logbf(__x); } + + constexpr long double + logb(long double __x) + { return __builtin_logbl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + logb(_Tp __x) + { return __builtin_logb(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long + lrint(float __x) + { return __builtin_lrintf(__x); } + + constexpr long + lrint(long double __x) + { return __builtin_lrintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type + lrint(_Tp __x) + { return __builtin_lrint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long + lround(float __x) + { return __builtin_lroundf(__x); } + + constexpr long + lround(long double __x) + { return __builtin_lroundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type + lround(_Tp __x) + { return __builtin_lround(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nearbyint(float __x) + { return __builtin_nearbyintf(__x); } + + constexpr long double + nearbyint(long double __x) + { return __builtin_nearbyintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + nearbyint(_Tp __x) + { return __builtin_nearbyint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nextafter(float __x, float __y) + { return __builtin_nextafterf(__x, __y); } + + constexpr long double + nextafter(long double __x, long double __y) + { return __builtin_nextafterl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + nextafter(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return nextafter(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nexttoward(float __x, long double __y) + { return __builtin_nexttowardf(__x, __y); } + + constexpr long double + nexttoward(long double __x, long double __y) + { return __builtin_nexttowardl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + nexttoward(_Tp __x, long double __y) + { return __builtin_nexttoward(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + remainder(float __x, float __y) + { return __builtin_remainderf(__x, __y); } + + constexpr long double + remainder(long double __x, long double __y) + { return __builtin_remainderl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remainder(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remainder(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + inline float + remquo(float __x, float __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + inline long double + remquo(long double __x, long double __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remquo(_Tp __x, _Up __y, int* __pquo) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remquo(__type(__x), __type(__y), __pquo); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + rint(float __x) + { return __builtin_rintf(__x); } + + constexpr long double + rint(long double __x) + { return __builtin_rintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + rint(_Tp __x) + { return __builtin_rint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + round(float __x) + { return __builtin_roundf(__x); } + + constexpr long double + round(long double __x) + { return __builtin_roundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + round(_Tp __x) + { return __builtin_round(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + scalbln(float __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + constexpr long double + scalbln(long double __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + scalbln(_Tp __x, long __ex) + { return __builtin_scalbln(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + scalbn(float __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + constexpr long double + scalbn(long double __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + scalbn(_Tp __x, int __ex) + { return __builtin_scalbn(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + tgamma(float __x) + { return __builtin_tgammaf(__x); } + + constexpr long double + tgamma(long double __x) + { return __builtin_tgammal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tgamma(_Tp __x) + { return __builtin_tgamma(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + trunc(float __x) + { return __builtin_truncf(__x); } + + constexpr long double + trunc(long double __x) + { return __builtin_truncl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + trunc(_Tp __x) + { return __builtin_trunc(__x); } +#endif + +#endif // _GLIBCXX_USE_C99_MATH_TR1 +#endif // C++11 + +#if __cplusplus >= 201703L + + // [c.math.hypot3], three-dimensional hypotenuse +#define __cpp_lib_hypot 201603L + + template + inline _Tp + __hypot3(_Tp __x, _Tp __y, _Tp __z) + { + __x = std::abs(__x); + __y = std::abs(__y); + __z = std::abs(__z); + if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) + return __a * std::sqrt((__x / __a) * (__x / __a) + + (__y / __a) * (__y / __a) + + (__z / __a) * (__z / __a)); + else + return {}; + } + + inline float + hypot(float __x, float __y, float __z) + { return std::__hypot3(__x, __y, __z); } + + inline double + hypot(double __x, double __y, double __z) + { return std::__hypot3(__x, __y, __z); } + + inline long double + hypot(long double __x, long double __y, long double __z) + { return std::__hypot3(__x, __y, __z); } + + template + __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> + hypot(_Tp __x, _Up __y, _Vp __z) + { + using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; + return std::__hypot3<__type>(__x, __y, __z); + } +#endif // C++17 + +#if __cplusplus >= 202002L + // linear interpolation +# define __cpp_lib_interpolate 201902L + + template + constexpr _Fp + __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept + { + if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) + return __t * __b + (1 - __t) * __a; + + if (__t == 1) + return __b; // exact + + // Exact at __t=0, monotonic except near __t=1, + // bounded, determinate, and consistent: + const _Fp __x = __a + __t * (__b - __a); + return (__t > 1) == (__b > __a) + ? (__b < __x ? __x : __b) + : (__b > __x ? __x : __b); // monotonic near __t=1 + } + + constexpr float + lerp(float __a, float __b, float __t) noexcept + { return std::__lerp(__a, __b, __t); } + + constexpr double + lerp(double __a, double __b, double __t) noexcept + { return std::__lerp(__a, __b, __t); } + + constexpr long double + lerp(long double __a, long double __b, long double __t) noexcept + { return std::__lerp(__a, __b, __t); } + + template + constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> + lerp(_Tp __x, _Up __y, _Vp __z) noexcept + { + using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; + return std::__lerp<__type>(__x, __y, __z); + } +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if _GLIBCXX_USE_STD_SPEC_FUNCS +# include +#endif + +} // extern "C++" + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath.blob new file mode 100644 index 0000000000000000000000000000000000000000..284abc6d13ff8127b0ae813d4f842d9ffb1c0199 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cmath.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt new file mode 100644 index 0000000000000000000000000000000000000000..e5b9207379f417d74e4f3fa2bc1f1b73f2317e10 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt @@ -0,0 +1,177 @@ +// -*- C++ -*- + +// Copyright (C) 2015-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C++ 14882: 22.5 Standard code conversion facets + +/** @file include/codecvt + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CODECVT +#define _GLIBCXX_CODECVT 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum codecvt_mode + { + consume_header = 4, + generate_header = 2, + little_endian = 1 + }; + + template + class codecvt_utf8 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf8(size_t __refs = 0); + + ~codecvt_utf8(); + }; + + template + class codecvt_utf16 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf16(size_t __refs = 0); + + ~codecvt_utf16(); + }; + + template + class codecvt_utf8_utf16 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf8_utf16(size_t __refs = 0); + + ~codecvt_utf8_utf16(); + }; + +#define _GLIBCXX_CODECVT_SPECIALIZATION2(_NAME, _ELEM) \ + template<> \ + class _NAME<_ELEM> \ + : public codecvt<_ELEM, char, mbstate_t> \ + { \ + public: \ + typedef _ELEM intern_type; \ + typedef char extern_type; \ + typedef mbstate_t state_type; \ + \ + protected: \ + _NAME(unsigned long __maxcode, codecvt_mode __mode, size_t __refs) \ + : codecvt(__refs), _M_maxcode(__maxcode), _M_mode(__mode) { } \ + \ + virtual \ + ~_NAME(); \ + \ + virtual result \ + do_out(state_type& __state, const intern_type* __from, \ + const intern_type* __from_end, const intern_type*& __from_next, \ + extern_type* __to, extern_type* __to_end, \ + extern_type*& __to_next) const; \ + \ + virtual result \ + do_unshift(state_type& __state, \ + extern_type* __to, extern_type* __to_end, \ + extern_type*& __to_next) const; \ + \ + virtual result \ + do_in(state_type& __state, \ + const extern_type* __from, const extern_type* __from_end, \ + const extern_type*& __from_next, \ + intern_type* __to, intern_type* __to_end, \ + intern_type*& __to_next) const; \ + \ + virtual \ + int do_encoding() const throw(); \ + \ + virtual \ + bool do_always_noconv() const throw(); \ + \ + virtual \ + int do_length(state_type&, const extern_type* __from, \ + const extern_type* __end, size_t __max) const; \ + \ + virtual int \ + do_max_length() const throw(); \ + \ + private: \ + unsigned long _M_maxcode; \ + codecvt_mode _M_mode; \ + } + +#define _GLIBCXX_CODECVT_SPECIALIZATION(_NAME, _ELEM) \ + _GLIBCXX_CODECVT_SPECIALIZATION2(__ ## _NAME ## _base, _ELEM); \ + template \ + class _NAME<_ELEM, _Maxcode, _Mode> \ + : public __ ## _NAME ## _base<_ELEM> \ + { \ + public: \ + explicit \ + _NAME(size_t __refs = 0) \ + : __ ## _NAME ## _base<_ELEM>(std::min(_Maxcode, 0x10fffful), \ + _Mode, __refs) \ + { } \ + } + + template class __codecvt_utf8_base; + template class __codecvt_utf16_base; + template class __codecvt_utf8_utf16_base; + + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char16_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char16_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char16_t); + + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char32_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char32_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char32_t); + +#ifdef _GLIBCXX_USE_WCHAR_T + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, wchar_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, wchar_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, wchar_t); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif /* _GLIBCXX_CODECVT */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt.blob new file mode 100644 index 0000000000000000000000000000000000000000..29354dec3d816b1ead2bf229989543f5e63f5648 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@codecvt.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare new file mode 100644 index 0000000000000000000000000000000000000000..e9cf9139deff6855e0b2c70e49f12b632855f27d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare @@ -0,0 +1,1246 @@ +// -*- C++ -*- operator<=> three-way comparison support. + +// Copyright (C) 2019-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file compare + * This is a Standard C++ Library header. + */ + +#ifndef _COMPARE +#define _COMPARE + +#pragma GCC system_header + +#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L + +#pragma GCC visibility push(default) + +#include + +#if __cpp_lib_concepts +# define __cpp_lib_three_way_comparison 201907L +#endif + +namespace std +{ + // [cmp.categories], comparison category types + + namespace __cmp_cat + { + using type = signed char; + + enum class _Ord : type { equivalent = 0, less = -1, greater = 1 }; + + enum class _Ncmp : type { _Unordered = 2 }; + + struct __unspec + { + constexpr __unspec(__unspec*) noexcept { } + }; + } + + class partial_ordering + { + // less=0xff, equiv=0x00, greater=0x01, unordered=0x02 + __cmp_cat::type _M_value; + + constexpr explicit + partial_ordering(__cmp_cat::_Ord __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + constexpr explicit + partial_ordering(__cmp_cat::_Ncmp __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + friend class weak_ordering; + friend class strong_ordering; + + public: + // valid values + static const partial_ordering less; + static const partial_ordering equivalent; + static const partial_ordering greater; + static const partial_ordering unordered; + + // comparisons + [[nodiscard]] + friend constexpr bool + operator==(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + [[nodiscard]] + friend constexpr bool + operator==(partial_ordering, partial_ordering) noexcept = default; + + [[nodiscard]] + friend constexpr bool + operator< (partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == -1; } + + [[nodiscard]] + friend constexpr bool + operator> (partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 1; } + + [[nodiscard]] + friend constexpr bool + operator<=(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + [[nodiscard]] + friend constexpr bool + operator>=(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator< (__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __v._M_value == 1; } + + [[nodiscard]] + friend constexpr bool + operator> (__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __v._M_value == -1; } + + [[nodiscard]] + friend constexpr bool + operator<=(__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator>=(__cmp_cat::__unspec, partial_ordering __v) noexcept + { return 0 >= __v._M_value; } + + [[nodiscard]] + friend constexpr partial_ordering + operator<=>(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + [[nodiscard]] + friend constexpr partial_ordering + operator<=>(__cmp_cat::__unspec, partial_ordering __v) noexcept + { + if (__v._M_value & 1) + return partial_ordering(__cmp_cat::_Ord(-__v._M_value)); + else + return __v; + } + }; + + // valid values' definitions + inline constexpr partial_ordering + partial_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr partial_ordering + partial_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr partial_ordering + partial_ordering::greater(__cmp_cat::_Ord::greater); + + inline constexpr partial_ordering + partial_ordering::unordered(__cmp_cat::_Ncmp::_Unordered); + + class weak_ordering + { + __cmp_cat::type _M_value; + + constexpr explicit + weak_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(__cmp_cat::type(__v)) + { } + + friend class strong_ordering; + + public: + // valid values + static const weak_ordering less; + static const weak_ordering equivalent; + static const weak_ordering greater; + + [[nodiscard]] + constexpr operator partial_ordering() const noexcept + { return partial_ordering(__cmp_cat::_Ord(_M_value)); } + + // comparisons + [[nodiscard]] + friend constexpr bool + operator==(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + [[nodiscard]] + friend constexpr bool + operator==(weak_ordering, weak_ordering) noexcept = default; + + [[nodiscard]] + friend constexpr bool + operator< (weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value < 0; } + + [[nodiscard]] + friend constexpr bool + operator> (weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value > 0; } + + [[nodiscard]] + friend constexpr bool + operator<=(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + [[nodiscard]] + friend constexpr bool + operator>=(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value >= 0; } + + [[nodiscard]] + friend constexpr bool + operator< (__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 < __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator> (__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 > __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator<=(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 <= __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator>=(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 >= __v._M_value; } + + [[nodiscard]] + friend constexpr weak_ordering + operator<=>(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + [[nodiscard]] + friend constexpr weak_ordering + operator<=>(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return weak_ordering(__cmp_cat::_Ord(-__v._M_value)); } + }; + + // valid values' definitions + inline constexpr weak_ordering + weak_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr weak_ordering + weak_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr weak_ordering + weak_ordering::greater(__cmp_cat::_Ord::greater); + + class strong_ordering + { + __cmp_cat::type _M_value; + + constexpr explicit + strong_ordering(__cmp_cat::_Ord __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + public: + // valid values + static const strong_ordering less; + static const strong_ordering equal; + static const strong_ordering equivalent; + static const strong_ordering greater; + + [[nodiscard]] + constexpr operator partial_ordering() const noexcept + { return partial_ordering(__cmp_cat::_Ord(_M_value)); } + + [[nodiscard]] + constexpr operator weak_ordering() const noexcept + { return weak_ordering(__cmp_cat::_Ord(_M_value)); } + + // comparisons + [[nodiscard]] + friend constexpr bool + operator==(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + [[nodiscard]] + friend constexpr bool + operator==(strong_ordering, strong_ordering) noexcept = default; + + [[nodiscard]] + friend constexpr bool + operator< (strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value < 0; } + + [[nodiscard]] + friend constexpr bool + operator> (strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value > 0; } + + [[nodiscard]] + friend constexpr bool + operator<=(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + [[nodiscard]] + friend constexpr bool + operator>=(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value >= 0; } + + [[nodiscard]] + friend constexpr bool + operator< (__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 < __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator> (__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 > __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator<=(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 <= __v._M_value; } + + [[nodiscard]] + friend constexpr bool + operator>=(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 >= __v._M_value; } + + [[nodiscard]] + friend constexpr strong_ordering + operator<=>(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + [[nodiscard]] + friend constexpr strong_ordering + operator<=>(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return strong_ordering(__cmp_cat::_Ord(-__v._M_value)); } + }; + + // valid values' definitions + inline constexpr strong_ordering + strong_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr strong_ordering + strong_ordering::equal(__cmp_cat::_Ord::equivalent); + + inline constexpr strong_ordering + strong_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr strong_ordering + strong_ordering::greater(__cmp_cat::_Ord::greater); + + + // named comparison functions + [[nodiscard]] + constexpr bool + is_eq(partial_ordering __cmp) noexcept + { return __cmp == 0; } + + [[nodiscard]] + constexpr bool + is_neq(partial_ordering __cmp) noexcept + { return __cmp != 0; } + + [[nodiscard]] + constexpr bool + is_lt (partial_ordering __cmp) noexcept + { return __cmp < 0; } + + [[nodiscard]] + constexpr bool + is_lteq(partial_ordering __cmp) noexcept + { return __cmp <= 0; } + + [[nodiscard]] + constexpr bool + is_gt (partial_ordering __cmp) noexcept + { return __cmp > 0; } + + [[nodiscard]] + constexpr bool + is_gteq(partial_ordering __cmp) noexcept + { return __cmp >= 0; } + + namespace __detail + { + template + inline constexpr unsigned __cmp_cat_id = 1; + template<> + inline constexpr unsigned __cmp_cat_id = 2; + template<> + inline constexpr unsigned __cmp_cat_id = 4; + template<> + inline constexpr unsigned __cmp_cat_id = 8; + + template + constexpr auto __common_cmp_cat() + { + constexpr unsigned __cats = (__cmp_cat_id<_Ts> | ...); + // If any Ti is not a comparison category type, U is void. + if constexpr (__cats & 1) + return; + // Otherwise, if at least one Ti is std::partial_ordering, + // U is std::partial_ordering. + else if constexpr (bool(__cats & __cmp_cat_id)) + return partial_ordering::equivalent; + // Otherwise, if at least one Ti is std::weak_ordering, + // U is std::weak_ordering. + else if constexpr (bool(__cats & __cmp_cat_id)) + return weak_ordering::equivalent; + // Otherwise, U is std::strong_ordering. + else + return strong_ordering::equivalent; + } + } // namespace __detail + + // [cmp.common], common comparison category type + template + struct common_comparison_category + { + using type = decltype(__detail::__common_cmp_cat<_Ts...>()); + }; + + // Partial specializations for one and zero argument cases. + + template + struct common_comparison_category<_Tp> + { using type = void; }; + + template<> + struct common_comparison_category + { using type = partial_ordering; }; + + template<> + struct common_comparison_category + { using type = weak_ordering; }; + + template<> + struct common_comparison_category + { using type = strong_ordering; }; + + template<> + struct common_comparison_category<> + { using type = strong_ordering; }; + + template + using common_comparison_category_t + = typename common_comparison_category<_Ts...>::type; + +#if __cpp_lib_concepts + namespace __detail + { + template + concept __compares_as + = same_as, _Cat>; + } // namespace __detail + + // [cmp.concept], concept three_way_comparable + template + concept three_way_comparable + = __detail::__weakly_eq_cmp_with<_Tp, _Tp> + && __detail::__partially_ordered_with<_Tp, _Tp> + && requires(const remove_reference_t<_Tp>& __a, + const remove_reference_t<_Tp>& __b) + { + { __a <=> __b } -> __detail::__compares_as<_Cat>; + }; + + template + concept three_way_comparable_with + = three_way_comparable<_Tp, _Cat> + && three_way_comparable<_Up, _Cat> + && common_reference_with&, + const remove_reference_t<_Up>&> + && three_way_comparable< + common_reference_t&, + const remove_reference_t<_Up>&>, _Cat> + && __detail::__weakly_eq_cmp_with<_Tp, _Up> + && __detail::__partially_ordered_with<_Tp, _Up> + && requires(const remove_reference_t<_Tp>& __t, + const remove_reference_t<_Up>& __u) + { + { __t <=> __u } -> __detail::__compares_as<_Cat>; + { __u <=> __t } -> __detail::__compares_as<_Cat>; + }; + + namespace __detail + { + template + using __cmp3way_res_t + = decltype(std::declval<_Tp>() <=> std::declval<_Up>()); + + // Implementation of std::compare_three_way_result. + // It is undefined for a program to add specializations of + // std::compare_three_way_result, so the std::compare_three_way_result_t + // alias ignores std::compare_three_way_result and uses + // __detail::__cmp3way_res_impl directly instead. + template + struct __cmp3way_res_impl + { }; + + template + requires requires { typename __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; } + struct __cmp3way_res_impl<_Tp, _Up> + { + using type = __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; + }; + } // namespace __detail + + /// [cmp.result], result of three-way comparison + template + struct compare_three_way_result + : __detail::__cmp3way_res_impl<_Tp, _Up> + { }; + + /// [cmp.result], result of three-way comparison + template + using compare_three_way_result_t + = typename __detail::__cmp3way_res_impl<_Tp, _Up>::type; + + namespace __detail + { + // BUILTIN-PTR-THREE-WAY(T, U) + // This determines whether t <=> u results in a call to a built-in + // operator<=> comparing pointers. It doesn't work for function pointers + // (PR 93628). + template + concept __3way_builtin_ptr_cmp + = requires(_Tp&& __t, _Up&& __u) + { static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u); } + && convertible_to<_Tp, const volatile void*> + && convertible_to<_Up, const volatile void*> + && ! requires(_Tp&& __t, _Up&& __u) + { operator<=>(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); } + && ! requires(_Tp&& __t, _Up&& __u) + { static_cast<_Tp&&>(__t).operator<=>(static_cast<_Up&&>(__u)); }; + } // namespace __detail + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3530 BUILTIN-PTR-MEOW should not opt the type out of syntactic checks + + // [cmp.object], typename compare_three_way + struct compare_three_way + { + template + requires three_way_comparable_with<_Tp, _Up> + constexpr auto + operator() [[nodiscard]] (_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() <=> std::declval<_Up>())) + { + if constexpr (__detail::__3way_builtin_ptr_cmp<_Tp, _Up>) + { + auto __pt = static_cast(__t); + auto __pu = static_cast(__u); + if (std::__is_constant_evaluated()) + return __pt <=> __pu; + auto __it = reinterpret_cast<__UINTPTR_TYPE__>(__pt); + auto __iu = reinterpret_cast<__UINTPTR_TYPE__>(__pu); + return __it <=> __iu; + } + else + return static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u); + } + + using is_transparent = void; + }; + + namespace __cmp_cust + { + template + constexpr weak_ordering + __fp_weak_ordering(_Tp __e, _Tp __f) + { + // Returns an integer with the same sign as the argument, and magnitude + // indicating the classification: zero=1 subnorm=2 norm=3 inf=4 nan=5 + auto __cat = [](_Tp __fp) -> int { + const int __sign = __builtin_signbit(__fp) ? -1 : 1; + if (__builtin_isnormal(__fp)) + return (__fp == 0 ? 1 : 3) * __sign; + if (__builtin_isnan(__fp)) + return 5 * __sign; + if (int __inf = __builtin_isinf_sign(__fp)) + return 4 * __inf; + return 2 * __sign; + }; + + auto __po = __e <=> __f; + if (is_lt(__po)) + return weak_ordering::less; + else if (is_gt(__po)) + return weak_ordering::greater; + else if (__po == partial_ordering::equivalent) + return weak_ordering::equivalent; + else // unordered, at least one argument is NaN + { + // return -1 for negative nan, +1 for positive nan, 0 otherwise. + auto __isnan_sign = [](_Tp __fp) -> int { + return __builtin_isnan(__fp) + ? __builtin_signbit(__fp) ? -1 : 1 + : 0; + }; + auto __ord = __isnan_sign(__e) <=> __isnan_sign(__f); + if (is_eq(__ord)) + return weak_ordering::equivalent; + else if (is_lt(__ord)) + return weak_ordering::less; + else + return weak_ordering::greater; + } + } + + template + concept __adl_strong = requires(_Tp&& __t, _Up&& __u) + { + strong_ordering(strong_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __adl_weak = requires(_Tp&& __t, _Up&& __u) + { + weak_ordering(weak_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __adl_partial = requires(_Tp&& __t, _Up&& __u) + { + partial_ordering(partial_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __cmp3way = requires(_Tp&& __t, _Up&& __u, compare_three_way __c) + { + _Ord(__c(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u))); + }; + + template + concept __strongly_ordered + = __adl_strong<_Tp, _Up> + || floating_point> + || __cmp3way; + + template + concept __decayed_same_as = same_as, decay_t<_Up>>; + + class _Strong_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (floating_point>) + return true; + else if constexpr (__adl_strong<_Tp, _Up>) + return noexcept(strong_ordering(strong_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + } + + friend class _Weak_order; + friend class _Strong_fallback; + + // Names for the supported floating-point representations. + enum class _Fp_fmt + { + _Binary16, _Binary32, _Binary64, _Binary128, // IEEE + _X86_80bit, // x86 80-bit extended precision + _M68k_80bit, // m68k 80-bit extended precision + _Dbldbl, // IBM 128-bit double-double + // TODO: _Bfloat16, + }; + +#ifndef __cpp_using_enum + // XXX Remove these once 'using enum' support is ubiquitous. + static constexpr _Fp_fmt _Binary16 = _Fp_fmt::_Binary16; + static constexpr _Fp_fmt _Binary32 = _Fp_fmt::_Binary32; + static constexpr _Fp_fmt _Binary64 = _Fp_fmt::_Binary64; + static constexpr _Fp_fmt _Binary128 = _Fp_fmt::_Binary128; + static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit; + static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit; + static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl; +#endif + + // Identify the format used by a floating-point type. + template + static consteval _Fp_fmt + _S_fp_fmt() noexcept + { +#ifdef __cpp_using_enum + using enum _Fp_fmt; +#endif + + // Identify these formats first, then assume anything else is IEEE. + // N.B. ARM __fp16 alternative format can be handled as binary16. + +#ifdef __LONG_DOUBLE_IBM128__ + if constexpr (__is_same(_Tp, long double)) + return _Dbldbl; +#elif defined __LONG_DOUBLE_IEEE128__ && defined __SIZEOF_IBM128__ + if constexpr (__is_same(_Tp, __ibm128)) + return _Dbldbl; +#endif + +#if __LDBL_MANT_DIG__ == 64 + if constexpr (__is_same(_Tp, long double)) + return __LDBL_MIN_EXP__ == -16381 ? _X86_80bit : _M68k_80bit; +#endif +#ifdef __SIZEOF_FLOAT80__ + if constexpr (__is_same(_Tp, __float80)) + return _X86_80bit; +#endif + + constexpr int __width = sizeof(_Tp) * __CHAR_BIT__; + + if constexpr (__width == 16) // IEEE binary16 (or ARM fp16). + return _Binary16; + else if constexpr (__width == 32) // IEEE binary32 + return _Binary32; + else if constexpr (__width == 64) // IEEE binary64 + return _Binary64; + else if constexpr (__width == 128) // IEEE binary128 + return _Binary128; + } + + // So we don't need to include and pollute the namespace. + using int64_t = __INT64_TYPE__; + using int32_t = __INT32_TYPE__; + using int16_t = __INT16_TYPE__; + using uint64_t = __UINT64_TYPE__; + using uint16_t = __UINT16_TYPE__; + + // Used to unpack floating-point types that do not fit into an integer. + template + struct _Int + { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + uint64_t _M_lo; + _Tp _M_hi; +#else + _Tp _M_hi; + uint64_t _M_lo; +#endif + + constexpr explicit + _Int(_Tp __hi, uint64_t __lo) noexcept : _M_hi(__hi) + { _M_lo = __lo; } + + constexpr explicit + _Int(uint64_t __lo) noexcept : _M_hi(0) + { _M_lo = __lo; } + + constexpr bool operator==(const _Int&) const = default; + +#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008) + consteval _Int + operator<<(int __n) const noexcept + { + // XXX this assumes n >= 64, which is true for the use below. + return _Int(static_cast<_Tp>(_M_lo << (__n - 64)), 0); + } +#endif + + constexpr _Int& + operator^=(const _Int& __rhs) noexcept + { + _M_hi ^= __rhs._M_hi; + _M_lo ^= __rhs._M_lo; + return *this; + } + + constexpr strong_ordering + operator<=>(const _Int& __rhs) const noexcept + { + strong_ordering __cmp = _M_hi <=> __rhs._M_hi; + if (__cmp != strong_ordering::equal) + return __cmp; + return _M_lo <=> __rhs._M_lo; + } + }; + + template + static constexpr _Tp + _S_compl(_Tp __t) noexcept + { + constexpr int __width = sizeof(_Tp) * __CHAR_BIT__; + // Sign extend to get all ones or all zeros. + make_unsigned_t<_Tp> __sign = __t >> (__width - 1); + // If the sign bit was set, this flips all bits below it. + // This converts ones' complement to two's complement. + return __t ^ (__sign >> 1); + } + + // As above but works on both parts of _Int. + template + static constexpr _Int<_Tp> + _S_compl(_Int<_Tp> __t) noexcept + { + constexpr int __width = sizeof(_Tp) * __CHAR_BIT__; + make_unsigned_t<_Tp> __sign = __t._M_hi >> (__width - 1); + __t._M_hi ^= (__sign >> 1 ); + uint64_t __sign64 = (_Tp)__sign; + __t._M_lo ^= __sign64; + return __t; + } + + // Bit-cast a floating-point value to an unsigned integer. + template + constexpr static auto + _S_fp_bits(_Tp __val) noexcept + { + if constexpr (sizeof(_Tp) == sizeof(int64_t)) + return __builtin_bit_cast(int64_t, __val); + else if constexpr (sizeof(_Tp) == sizeof(int32_t)) + return __builtin_bit_cast(int32_t, __val); + else if constexpr (sizeof(_Tp) == sizeof(int16_t)) + return __builtin_bit_cast(int16_t, __val); + else + { +#ifdef __cpp_using_enum + using enum _Fp_fmt; +#endif + constexpr auto __fmt = _S_fp_fmt<_Tp>(); + if constexpr (__fmt == _X86_80bit || __fmt == _M68k_80bit) + { + if constexpr (sizeof(_Tp) == 3 * sizeof(int32_t)) + { + auto __ival = __builtin_bit_cast(_Int, __val); + return _Int(__ival._M_hi, __ival._M_lo); + } + else + { + auto __ival = __builtin_bit_cast(_Int, __val); + return _Int(__ival._M_hi, __ival._M_lo); + } + } + else if constexpr (sizeof(_Tp) == 2 * sizeof(int64_t)) + { +#if __SIZEOF_INT128__ + return __builtin_bit_cast(__int128, __val); +#else + return __builtin_bit_cast(_Int, __val); +#endif + } + else + static_assert(sizeof(_Tp) == sizeof(int64_t), + "unsupported floating-point type"); + } + } + + template + static constexpr strong_ordering + _S_fp_cmp(_Tp __x, _Tp __y) noexcept + { +#ifdef __vax__ + if (__builtin_isnan(__x) || __builtin_isnan(__y)) + { + int __ix = (bool) __builtin_isnan(__x); + int __iy = (bool) __builtin_isnan(__y); + __ix *= __builtin_signbit(__x) ? -1 : 1; + __iy *= __builtin_signbit(__y) ? -1 : 1; + return __ix <=> __iy; + } + else + return __builtin_bit_cast(strong_ordering, __x <=> __y); +#endif + + auto __ix = _S_fp_bits(__x); + auto __iy = _S_fp_bits(__y); + + if (__ix == __iy) + return strong_ordering::equal; // All bits are equal, we're done. + +#ifdef __cpp_using_enum + using enum _Fp_fmt; +#endif + constexpr auto __fmt = _S_fp_fmt<_Tp>(); + + if constexpr (__fmt == _Dbldbl) // double-double + { + // Unpack the double-double into two parts. + // We never inspect the low double as a double, cast to integer. + struct _Unpacked { double _M_hi; int64_t _M_lo; }; + auto __x2 = __builtin_bit_cast(_Unpacked, __x); + auto __y2 = __builtin_bit_cast(_Unpacked, __y); + + // Compare the high doubles first and use result if unequal. + auto __cmp = _S_fp_cmp(__x2._M_hi, __y2._M_hi); + if (__cmp != strong_ordering::equal) + return __cmp; + + // For NaN the low double is unused, so if the high doubles + // are the same NaN, we don't need to compare the low doubles. + if (__builtin_isnan(__x2._M_hi)) + return strong_ordering::equal; + // Similarly, if the low doubles are +zero or -zero (which is + // true for all infinities and some other values), we're done. + if (((__x2._M_lo | __y2._M_lo) & 0x7fffffffffffffffULL) == 0) + return strong_ordering::equal; + + // Otherwise, compare the low parts. + return _S_compl(__x2._M_lo) <=> _S_compl(__y2._M_lo); + } + else + { + if constexpr (__fmt == _M68k_80bit) + { + // For m68k the MSB of the significand is ignored for the + // greatest exponent, so either 0 or 1 is valid there. + // Set it before comparing, so that we never have 0 there. + constexpr uint16_t __maxexp = 0x7fff; + if ((__ix._M_hi & __maxexp) == __maxexp) + __ix._M_lo |= 1ull << 63; + if ((__iy._M_hi & __maxexp) == __maxexp) + __iy._M_lo |= 1ull << 63; + } + else + { +#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008) + // IEEE 754-1985 allowed the meaning of the quiet/signaling + // bit to be reversed. Flip that to give desired ordering. + if (__builtin_isnan(__x) && __builtin_isnan(__y)) + { + using _Int = decltype(__ix); + + constexpr int __nantype = __fmt == _Binary32 ? 22 + : __fmt == _Binary64 ? 51 + : __fmt == _Binary128 ? 111 + : -1; + constexpr _Int __bit = _Int(1) << __nantype; + __ix ^= __bit; + __iy ^= __bit; + } +#endif + } + return _S_compl(__ix) <=> _S_compl(__iy); + } + } + + public: + template _Up> + requires __strongly_ordered<_Tp, _Up> + constexpr strong_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (floating_point>) + return _S_fp_cmp(__e, __f); + else if constexpr (__adl_strong<_Tp, _Up>) + return strong_ordering(strong_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __weakly_ordered + = floating_point> + || __adl_weak<_Tp, _Up> + || __cmp3way + || __strongly_ordered<_Tp, _Up>; + + class _Weak_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (floating_point>) + return true; + else if constexpr (__adl_weak<_Tp, _Up>) + return noexcept(weak_ordering(weak_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order::_S_noexcept<_Tp, _Up>(); + } + + friend class _Partial_order; + friend class _Weak_fallback; + + public: + template _Up> + requires __weakly_ordered<_Tp, _Up> + constexpr weak_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (floating_point>) + return __cmp_cust::__fp_weak_ordering(__e, __f); + else if constexpr (__adl_weak<_Tp, _Up>) + return weak_ordering(weak_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __partially_ordered + = __adl_partial<_Tp, _Up> + || __cmp3way + || __weakly_ordered<_Tp, _Up>; + + class _Partial_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_partial<_Tp, _Up>) + return noexcept(partial_ordering(partial_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order::_S_noexcept<_Tp, _Up>(); + } + + friend class _Partial_fallback; + + public: + template _Up> + requires __partially_ordered<_Tp, _Up> + constexpr partial_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_partial<_Tp, _Up>) + return partial_ordering(partial_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __op_eq_lt = requires(_Tp&& __t, _Up&& __u) + { + { static_cast<_Tp&&>(__t) == static_cast<_Up&&>(__u) } + -> convertible_to; + { static_cast<_Tp&&>(__t) < static_cast<_Up&&>(__u) } + -> convertible_to; + }; + + class _Strong_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __strongly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> + constexpr strong_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? strong_ordering::equal + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? strong_ordering::less + : strong_ordering::greater; + } + }; + + class _Weak_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __weakly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> + constexpr weak_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? weak_ordering::equivalent + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? weak_ordering::less + : weak_ordering::greater; + } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3465. compare_partial_order_fallback requires F < E + template + concept __op_eq_lt_lt = __op_eq_lt<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) + { + { static_cast<_Up&&>(__u) < static_cast<_Tp&&>(__t) } + -> convertible_to; + }; + + class _Partial_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__partially_ordered<_Tp, _Up>) + return _Partial_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up> + constexpr partial_ordering + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__partially_ordered<_Tp, _Up>) + return _Partial_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? partial_ordering::equivalent + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? partial_ordering::less + : static_cast<_Up&&>(__f) < static_cast<_Tp&&>(__e) + ? partial_ordering::greater + : partial_ordering::unordered; + } + }; + } // namespace __cmp_cust + + // [cmp.alg], comparison algorithms + inline namespace __cmp_alg + { + inline constexpr __cmp_cust::_Strong_order strong_order{}; + + inline constexpr __cmp_cust::_Weak_order weak_order{}; + + inline constexpr __cmp_cust::_Partial_order partial_order{}; + + inline constexpr __cmp_cust::_Strong_fallback + compare_strong_order_fallback{}; + + inline constexpr __cmp_cust::_Weak_fallback + compare_weak_order_fallback{}; + + inline constexpr __cmp_cust::_Partial_fallback + compare_partial_order_fallback{}; + } + + namespace __detail + { + // [expos.only.func] synth-three-way + inline constexpr struct _Synth3way + { + template + static constexpr bool + _S_noexcept(const _Tp* __t = nullptr, const _Up* __u = nullptr) + { + if constexpr (three_way_comparable_with<_Tp, _Up>) + return noexcept(*__t <=> *__u); + else + return noexcept(*__t < *__u) && noexcept(*__u < *__t); + } + + template + [[nodiscard]] + constexpr auto + operator()(const _Tp& __t, const _Up& __u) const + noexcept(_S_noexcept<_Tp, _Up>()) + requires requires + { + { __t < __u } -> __boolean_testable; + { __u < __t } -> __boolean_testable; + } + { + if constexpr (three_way_comparable_with<_Tp, _Up>) + return __t <=> __u; + else + { + if (__t < __u) + return weak_ordering::less; + else if (__u < __t) + return weak_ordering::greater; + else + return weak_ordering::equivalent; + } + } + } __synth3way = {}; + + // [expos.only.func] synth-three-way-result + template + using __synth3way_t + = decltype(__detail::__synth3way(std::declval<_Tp&>(), + std::declval<_Up&>())); + } // namespace __detail +#endif // concepts +} // namespace std + +#pragma GCC visibility pop + +#endif // C++20 + +#endif // _COMPARE diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare.blob new file mode 100644 index 0000000000000000000000000000000000000000..e71c3fcb321c3faefb9fdfccb00a33d545482d7b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@compare.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex new file mode 100644 index 0000000000000000000000000000000000000000..8f9368fd7d04f25d3313625de70c3fb8b95e63a3 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex @@ -0,0 +1,1995 @@ +// The template and inlines for the -*- C++ -*- complex number classes. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/complex + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 26.2 Complex Numbers +// Note: this is not a conforming implementation. +// Initially implemented by Ulrich Drepper +// Improved by Gabriel Dos Reis +// + +#ifndef _GLIBCXX_COMPLEX +#define _GLIBCXX_COMPLEX 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +// Get rid of a macro possibly defined in +#undef complex + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_complex 201711L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup complex_numbers Complex Numbers + * @ingroup numerics + * + * Classes and functions for complex numbers. + * @{ + */ + + // Forward declarations. + template class complex; + template<> class complex; + template<> class complex; + template<> class complex; + + /// Return magnitude of @a z. + template _Tp abs(const complex<_Tp>&); + /// Return phase angle of @a z. + template _Tp arg(const complex<_Tp>&); + /// Return @a z magnitude squared. + template _Tp _GLIBCXX20_CONSTEXPR norm(const complex<_Tp>&); + + /// Return complex conjugate of @a z. + template + _GLIBCXX20_CONSTEXPR complex<_Tp> conj(const complex<_Tp>&); + /// Return complex with magnitude @a rho and angle @a theta. + template complex<_Tp> polar(const _Tp&, const _Tp& = 0); + + // Transcendentals: + /// Return complex cosine of @a z. + template complex<_Tp> cos(const complex<_Tp>&); + /// Return complex hyperbolic cosine of @a z. + template complex<_Tp> cosh(const complex<_Tp>&); + /// Return complex base e exponential of @a z. + template complex<_Tp> exp(const complex<_Tp>&); + /// Return complex natural logarithm of @a z. + template complex<_Tp> log(const complex<_Tp>&); + /// Return complex base 10 logarithm of @a z. + template complex<_Tp> log10(const complex<_Tp>&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, int); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, const _Tp&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, + const complex<_Tp>&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const _Tp&, const complex<_Tp>&); + /// Return complex sine of @a z. + template complex<_Tp> sin(const complex<_Tp>&); + /// Return complex hyperbolic sine of @a z. + template complex<_Tp> sinh(const complex<_Tp>&); + /// Return complex square root of @a z. + template complex<_Tp> sqrt(const complex<_Tp>&); + /// Return complex tangent of @a z. + template complex<_Tp> tan(const complex<_Tp>&); + /// Return complex hyperbolic tangent of @a z. + template complex<_Tp> tanh(const complex<_Tp>&); + + + // 26.2.2 Primary template class complex + /** + * Template to represent complex numbers. + * + * Specializations for float, double, and long double are part of the + * library. Results with any other type are not guaranteed. + * + * @param Tp Type of real and imaginary values. + */ + template + class complex + { + public: + /// Value typedef. + typedef _Tp value_type; + + /// Default constructor. First parameter is x, second parameter is y. + /// Unspecified parameters default to 0. + _GLIBCXX_CONSTEXPR complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp()) + : _M_real(__r), _M_imag(__i) { } + + // Let the compiler synthesize the copy constructor +#if __cplusplus >= 201103L + constexpr complex(const complex&) = default; +#endif + + /// Converting constructor. + template + _GLIBCXX_CONSTEXPR complex(const complex<_Up>& __z) + : _M_real(__z.real()), _M_imag(__z.imag()) { } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX_ABI_TAG_CXX11 + constexpr _Tp + real() const { return _M_real; } + + _GLIBCXX_ABI_TAG_CXX11 + constexpr _Tp + imag() const { return _M_imag; } +#else + /// Return real part of complex number. + _Tp& + real() { return _M_real; } + + /// Return real part of complex number. + const _Tp& + real() const { return _M_real; } + + /// Return imaginary part of complex number. + _Tp& + imag() { return _M_imag; } + + /// Return imaginary part of complex number. + const _Tp& + imag() const { return _M_imag; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(_Tp __val) { _M_real = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(_Tp __val) { _M_imag = __val; } + + /// Assign a scalar to this complex number. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator=(const _Tp&); + + /// Add a scalar to this complex number. + // 26.2.5/1 + _GLIBCXX20_CONSTEXPR complex<_Tp>& + operator+=(const _Tp& __t) + { + _M_real += __t; + return *this; + } + + /// Subtract a scalar from this complex number. + // 26.2.5/3 + _GLIBCXX20_CONSTEXPR complex<_Tp>& + operator-=(const _Tp& __t) + { + _M_real -= __t; + return *this; + } + + /// Multiply this complex number by a scalar. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator*=(const _Tp&); + /// Divide this complex number by a scalar. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator/=(const _Tp&); + + // Let the compiler synthesize the copy assignment operator +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + /// Assign another complex number to this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator=(const complex<_Up>&); + /// Add another complex number to this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator+=(const complex<_Up>&); + /// Subtract another complex number from this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator-=(const complex<_Up>&); + /// Multiply this complex number by another. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator*=(const complex<_Up>&); + /// Divide this complex number by another. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator/=(const complex<_Up>&); + + _GLIBCXX_CONSTEXPR complex __rep() const + { return *this; } + + private: + _Tp _M_real; + _Tp _M_imag; + }; + + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator=(const _Tp& __t) + { + _M_real = __t; + _M_imag = _Tp(); + return *this; + } + + // 26.2.5/5 + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator*=(const _Tp& __t) + { + _M_real *= __t; + _M_imag *= __t; + return *this; + } + + // 26.2.5/7 + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator/=(const _Tp& __t) + { + _M_real /= __t; + _M_imag /= __t; + return *this; + } + + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator=(const complex<_Up>& __z) + { + _M_real = __z.real(); + _M_imag = __z.imag(); + return *this; + } + + // 26.2.5/9 + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator+=(const complex<_Up>& __z) + { + _M_real += __z.real(); + _M_imag += __z.imag(); + return *this; + } + + // 26.2.5/11 + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator-=(const complex<_Up>& __z) + { + _M_real -= __z.real(); + _M_imag -= __z.imag(); + return *this; + } + + // 26.2.5/13 + // XXX: This is a grammar school implementation. + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator*=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); + _M_imag = _M_real * __z.imag() + _M_imag * __z.real(); + _M_real = __r; + return *this; + } + + // 26.2.5/15 + // XXX: This is a grammar school implementation. + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator/=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); + const _Tp __n = std::norm(__z); + _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n; + _M_real = __r / __n; + return *this; + } + + // Operators: + ///@{ + /// Return new complex value @a x plus @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r += __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x minus @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = -__y; + __r += __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x times @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r *= __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x divided by @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + ///@} + + /// Return @a x. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x) + { return __x; } + + /// Return complex negation of @a x. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x) + { return complex<_Tp>(-__x.real(), -__x.imag()); } + + ///@{ + /// Return true if @a x is equal to @a y. + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() == __y.real() && __x.imag() == __y.imag(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() == __y && __x.imag() == _Tp(); } + +#if !(__cpp_impl_three_way_comparison >= 201907L) + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const _Tp& __x, const complex<_Tp>& __y) + { return __x == __y.real() && _Tp() == __y.imag(); } + ///@} + + ///@{ + /// Return false if @a x is equal to @a y. + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() != __y.real() || __x.imag() != __y.imag(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() != __y || __x.imag() != _Tp(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const _Tp& __x, const complex<_Tp>& __y) + { return __x != __y.real() || _Tp() != __y.imag(); } +#endif + ///@} + + /// Extraction operator for complex values. + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) + { + bool __fail = true; + _CharT __ch; + if (__is >> __ch) + { + if (_Traits::eq(__ch, __is.widen('('))) + { + _Tp __u; + if (__is >> __u >> __ch) + { + const _CharT __rparen = __is.widen(')'); + if (_Traits::eq(__ch, __rparen)) + { + __x = __u; + __fail = false; + } + else if (_Traits::eq(__ch, __is.widen(','))) + { + _Tp __v; + if (__is >> __v >> __ch) + { + if (_Traits::eq(__ch, __rparen)) + { + __x = complex<_Tp>(__u, __v); + __fail = false; + } + else + __is.putback(__ch); + } + } + else + __is.putback(__ch); + } + } + else + { + __is.putback(__ch); + _Tp __u; + if (__is >> __u) + { + __x = __u; + __fail = false; + } + } + } + if (__fail) + __is.setstate(ios_base::failbit); + return __is; + } + + /// Insertion operator for complex values. + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) + { + basic_ostringstream<_CharT, _Traits> __s; + __s.flags(__os.flags()); + __s.imbue(__os.getloc()); + __s.precision(__os.precision()); + __s << '(' << __x.real() << ',' << __x.imag() << ')'; + return __os << __s.str(); + } + + // Values +#if __cplusplus >= 201103L + template + constexpr _Tp + real(const complex<_Tp>& __z) + { return __z.real(); } + + template + constexpr _Tp + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#else + template + inline _Tp& + real(complex<_Tp>& __z) + { return __z.real(); } + + template + inline const _Tp& + real(const complex<_Tp>& __z) + { return __z.real(); } + + template + inline _Tp& + imag(complex<_Tp>& __z) + { return __z.imag(); } + + template + inline const _Tp& + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#endif + + // 26.2.7/3 abs(__z): Returns the magnitude of __z. + template + inline _Tp + __complex_abs(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + const _Tp __s = std::max(abs(__x), abs(__y)); + if (__s == _Tp()) // well ... + return __s; + __x /= __s; + __y /= __s; + return __s * sqrt(__x * __x + __y * __y); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline float + __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); } + + inline double + __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); } + + inline long double + __complex_abs(const __complex__ long double& __z) + { return __builtin_cabsl(__z); } + + template + inline _Tp + abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } +#else + template + inline _Tp + abs(const complex<_Tp>& __z) { return __complex_abs(__z); } +#endif + + + // 26.2.7/4: arg(__z): Returns the phase angle of __z. + template + inline _Tp + __complex_arg(const complex<_Tp>& __z) + { return atan2(__z.imag(), __z.real()); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline float + __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); } + + inline double + __complex_arg(__complex__ double __z) { return __builtin_carg(__z); } + + inline long double + __complex_arg(const __complex__ long double& __z) + { return __builtin_cargl(__z); } + + template + inline _Tp + arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } +#else + template + inline _Tp + arg(const complex<_Tp>& __z) { return __complex_arg(__z); } +#endif + + // 26.2.7/5: norm(__z) returns the squared magnitude of __z. + // As defined, norm() is -not- a norm is the common mathematical + // sense used in numerics. The helper class _Norm_helper<> tries to + // distinguish between builtin floating point and the rest, so as + // to deliver an answer as close as possible to the real value. + template + struct _Norm_helper + { + template + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return __x * __x + __y * __y; + } + }; + + template<> + struct _Norm_helper + { + template + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + { + //_Tp __res = std::abs(__z); + //return __res * __res; + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return __x * __x + __y * __y; + } + }; + + template + inline _GLIBCXX20_CONSTEXPR _Tp + norm(const complex<_Tp>& __z) + { + return _Norm_helper<__is_floating<_Tp>::__value + && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); + } + + template + inline complex<_Tp> + polar(const _Tp& __rho, const _Tp& __theta) + { + __glibcxx_assert( __rho >= 0 ); + return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + conj(const complex<_Tp>& __z) + { return complex<_Tp>(__z.real(), -__z.imag()); } + + // Transcendentals + + // 26.2.8/1 cos(__z): Returns the cosine of __z. + template + inline complex<_Tp> + __complex_cos(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); } + + inline __complex__ double + __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); } + + inline __complex__ long double + __complex_cos(const __complex__ long double& __z) + { return __builtin_ccosl(__z); } + + template + inline complex<_Tp> + cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); } +#else + template + inline complex<_Tp> + cos(const complex<_Tp>& __z) { return __complex_cos(__z); } +#endif + + // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z. + template + inline complex<_Tp> + __complex_cosh(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); } + + inline __complex__ double + __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); } + + inline __complex__ long double + __complex_cosh(const __complex__ long double& __z) + { return __builtin_ccoshl(__z); } + + template + inline complex<_Tp> + cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); } +#else + template + inline complex<_Tp> + cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); } +#endif + + // 26.2.8/3 exp(__z): Returns the complex base e exponential of x + template + inline complex<_Tp> + __complex_exp(const complex<_Tp>& __z) + { return std::polar<_Tp>(exp(__z.real()), __z.imag()); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); } + + inline __complex__ double + __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); } + + inline __complex__ long double + __complex_exp(const __complex__ long double& __z) + { return __builtin_cexpl(__z); } + + template + inline complex<_Tp> + exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); } +#else + template + inline complex<_Tp> + exp(const complex<_Tp>& __z) { return __complex_exp(__z); } +#endif + + // 26.2.8/5 log(__z): Returns the natural complex logarithm of __z. + // The branch cut is along the negative axis. + template + inline complex<_Tp> + __complex_log(const complex<_Tp>& __z) + { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_log(__complex__ float __z) { return __builtin_clogf(__z); } + + inline __complex__ double + __complex_log(__complex__ double __z) { return __builtin_clog(__z); } + + inline __complex__ long double + __complex_log(const __complex__ long double& __z) + { return __builtin_clogl(__z); } + + template + inline complex<_Tp> + log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); } +#else + template + inline complex<_Tp> + log(const complex<_Tp>& __z) { return __complex_log(__z); } +#endif + + template + inline complex<_Tp> + log10(const complex<_Tp>& __z) + { return std::log(__z) / log(_Tp(10.0)); } + + // 26.2.8/10 sin(__z): Returns the sine of __z. + template + inline complex<_Tp> + __complex_sin(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); } + + inline __complex__ double + __complex_sin(__complex__ double __z) { return __builtin_csin(__z); } + + inline __complex__ long double + __complex_sin(const __complex__ long double& __z) + { return __builtin_csinl(__z); } + + template + inline complex<_Tp> + sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); } +#else + template + inline complex<_Tp> + sin(const complex<_Tp>& __z) { return __complex_sin(__z); } +#endif + + // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z. + template + inline complex<_Tp> + __complex_sinh(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); } + + inline __complex__ double + __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); } + + inline __complex__ long double + __complex_sinh(const __complex__ long double& __z) + { return __builtin_csinhl(__z); } + + template + inline complex<_Tp> + sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); } +#else + template + inline complex<_Tp> + sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); } +#endif + + // 26.2.8/13 sqrt(__z): Returns the complex square root of __z. + // The branch cut is on the negative axis. + template + complex<_Tp> + __complex_sqrt(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + + if (__x == _Tp()) + { + _Tp __t = sqrt(abs(__y) / 2); + return complex<_Tp>(__t, __y < _Tp() ? -__t : __t); + } + else + { + _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x))); + _Tp __u = __t / 2; + return __x > _Tp() + ? complex<_Tp>(__u, __y / __t) + : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u); + } + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); } + + inline __complex__ double + __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); } + + inline __complex__ long double + __complex_sqrt(const __complex__ long double& __z) + { return __builtin_csqrtl(__z); } + + template + inline complex<_Tp> + sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); } +#else + template + inline complex<_Tp> + sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); } +#endif + + // 26.2.8/14 tan(__z): Return the complex tangent of __z. + + template + inline complex<_Tp> + __complex_tan(const complex<_Tp>& __z) + { return std::sin(__z) / std::cos(__z); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); } + + inline __complex__ double + __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); } + + inline __complex__ long double + __complex_tan(const __complex__ long double& __z) + { return __builtin_ctanl(__z); } + + template + inline complex<_Tp> + tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); } +#else + template + inline complex<_Tp> + tan(const complex<_Tp>& __z) { return __complex_tan(__z); } +#endif + + + // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z. + + template + inline complex<_Tp> + __complex_tanh(const complex<_Tp>& __z) + { return std::sinh(__z) / std::cosh(__z); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); } + + inline __complex__ double + __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); } + + inline __complex__ long double + __complex_tanh(const __complex__ long double& __z) + { return __builtin_ctanhl(__z); } + + template + inline complex<_Tp> + tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); } +#else + template + inline complex<_Tp> + tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); } +#endif + + + // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x + // raised to the __y-th power. The branch + // cut is on the negative axis. + template + complex<_Tp> + __complex_pow_unsigned(complex<_Tp> __x, unsigned __n) + { + complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1); + + while (__n >>= 1) + { + __x *= __x; + if (__n % 2) + __y *= __x; + } + + return __y; + } + + // In C++11 mode we used to implement the resolution of + // DR 844. complex pow return type is ambiguous. + // thus the following overload was disabled in that mode. However, doing + // that causes all sorts of issues, see, for example: + // http://gcc.gnu.org/ml/libstdc++/2013-01/msg00058.html + // and also PR57974. + template + inline complex<_Tp> + pow(const complex<_Tp>& __z, int __n) + { + return __n < 0 + ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(unsigned)__n) + : std::__complex_pow_unsigned(__z, __n); + } + + template + complex<_Tp> + pow(const complex<_Tp>& __x, const _Tp& __y) + { +#if ! _GLIBCXX_USE_C99_COMPLEX + if (__x == _Tp()) + return _Tp(); +#endif + if (__x.imag() == _Tp() && __x.real() > _Tp()) + return pow(__x.real(), __y); + + complex<_Tp> __t = std::log(__x); + return std::polar<_Tp>(exp(__y * __t.real()), __y * __t.imag()); + } + + template + inline complex<_Tp> + __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_pow(__complex__ float __x, __complex__ float __y) + { return __builtin_cpowf(__x, __y); } + + inline __complex__ double + __complex_pow(__complex__ double __x, __complex__ double __y) + { return __builtin_cpow(__x, __y); } + + inline __complex__ long double + __complex_pow(const __complex__ long double& __x, + const __complex__ long double& __y) + { return __builtin_cpowl(__x, __y); } + + template + inline complex<_Tp> + pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __complex_pow(__x.__rep(), __y.__rep()); } +#else + template + inline complex<_Tp> + pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __complex_pow(__x, __y); } +#endif + + template + inline complex<_Tp> + pow(const _Tp& __x, const complex<_Tp>& __y) + { + return __x > _Tp() ? std::polar<_Tp>(pow(__x, __y.real()), + __y.imag() * log(__x)) + : std::pow(complex<_Tp>(__x), __y); + } + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef float value_type; + typedef __complex__ float _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr float + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr float + imag() const { return __imag__ _M_value; } +#else + float& + real() { return __real__ _M_value; } + + const float& + real() const { return __real__ _M_value; } + + float& + imag() { return __imag__ _M_value; } + + const float& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(float __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(float __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(float __f) + { + _M_value = __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(float __f) + { + _M_value += __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(float __f) + { + _M_value -= __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(float __f) + { + _M_value *= __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(float __f) + { + _M_value /= __f; + return *this; + } + + // Let the compiler synthesize the copy and assignment + // operator. It always does a pretty good job. +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef double value_type; + typedef __complex__ double _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr double + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr double + imag() const { return __imag__ _M_value; } +#else + double& + real() { return __real__ _M_value; } + + const double& + real() const { return __real__ _M_value; } + + double& + imag() { return __imag__ _M_value; } + + const double& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(double __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(double __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(double __d) + { + _M_value = __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(double __d) + { + _M_value += __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(double __d) + { + _M_value -= __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(double __d) + { + _M_value *= __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(double __d) + { + _M_value /= __d; + return *this; + } + + // The compiler will synthesize this, efficiently. +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + _M_value = __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef long double value_type; + typedef __complex__ long double _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, + long double __i = 0.0L) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr long double + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr long double + imag() const { return __imag__ _M_value; } +#else + long double& + real() { return __real__ _M_value; } + + const long double& + real() const { return __real__ _M_value; } + + long double& + imag() { return __imag__ _M_value; } + + const long double& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(long double __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(long double __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(long double __r) + { + _M_value = __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(long double __r) + { + _M_value += __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(long double __r) + { + _M_value -= __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(long double __r) + { + _M_value *= __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(long double __r) + { + _M_value /= __r; + return *this; + } + + // The compiler knows how to do this efficiently +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + _M_value = __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + // These bits have to be at the end of this file, so that the + // specializations have all been defined. + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. + // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); +#endif +#endif + + /// @} group complex_numbers + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Forward declarations. + template std::complex<_Tp> acos(const std::complex<_Tp>&); + template std::complex<_Tp> asin(const std::complex<_Tp>&); + template std::complex<_Tp> atan(const std::complex<_Tp>&); + + template std::complex<_Tp> acosh(const std::complex<_Tp>&); + template std::complex<_Tp> asinh(const std::complex<_Tp>&); + template std::complex<_Tp> atanh(const std::complex<_Tp>&); + // DR 595. + template _Tp fabs(const std::complex<_Tp>&); + + template + inline std::complex<_Tp> + __complex_acos(const std::complex<_Tp>& __z) + { + const std::complex<_Tp> __t = std::asin(__z); + const _Tp __pi_2 = 1.5707963267948966192313216916397514L; + return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acos(__complex__ float __z) + { return __builtin_cacosf(__z); } + + inline __complex__ double + __complex_acos(__complex__ double __z) + { return __builtin_cacos(__z); } + + inline __complex__ long double + __complex_acos(const __complex__ long double& __z) + { return __builtin_cacosl(__z); } + + template + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z.__rep()); } +#else + /// acos(__z) [8.1.2]. + // Effects: Behaves the same as C99 function cacos, defined + // in subclause 7.3.5.1. + template + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z); } +#endif + + template + inline std::complex<_Tp> + __complex_asin(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t(-__z.imag(), __z.real()); + __t = std::asinh(__t); + return std::complex<_Tp>(__t.imag(), -__t.real()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asin(__complex__ float __z) + { return __builtin_casinf(__z); } + + inline __complex__ double + __complex_asin(__complex__ double __z) + { return __builtin_casin(__z); } + + inline __complex__ long double + __complex_asin(const __complex__ long double& __z) + { return __builtin_casinl(__z); } + + template + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z.__rep()); } +#else + /// asin(__z) [8.1.3]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.5.2. + template + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z); } +#endif + + template + std::complex<_Tp> + __complex_atan(const std::complex<_Tp>& __z) + { + const _Tp __r2 = __z.real() * __z.real(); + const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag(); + + _Tp __num = __z.imag() + _Tp(1.0); + _Tp __den = __z.imag() - _Tp(1.0); + + __num = __r2 + __num * __num; + __den = __r2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x), + _Tp(0.25) * log(__num / __den)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atan(__complex__ float __z) + { return __builtin_catanf(__z); } + + inline __complex__ double + __complex_atan(__complex__ double __z) + { return __builtin_catan(__z); } + + inline __complex__ long double + __complex_atan(const __complex__ long double& __z) + { return __builtin_catanl(__z); } + + template + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z.__rep()); } +#else + /// atan(__z) [8.1.4]. + // Effects: Behaves the same as C99 function catan, defined + // in subclause 7.3.5.3. + template + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z); } +#endif + + template + std::complex<_Tp> + __complex_acosh(const std::complex<_Tp>& __z) + { + // Kahan's formula. + return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0))) + + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acosh(__complex__ float __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ double + __complex_acosh(__complex__ double __z) + { return __builtin_cacosh(__z); } + + inline __complex__ long double + __complex_acosh(const __complex__ long double& __z) + { return __builtin_cacoshl(__z); } + + template + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z.__rep()); } +#else + /// acosh(__z) [8.1.5]. + // Effects: Behaves the same as C99 function cacosh, defined + // in subclause 7.3.6.1. + template + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z); } +#endif + + template + std::complex<_Tp> + __complex_asinh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) + _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asinh(__complex__ float __z) + { return __builtin_casinhf(__z); } + + inline __complex__ double + __complex_asinh(__complex__ double __z) + { return __builtin_casinh(__z); } + + inline __complex__ long double + __complex_asinh(const __complex__ long double& __z) + { return __builtin_casinhl(__z); } + + template + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z.__rep()); } +#else + /// asinh(__z) [8.1.6]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.6.2. + template + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z); } +#endif + + template + std::complex<_Tp> + __complex_atanh(const std::complex<_Tp>& __z) + { + const _Tp __i2 = __z.imag() * __z.imag(); + const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real(); + + _Tp __num = _Tp(1.0) + __z.real(); + _Tp __den = _Tp(1.0) - __z.real(); + + __num = __i2 + __num * __num; + __den = __i2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)), + _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atanh(__complex__ float __z) + { return __builtin_catanhf(__z); } + + inline __complex__ double + __complex_atanh(__complex__ double __z) + { return __builtin_catanh(__z); } + + inline __complex__ long double + __complex_atanh(const __complex__ long double& __z) + { return __builtin_catanhl(__z); } + + template + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z.__rep()); } +#else + /// atanh(__z) [8.1.7]. + // Effects: Behaves the same as C99 function catanh, defined + // in subclause 7.3.6.3. + template + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z); } +#endif + + template + inline _Tp + /// fabs(__z) [8.1.8]. + // Effects: Behaves the same as C99 function cabs, defined + // in subclause 7.3.8.1. + fabs(const std::complex<_Tp>& __z) + { return std::abs(__z); } + + /// Additional overloads [8.1.9]. + template + inline typename __gnu_cxx::__promote<_Tp>::__type + arg(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; +#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) + return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L) + : __type(); +#else + return std::arg(std::complex<__type>(__x)); +#endif + } + + template + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + imag(_Tp) + { return _Tp(); } + + template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + norm(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __type(__x) * __type(__x); + } + + template + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + real(_Tp __x) + { return __x; } + + template + inline std::complex::__type> + pow(const std::complex<_Tp>& __x, const _Up& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), __type(__y)); + } + + template + inline std::complex::__type> + pow(const _Tp& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), std::complex<__type>(__y)); + } + + template + inline std::complex::__type> + pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), + std::complex<__type>(__y)); + } + + // Forward declarations. + // DR 781. + template + std::complex<_Tp> proj(const std::complex<_Tp>&); + + // Generic implementation of std::proj, does not work for infinities. + template + inline std::complex<_Tp> + __complex_proj(const std::complex<_Tp>& __z) + { return __z; } + +#if _GLIBCXX_USE_C99_COMPLEX + inline complex + __complex_proj(const complex& __z) + { return __builtin_cprojf(__z.__rep()); } + + inline complex + __complex_proj(const complex& __z) + { return __builtin_cproj(__z.__rep()); } + + inline complex + __complex_proj(const complex& __z) + { return __builtin_cprojl(__z.__rep()); } +#elif defined _GLIBCXX_USE_C99_MATH_TR1 + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_inff(), + __builtin_copysignf(0.0f, __z.imag())); + return __z; + } + + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_inf(), + __builtin_copysign(0.0, __z.imag())); + return __z; + } + + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_infl(), + __builtin_copysignl(0.0l, __z.imag())); + return __z; + } +#endif + + template + inline std::complex<_Tp> + proj(const std::complex<_Tp>& __z) + { return __complex_proj(__z); } + + // Overload for scalars + template + inline std::complex::__type> + proj(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::proj(std::complex<__type>(__x)); + } + + template + inline _GLIBCXX20_CONSTEXPR + std::complex::__type> + conj(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::complex<__type>(__x, -__type()); + } + +#if __cplusplus > 201103L + +inline namespace literals { +inline namespace complex_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" +#define __cpp_lib_complex_udls 201309L + + constexpr std::complex + operator""if(long double __num) + { return std::complex{0.0F, static_cast(__num)}; } + + constexpr std::complex + operator""if(unsigned long long __num) + { return std::complex{0.0F, static_cast(__num)}; } + + constexpr std::complex + operator""i(long double __num) + { return std::complex{0.0, static_cast(__num)}; } + + constexpr std::complex + operator""i(unsigned long long __num) + { return std::complex{0.0, static_cast(__num)}; } + + constexpr std::complex + operator""il(long double __num) + { return std::complex{0.0L, __num}; } + + constexpr std::complex + operator""il(unsigned long long __num) + { return std::complex{0.0L, static_cast(__num)}; } + +#pragma GCC diagnostic pop +} // inline namespace complex_literals +} // inline namespace literals + +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif /* _GLIBCXX_COMPLEX */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex.blob new file mode 100644 index 0000000000000000000000000000000000000000..d0c0eb57d89313565f7a3b1d449f99137381b7d2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@complex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable new file mode 100644 index 0000000000000000000000000000000000000000..2a23e65bbd308d395098ca702adc94a4e4ba47fe --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable @@ -0,0 +1,450 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/condition_variable + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CONDITION_VARIABLE +#define _GLIBCXX_CONDITION_VARIABLE 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include + +#if __cplusplus > 201703L +# include +#endif + +#if defined(_GLIBCXX_HAS_GTHREADS) + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup condition_variables Condition Variables + * @ingroup concurrency + * + * Classes for condition_variable support. + * @{ + */ + + /// cv_status + enum class cv_status { no_timeout, timeout }; + + /// condition_variable + class condition_variable + { + using steady_clock = chrono::steady_clock; + using system_clock = chrono::system_clock; +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + using __clock_t = steady_clock; +#else + using __clock_t = system_clock; +#endif + + __condvar _M_cond; + + public: + typedef __gthread_cond_t* native_handle_type; + + condition_variable() noexcept; + ~condition_variable() noexcept; + + condition_variable(const condition_variable&) = delete; + condition_variable& operator=(const condition_variable&) = delete; + + void + notify_one() noexcept; + + void + notify_all() noexcept; + + void + wait(unique_lock& __lock); + + template + void + wait(unique_lock& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point& __atime) + { return __wait_until_impl(__lock, __atime); } +#endif + + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point& __atime) + { return __wait_until_impl(__lock, __atime); } + + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + using __s_dur = typename __clock_t::duration; + const typename _Clock::time_point __c_entry = _Clock::now(); + const __clock_t::time_point __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + + chrono::__detail::ceil<__s_dur>(__delta); + + if (__wait_until_impl(__lock, __s_atime) == cv_status::no_timeout) + return cv_status::no_timeout; + // We got a timeout when measured against __clock_t but + // we need to check against the caller-supplied clock + // to tell whether we should return a timeout. + if (_Clock::now() < __atime) + return cv_status::no_timeout; + return cv_status::timeout; + } + + template + bool + wait_until(unique_lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p) + { + while (!__p()) + if (wait_until(__lock, __atime) == cv_status::timeout) + return __p(); + return true; + } + + template + cv_status + wait_for(unique_lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime) + { + using __dur = typename steady_clock::duration; + return wait_until(__lock, + steady_clock::now() + + chrono::__detail::ceil<__dur>(__rtime)); + } + + template + bool + wait_for(unique_lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, + _Predicate __p) + { + using __dur = typename steady_clock::duration; + return wait_until(__lock, + steady_clock::now() + + chrono::__detail::ceil<__dur>(__rtime), + std::move(__p)); + } + + native_handle_type + native_handle() + { return _M_cond.native_handle(); } + + private: +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + template + cv_status + __wait_until_impl(unique_lock& __lock, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + _M_cond.wait_until(*__lock.mutex(), CLOCK_MONOTONIC, __ts); + + return (steady_clock::now() < __atime + ? cv_status::no_timeout : cv_status::timeout); + } +#endif + + template + cv_status + __wait_until_impl(unique_lock& __lock, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + _M_cond.wait_until(*__lock.mutex(), __ts); + + return (system_clock::now() < __atime + ? cv_status::no_timeout : cv_status::timeout); + } + }; + + void + notify_all_at_thread_exit(condition_variable&, unique_lock); + + struct __at_thread_exit_elt + { + __at_thread_exit_elt* _M_next; + void (*_M_cb)(void*); + }; + + inline namespace _V2 { + + /// condition_variable_any + // Like above, but mutex is not required to have try_lock. + class condition_variable_any + { +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + using __clock_t = chrono::steady_clock; +#else + using __clock_t = chrono::system_clock; +#endif + condition_variable _M_cond; + shared_ptr _M_mutex; + + // scoped unlock - unlocks in ctor, re-locks in dtor + template + struct _Unlock + { + explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + ~_Unlock() noexcept(false) + { + if (uncaught_exception()) + { + __try + { _M_lock.lock(); } + __catch(const __cxxabiv1::__forced_unwind&) + { __throw_exception_again; } + __catch(...) + { } + } + else + _M_lock.lock(); + } +#pragma GCC diagnostic pop + + _Unlock(const _Unlock&) = delete; + _Unlock& operator=(const _Unlock&) = delete; + + _Lock& _M_lock; + }; + + public: + condition_variable_any() : _M_mutex(std::make_shared()) { } + ~condition_variable_any() = default; + + condition_variable_any(const condition_variable_any&) = delete; + condition_variable_any& operator=(const condition_variable_any&) = delete; + + void + notify_one() noexcept + { + lock_guard __lock(*_M_mutex); + _M_cond.notify_one(); + } + + void + notify_all() noexcept + { + lock_guard __lock(*_M_mutex); + _M_cond.notify_all(); + } + + template + void + wait(_Lock& __lock) + { + shared_ptr __mutex = _M_mutex; + unique_lock __my_lock(*__mutex); + _Unlock<_Lock> __unlock(__lock); + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + unique_lock __my_lock2(std::move(__my_lock)); + _M_cond.wait(__my_lock2); + } + + + template + void + wait(_Lock& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + + template + cv_status + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { + shared_ptr __mutex = _M_mutex; + unique_lock __my_lock(*__mutex); + _Unlock<_Lock> __unlock(__lock); + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + unique_lock __my_lock2(std::move(__my_lock)); + return _M_cond.wait_until(__my_lock2, __atime); + } + + template + bool + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p) + { + while (!__p()) + if (wait_until(__lock, __atime) == cv_status::timeout) + return __p(); + return true; + } + + template + cv_status + wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime) + { return wait_until(__lock, __clock_t::now() + __rtime); } + + template + bool + wait_for(_Lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p) + { return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); } + +#ifdef __cpp_lib_jthread + template + bool wait(_Lock& __lock, + stop_token __stoken, + _Predicate __p) + { + if (__stoken.stop_requested()) + { + return __p(); + } + + std::stop_callback __cb(__stoken, [this] { notify_all(); }); + shared_ptr __mutex = _M_mutex; + while (!__p()) + { + unique_lock __my_lock(*__mutex); + if (__stoken.stop_requested()) + { + return false; + } + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + _Unlock<_Lock> __unlock(__lock); + unique_lock __my_lock2(std::move(__my_lock)); + _M_cond.wait(__my_lock2); + } + return true; + } + + template + bool wait_until(_Lock& __lock, + stop_token __stoken, + const chrono::time_point<_Clock, _Duration>& __abs_time, + _Predicate __p) + { + if (__stoken.stop_requested()) + { + return __p(); + } + + std::stop_callback __cb(__stoken, [this] { notify_all(); }); + shared_ptr __mutex = _M_mutex; + while (!__p()) + { + bool __stop; + { + unique_lock __my_lock(*__mutex); + if (__stoken.stop_requested()) + { + return false; + } + _Unlock<_Lock> __u(__lock); + unique_lock __my_lock2(std::move(__my_lock)); + const auto __status = _M_cond.wait_until(__my_lock2, __abs_time); + __stop = (__status == std::cv_status::timeout) || __stoken.stop_requested(); + } + if (__stop) + { + return __p(); + } + } + return true; + } + + template + bool wait_for(_Lock& __lock, + stop_token __stoken, + const chrono::duration<_Rep, _Period>& __rel_time, + _Predicate __p) + { + auto __abst = std::chrono::steady_clock::now() + __rel_time; + return wait_until(__lock, + std::move(__stoken), + __abst, + std::move(__p)); + } +#endif + }; + + } // end inline namespace + + /// @} group condition_variables +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _GLIBCXX_HAS_GTHREADS +#endif // C++11 +#endif // _GLIBCXX_CONDITION_VARIABLE diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable.blob new file mode 100644 index 0000000000000000000000000000000000000000..8a37df3f2b6ee846e22d586706e5a978d3b8bef5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@condition_variable.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp new file mode 100644 index 0000000000000000000000000000000000000000..be2e3807b3204ca72e651171d79f44b2424e84af --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp @@ -0,0 +1,61 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file csetjmp + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c setjmp.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSETJMP +#define _GLIBCXX_CSETJMP 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef longjmp + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef setjmp +#define setjmp(env) setjmp (env) +#endif + +namespace std +{ + using ::jmp_buf; + using ::longjmp; +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp.blob new file mode 100644 index 0000000000000000000000000000000000000000..d0a125c7c2c5e27d75cfe5509a17b52620d7ad48 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csetjmp.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal new file mode 100644 index 0000000000000000000000000000000000000000..95a05519f020b3b2b3b6577d9d8121c90c2f7ec9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal @@ -0,0 +1,57 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file csignal + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c signal.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSIGNAL +#define _GLIBCXX_CSIGNAL 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef raise + +namespace std +{ + using ::sig_atomic_t; + using ::signal; + using ::raise; +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal.blob new file mode 100644 index 0000000000000000000000000000000000000000..08066e576ef9bd465db0a7ff1477c7c17a517921 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@csignal.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign new file mode 100644 index 0000000000000000000000000000000000000000..b6ed4873e512945697e98bf1ad72f1a2fc887cae --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2011-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdalign + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CSTDALIGN +#define _GLIBCXX_CSTDALIGN 1 + +#if __cplusplus < 201103L +# include +#else +# include +# if _GLIBCXX_HAVE_STDALIGN_H +# include +# endif +#endif + +#endif + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign.blob new file mode 100644 index 0000000000000000000000000000000000000000..cc7b1e29faba7c0c2fc84d8dc0ec45f303685d34 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdalign.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg new file mode 100644 index 0000000000000000000000000000000000000000..bd82af7d7019412c0f49697cba775bb79afa15ce --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdarg + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdarg.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#undef __need___va_list +#include +#include + +#ifndef _GLIBCXX_CSTDARG +#define _GLIBCXX_CSTDARG 1 + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef va_end +#define va_end(ap) va_end (ap) +#endif + +namespace std +{ + using ::va_list; +} // namespace std + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg.blob new file mode 100644 index 0000000000000000000000000000000000000000..2a183674dcf67869716c8e8f0bfffaaf12d3ea18 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdarg.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool new file mode 100644 index 0000000000000000000000000000000000000000..95b22ca723a9ab9c45380525f0d1e821bea28115 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdbool + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CSTDBOOL +#define _GLIBCXX_CSTDBOOL 1 + +#if __cplusplus < 201103L +# include +#else +# include +# if _GLIBCXX_HAVE_STDBOOL_H +# include +# endif +#endif + +#endif + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool.blob new file mode 100644 index 0000000000000000000000000000000000000000..a4feaea8b3a321f7e6df015d75420cdfad5caf5a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdbool.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef new file mode 100644 index 0000000000000000000000000000000000000000..4970c2dfcfbf055c3ffd22ae5c35c4ad82859717 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef @@ -0,0 +1,180 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cstddef + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stddef.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.1 Types +// + +#ifndef _GLIBCXX_CSTDDEF +#define _GLIBCXX_CSTDDEF 1 + +#pragma GCC system_header + +#undef __need_wchar_t +#undef __need_ptrdiff_t +#undef __need_size_t +#undef __need_NULL +#undef __need_wint_t +#include +#include + +extern "C++" +{ +#if __cplusplus >= 201103L +namespace std +{ + // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h. + using ::max_align_t; +} +#endif // C++11 + +#if __cplusplus >= 201703L +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_byte 201603L + + /// std::byte + enum class byte : unsigned char {}; + + template struct __byte_operand { }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; +#ifdef _GLIBCXX_USE_CHAR8_T + template<> struct __byte_operand { using __type = byte; }; +#endif + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; +#if defined(__GLIBCXX_TYPE_INT_N_0) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + + template + using __byte_op_t = typename __byte_operand<_IntegerType>::__type; + + template + constexpr __byte_op_t<_IntegerType> + operator<<(byte __b, _IntegerType __shift) noexcept + { return (byte)(unsigned char)((unsigned)__b << __shift); } + + template + constexpr __byte_op_t<_IntegerType> + operator>>(byte __b, _IntegerType __shift) noexcept + { return (byte)(unsigned char)((unsigned)__b >> __shift); } + + constexpr byte + operator|(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); } + + constexpr byte + operator&(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); } + + constexpr byte + operator^(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); } + + constexpr byte + operator~(byte __b) noexcept + { return (byte)(unsigned char)~(unsigned)__b; } + + template + constexpr __byte_op_t<_IntegerType>& + operator<<=(byte& __b, _IntegerType __shift) noexcept + { return __b = __b << __shift; } + + template + constexpr __byte_op_t<_IntegerType>& + operator>>=(byte& __b, _IntegerType __shift) noexcept + { return __b = __b >> __shift; } + + constexpr byte& + operator|=(byte& __l, byte __r) noexcept + { return __l = __l | __r; } + + constexpr byte& + operator&=(byte& __l, byte __r) noexcept + { return __l = __l & __r; } + + constexpr byte& + operator^=(byte& __l, byte __r) noexcept + { return __l = __l ^ __r; } + + template + [[nodiscard]] + constexpr _IntegerType + to_integer(__byte_op_t<_IntegerType> __b) noexcept + { return _IntegerType(__b); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 +} // extern "C++" + +#endif // _GLIBCXX_CSTDDEF diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef.blob new file mode 100644 index 0000000000000000000000000000000000000000..e9f891dff73d191e71bfb606861969444ee4f8b3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstddef.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint new file mode 100644 index 0000000000000000000000000000000000000000..4490d06f0996e7e709c27f900ef5f3ee94aa78c7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint @@ -0,0 +1,91 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdint + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CSTDINT +#define _GLIBCXX_CSTDINT 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +#if _GLIBCXX_HAVE_STDINT_H +# include +#endif + +namespace std +{ +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; +#else // !_GLIBCXX_USE_C99_STDINT_TR1 + // Define the minimum needed for , etc. + using intmax_t = __INTMAX_TYPE__; + using uintmax_t = __UINTMAX_TYPE__; +#endif // _GLIBCXX_USE_C99_STDINT_TR1 +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_CSTDINT diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint.blob new file mode 100644 index 0000000000000000000000000000000000000000..45ea6a25b96ecb13a28040cc8710d78cc0909dcd Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdint.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio new file mode 100644 index 0000000000000000000000000000000000000000..4c7e136ed42030c0b88f4120f04257d75ebfbba5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio @@ -0,0 +1,194 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdio + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdio.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 27.8.2 C Library files +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSTDIO +#define _GLIBCXX_CSTDIO 1 + +#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS) +extern "C" char* gets (char* __s) __attribute__((__deprecated__)); +#endif + +// Get rid of those macros defined in in lieu of real functions. +#undef clearerr +#undef fclose +#undef feof +#undef ferror +#undef fflush +#undef fgetc +#undef fgetpos +#undef fgets +#undef fopen +#undef fprintf +#undef fputc +#undef fputs +#undef fread +#undef freopen +#undef fscanf +#undef fseek +#undef fsetpos +#undef ftell +#undef fwrite +#undef getc +#undef getchar +#if __cplusplus <= 201103L +# undef gets +#endif +#undef perror +#undef printf +#undef putc +#undef putchar +#undef puts +#undef remove +#undef rename +#undef rewind +#undef scanf +#undef setbuf +#undef setvbuf +#undef sprintf +#undef sscanf +#undef tmpfile +#undef tmpnam +#undef ungetc +#undef vfprintf +#undef vprintf +#undef vsprintf + +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; +#if __cplusplus <= 201103L + // LWG 2249 + using ::gets; +#endif + 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; +#if _GLIBCXX_USE_TMPNAM + using ::tmpnam; +#endif + using ::ungetc; + using ::vfprintf; + using ::vprintf; + using ::vsprintf; +} // namespace + +#if _GLIBCXX_USE_C99_STDIO + +#undef snprintf +#undef vfscanf +#undef vscanf +#undef vsnprintf +#undef vsscanf + +namespace __gnu_cxx +{ +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" int + (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...) + throw (); + extern "C" int + (vfscanf)(FILE * __restrict, const char * __restrict, __gnuc_va_list); + extern "C" int (vscanf)(const char * __restrict, __gnuc_va_list); + extern "C" int + (vsnprintf)(char * __restrict, std::size_t, const char * __restrict, + __gnuc_va_list) throw (); + extern "C" int + (vsscanf)(const char * __restrict, const char * __restrict, __gnuc_va_list) + throw (); +#endif + +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::snprintf; + using ::vfscanf; + using ::vscanf; + using ::vsnprintf; + using ::vsscanf; +#endif +} // namespace __gnu_cxx + +namespace std +{ + using ::__gnu_cxx::snprintf; + using ::__gnu_cxx::vfscanf; + using ::__gnu_cxx::vscanf; + using ::__gnu_cxx::vsnprintf; + using ::__gnu_cxx::vsscanf; +} // namespace std + +#endif // _GLIBCXX_USE_C99_STDIO + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio.blob new file mode 100644 index 0000000000000000000000000000000000000000..922e942f386319482a2435ecb11a00afa7a4625c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdio.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib new file mode 100644 index 0000000000000000000000000000000000000000..8a832aff0f98fd8325f691a30aad39d136626cc6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib @@ -0,0 +1,261 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdlib + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdlib.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include + +#ifndef _GLIBCXX_CSTDLIB +#define _GLIBCXX_CSTDLIB 1 + +#if !_GLIBCXX_HOSTED +// The C standard does not require a freestanding implementation to +// provide . However, the C++ standard does still require +// -- but only the functionality mentioned in +// [lib.support.start.term]. + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +namespace std +{ + extern "C" void abort(void) throw () _GLIBCXX_NORETURN; + extern "C" int atexit(void (*)(void)) throw (); + extern "C" void exit(int) throw () _GLIBCXX_NORETURN; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT + extern "C" int at_quick_exit(void (*)(void)) throw (); +# endif +# ifdef _GLIBCXX_HAVE_QUICK_EXIT + extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN; +# endif +#endif +} // namespace std + +#else + +// Need to ensure this finds the C library's not a libstdc++ +// wrapper that might already be installed later in the include search path. +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef abort +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) +# undef aligned_alloc +#endif +#undef atexit +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT +# undef at_quick_exit +# endif +#endif +#undef atof +#undef atoi +#undef atol +#undef bsearch +#undef calloc +#undef div +#undef exit +#undef free +#undef getenv +#undef labs +#undef ldiv +#undef malloc +#undef mblen +#undef mbstowcs +#undef mbtowc +#undef qsort +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_QUICK_EXIT +# undef quick_exit +# endif +#endif +#undef rand +#undef realloc +#undef srand +#undef strtod +#undef strtol +#undef strtoul +#undef system +#undef wcstombs +#undef wctomb + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::div_t; + using ::ldiv_t; + + using ::abort; +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) + using ::aligned_alloc; +#endif + using ::atexit; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT + using ::at_quick_exit; +# endif +#endif + using ::atof; + using ::atoi; + using ::atol; + using ::bsearch; + using ::calloc; + using ::div; + using ::exit; + using ::free; + using ::getenv; + using ::labs; + using ::ldiv; + using ::malloc; +#ifdef _GLIBCXX_HAVE_MBSTATE_T + using ::mblen; + using ::mbstowcs; + using ::mbtowc; +#endif // _GLIBCXX_HAVE_MBSTATE_T + using ::qsort; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_QUICK_EXIT + using ::quick_exit; +# endif +#endif + using ::rand; + using ::realloc; + using ::srand; + using ::strtod; + using ::strtol; + using ::strtoul; + using ::system; +#ifdef _GLIBCXX_USE_WCHAR_T + using ::wcstombs; + using ::wctomb; +#endif // _GLIBCXX_USE_WCHAR_T + +#ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO + inline ldiv_t + div(long __i, long __j) { return ldiv(__i, __j); } +#endif + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if _GLIBCXX_USE_C99_STDLIB + +#undef _Exit +#undef llabs +#undef lldiv +#undef atoll +#undef strtoll +#undef strtoull +#undef strtof +#undef strtold + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::lldiv_t; +#endif +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; +#endif +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::_Exit; +#endif + +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::llabs; + + inline lldiv_t + div(long long __n, long long __d) + { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } + + using ::lldiv; +#endif + +#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + extern "C" long long int (atoll)(const char *) throw (); + extern "C" long long int + (strtoll)(const char * __restrict, char ** __restrict, int) throw (); + extern "C" unsigned long long int + (strtoull)(const char * __restrict, char ** __restrict, int) throw (); +#endif +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::atoll; + using ::strtoll; + using ::strtoull; +#endif + using ::strtof; + using ::strtold; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace __gnu_cxx + +namespace std +{ +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::__gnu_cxx::lldiv_t; +#endif + using ::__gnu_cxx::_Exit; +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::__gnu_cxx::llabs; + using ::__gnu_cxx::div; + using ::__gnu_cxx::lldiv; +#endif + using ::__gnu_cxx::atoll; + using ::__gnu_cxx::strtof; + using ::__gnu_cxx::strtoll; + using ::__gnu_cxx::strtoull; + using ::__gnu_cxx::strtold; +} // namespace std + +#endif // _GLIBCXX_USE_C99_STDLIB + +} // extern "C++" + +#endif // !_GLIBCXX_HOSTED + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib.blob new file mode 100644 index 0000000000000000000000000000000000000000..d30bafb6063fdc9532400d2a3a2ba3d8dae2fe7e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstdlib.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring new file mode 100644 index 0000000000000000000000000000000000000000..f3b77d07505e6e3d6b8093cde3ad3d946f330297 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring @@ -0,0 +1,126 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cstring + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c string.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSTRING +#define _GLIBCXX_CSTRING 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef memchr +#undef memcmp +#undef memcpy +#undef memmove +#undef memset +#undef strcat +#undef strchr +#undef strcmp +#undef strcoll +#undef strcpy +#undef strcspn +#undef strerror +#undef strlen +#undef strncat +#undef strncmp +#undef strncpy +#undef strpbrk +#undef strrchr +#undef strspn +#undef strstr +#undef strtok +#undef strxfrm + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::memchr; + using ::memcmp; + using ::memcpy; + using ::memmove; + using ::memset; + using ::strcat; + using ::strcmp; + using ::strcoll; + using ::strcpy; + using ::strcspn; + using ::strerror; + using ::strlen; + using ::strncat; + using ::strncmp; + using ::strncpy; + using ::strspn; + using ::strtok; + using ::strxfrm; + using ::strchr; + using ::strpbrk; + using ::strrchr; + using ::strstr; + +#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO + inline void* + memchr(void* __s, int __c, size_t __n) + { return __builtin_memchr(__s, __c, __n); } + + inline char* + strchr(char* __s, int __n) + { return __builtin_strchr(__s, __n); } + + inline char* + strpbrk(char* __s1, const char* __s2) + { return __builtin_strpbrk(__s1, __s2); } + + inline char* + strrchr(char* __s, int __n) + { return __builtin_strrchr(__s, __n); } + + inline char* + strstr(char* __s1, const char* __s2) + { return __builtin_strstr(__s1, __s2); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring.blob new file mode 100644 index 0000000000000000000000000000000000000000..172bdf57127496cc6e953f4ed841681bfa423a9a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cstring.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath new file mode 100644 index 0000000000000000000000000000000000000000..f1cd7301a540feb85d7d252344ad02b1c4282f75 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ctgmath + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CTGMATH +#define _GLIBCXX_CTGMATH 1 + +#if __cplusplus < 201103L +# include +#else +# include +extern "C++" { +# include +} +#endif + +#endif + diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath.blob new file mode 100644 index 0000000000000000000000000000000000000000..fbb8bd4c857406b05f9cbe02f6648bcc6ab31318 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctgmath.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime new file mode 100644 index 0000000000000000000000000000000000000000..576ea5650677bb78d76666a84b85bb4b7bd73571 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime @@ -0,0 +1,84 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ctime + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c time.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.5 Date and time +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CTIME +#define _GLIBCXX_CTIME 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef clock +#undef difftime +#undef mktime +#undef time +#undef asctime +#undef ctime +#undef gmtime +#undef localtime +#undef strftime + +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 + +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_TIMESPEC_GET) +#undef timespec_get +namespace std +{ + using ::timespec; + using ::timespec_get; +} // namespace std +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime.blob new file mode 100644 index 0000000000000000000000000000000000000000..10ee4787bc5fece6de78bba6949db4058f4b2b4a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ctime.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar new file mode 100644 index 0000000000000000000000000000000000000000..bca2540250d01c798013ca53d3734e2becb97316 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar @@ -0,0 +1,108 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 2015-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cuchar + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c uchar.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882:2011 21.8 +// + +#ifndef _GLIBCXX_CUCHAR +#define _GLIBCXX_CUCHAR 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +#if (_GLIBCXX_USE_C11_UCHAR_CXX11 \ + || (_GLIBCXX_USE_CHAR8_T \ + && (_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T \ + || (__cplusplus >= 202002 \ + && _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20)))) + +#include + +#endif + + +// Support for mbrtoc8 and c8rtomb is conditioned on support by the C library. +#if (_GLIBCXX_USE_CHAR8_T \ + && (_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T \ + || (__cplusplus >= 202002 \ + && _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20))) + +#undef mbrtoc8 +#undef c8rtomb + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::mbrtoc8; + using ::c8rtomb; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _GLIBCXX_USE_CHAR8_T + + +#if _GLIBCXX_USE_C11_UCHAR_CXX11 + +// Get rid of those macros defined in in lieu of real functions. +#undef mbrtoc16 +#undef c16rtomb +#undef mbrtoc32 +#undef c32rtomb + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::mbrtoc16; + using ::c16rtomb; + using ::mbrtoc32; + using ::c32rtomb; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _GLIBCXX_USE_C11_UCHAR_CXX11 + +#endif // C++11 + +#endif // _GLIBCXX_CUCHAR diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar.blob new file mode 100644 index 0000000000000000000000000000000000000000..3e01a5e7c4c16a8b0e4ce3dfb62c3513ddf4d133 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cuchar.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar new file mode 100644 index 0000000000000000000000000000000000000000..5ad870b9677d251830558e50c1519e64fc7def84 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar @@ -0,0 +1,306 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cwchar + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c wchar.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 21.4 +// + +#pragma GCC system_header + +#include + +#if _GLIBCXX_HAVE_WCHAR_H +#include +#endif + +#ifndef _GLIBCXX_CWCHAR +#define _GLIBCXX_CWCHAR 1 + +// Need to do a bit of trickery here with mbstate_t as char_traits +// assumes it is in wchar.h, regardless of wchar_t specializations. +#ifndef _GLIBCXX_HAVE_MBSTATE_T +extern "C" +{ + typedef struct + { + int __fill[6]; + } mbstate_t; +} +#endif + +namespace std +{ + using ::mbstate_t; +} // namespace std + +// Get rid of those macros defined in in lieu of real functions. +#undef btowc +#undef fgetwc +#undef fgetws +#undef fputwc +#undef fputws +#undef fwide +#undef fwprintf +#undef fwscanf +#undef getwc +#undef getwchar +#undef mbrlen +#undef mbrtowc +#undef mbsinit +#undef mbsrtowcs +#undef putwc +#undef putwchar +#undef swprintf +#undef swscanf +#undef ungetwc +#undef vfwprintf +#if _GLIBCXX_HAVE_VFWSCANF +# undef vfwscanf +#endif +#undef vswprintf +#if _GLIBCXX_HAVE_VSWSCANF +# undef vswscanf +#endif +#undef vwprintf +#if _GLIBCXX_HAVE_VWSCANF +# undef vwscanf +#endif +#undef wcrtomb +#undef wcscat +#undef wcschr +#undef wcscmp +#undef wcscoll +#undef wcscpy +#undef wcscspn +#undef wcsftime +#undef wcslen +#undef wcsncat +#undef wcsncmp +#undef wcsncpy +#undef wcspbrk +#undef wcsrchr +#undef wcsrtombs +#undef wcsspn +#undef wcsstr +#undef wcstod +#if _GLIBCXX_HAVE_WCSTOF +# undef wcstof +#endif +#undef wcstok +#undef wcstol +#undef wcstoul +#undef wcsxfrm +#undef wctob +#undef wmemchr +#undef wmemcmp +#undef wmemcpy +#undef wmemmove +#undef wmemset +#undef wprintf +#undef wscanf + +#if _GLIBCXX_USE_WCHAR_T + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + 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; +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + using ::swprintf; +#endif + using ::swscanf; + using ::ungetwc; + using ::vfwprintf; +#if _GLIBCXX_HAVE_VFWSCANF + using ::vfwscanf; +#endif +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + using ::vswprintf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using ::vswscanf; +#endif + using ::vwprintf; +#if _GLIBCXX_HAVE_VWSCANF + using ::vwscanf; +#endif + 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; +#if _GLIBCXX_HAVE_WCSTOF + using ::wcstof; +#endif + using ::wcstok; + using ::wcstol; + using ::wcstoul; + using ::wcsxfrm; + using ::wctob; + using ::wmemcmp; + using ::wmemcpy; + using ::wmemmove; + using ::wmemset; + using ::wprintf; + using ::wscanf; + using ::wcschr; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsstr; + using ::wmemchr; + +#ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO + inline wchar_t* + wcschr(wchar_t* __p, wchar_t __c) + { return wcschr(const_cast(__p), __c); } + + inline wchar_t* + wcspbrk(wchar_t* __s1, const wchar_t* __s2) + { return wcspbrk(const_cast(__s1), __s2); } + + inline wchar_t* + wcsrchr(wchar_t* __p, wchar_t __c) + { return wcsrchr(const_cast(__p), __c); } + + inline wchar_t* + wcsstr(wchar_t* __s1, const wchar_t* __s2) + { return wcsstr(const_cast(__s1), __s2); } + + inline wchar_t* + wmemchr(wchar_t* __p, wchar_t __c, size_t __n) + { return wmemchr(const_cast(__p), __c, __n); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#if _GLIBCXX_USE_C99_WCHAR + +#undef wcstold +#undef wcstoll +#undef wcstoull + +namespace __gnu_cxx +{ +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" long double + (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw (); +#endif +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::wcstold; +#endif +#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + extern "C" long long int + (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw (); + extern "C" unsigned long long int + (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw (); +#endif +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::wcstoll; + using ::wcstoull; +#endif +} // namespace __gnu_cxx + +namespace std +{ + using ::__gnu_cxx::wcstold; + using ::__gnu_cxx::wcstoll; + using ::__gnu_cxx::wcstoull; +} // namespace + +#endif + +#endif //_GLIBCXX_USE_WCHAR_T + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_WCHAR_T + +namespace std +{ +#if _GLIBCXX_HAVE_WCSTOF + using std::wcstof; +#endif +#if _GLIBCXX_HAVE_VFWSCANF + using std::vfwscanf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using std::vswscanf; +#endif +#if _GLIBCXX_HAVE_VWSCANF + using std::vwscanf; +#endif + +#if _GLIBCXX_USE_C99_WCHAR + using std::wcstold; + using std::wcstoll; + using std::wcstoull; +#endif +} // namespace + +#endif // _GLIBCXX_USE_WCHAR_T + +#endif // C++11 + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar.blob new file mode 100644 index 0000000000000000000000000000000000000000..42626c3b1fa599ec86761be268675122be9e46fe Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwchar.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype new file mode 100644 index 0000000000000000000000000000000000000000..d80ff72b2020a898f5268f6a2517c38b5048f4d9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype @@ -0,0 +1,110 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cwctype + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c wctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: +// + +#pragma GCC system_header + +#include + +#if _GLIBCXX_HAVE_WCTYPE_H + +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 +// Work around glibc BZ 9694 +#include +#endif + +#include +#endif // _GLIBCXX_HAVE_WCTYPE_H + +#ifndef _GLIBCXX_CWCTYPE +#define _GLIBCXX_CWCTYPE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef iswalnum +#undef iswalpha +#if _GLIBCXX_HAVE_ISWBLANK +# undef iswblank +#endif +#undef iswcntrl +#undef iswctype +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef towctrans +#undef towlower +#undef towupper +#undef wctrans +#undef wctype + +#if _GLIBCXX_USE_WCHAR_T + +namespace std +{ + using ::wctrans_t; + using ::wctype_t; + using ::wint_t; + + using ::iswalnum; + using ::iswalpha; +#if _GLIBCXX_HAVE_ISWBLANK + using ::iswblank; +#endif + using ::iswcntrl; + using ::iswctype; + using ::iswdigit; + using ::iswgraph; + using ::iswlower; + using ::iswprint; + using ::iswpunct; + using ::iswspace; + using ::iswupper; + using ::iswxdigit; + using ::towctrans; + using ::towlower; + using ::towupper; + using ::wctrans; + using ::wctype; +} // namespace + +#endif //_GLIBCXX_USE_WCHAR_T + +#endif // _GLIBCXX_CWCTYPE diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype.blob new file mode 100644 index 0000000000000000000000000000000000000000..97a5a533bb07f4224b85c3f90f8b5e056a20a641 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@cwctype.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h new file mode 100644 index 0000000000000000000000000000000000000000..57c0ab2c3cf6d714ba41fed1b1107745494ba5e2 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h @@ -0,0 +1,70 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/assertions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_ASSERTIONS_H +#define _GLIBCXX_DEBUG_ASSERTIONS_H 1 + +#include + +#ifndef _GLIBCXX_DEBUG + +# define _GLIBCXX_DEBUG_ASSERT(_Condition) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) + +#endif + +#ifndef _GLIBCXX_ASSERTIONS +# define __glibcxx_requires_non_empty_range(_First,_Last) +# define __glibcxx_requires_nonempty() +# define __glibcxx_requires_subscript(_N) +#else + +// Verify that [_First, _Last) forms a non-empty iterator range. +# define __glibcxx_requires_non_empty_range(_First,_Last) \ + __glibcxx_assert(_First != _Last) +# define __glibcxx_requires_subscript(_N) \ + __glibcxx_assert(_N < this->size()) +// Verify that the container is nonempty +# define __glibcxx_requires_nonempty() \ + __glibcxx_assert(!this->empty()) +#endif + +#ifdef _GLIBCXX_DEBUG +# define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition) + +# ifdef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) +# else +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# endif + +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement +#endif + +#endif // _GLIBCXX_DEBUG_ASSERTIONS diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..afb821ef91c41748963678547e99cf0b9864266c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@assertions.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h new file mode 100644 index 0000000000000000000000000000000000000000..d3cdfbc044c360d51246dea6be2ad841a7a4dcde --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h @@ -0,0 +1,137 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/debug.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H +#define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1 + +/** Macros and namespaces used by the implementation outside of debug + * wrappers to verify certain properties. The __glibcxx_requires_xxx + * macros are merely wrappers around the __glibcxx_check_xxx wrappers + * when we are compiling with debug mode, but disappear when we are + * in release mode so that there is no checking performed in, e.g., + * the standard library algorithms. +*/ + +#include + +// Debug mode namespaces. + +/** + * @namespace std::__debug + * @brief GNU debug code, replaces standard behavior with debug behavior. + */ +namespace std +{ + namespace __debug { } +} + +/** @namespace __gnu_debug + * @brief GNU debug classes for public use. +*/ +namespace __gnu_debug +{ + using namespace std::__debug; + + template + struct _Safe_iterator; +} + +#ifndef _GLIBCXX_DEBUG + +# define __glibcxx_requires_cond(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) +# define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) +# define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) +# define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) +# define __glibcxx_requires_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) + +#else + +# include + +# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) \ + __glibcxx_check_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) \ + __glibcxx_check_can_increment(_First,_Size) +# define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) \ + __glibcxx_check_can_increment_range(_First1,_Last1,_First2) +# define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) \ + __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted(_First,_Last) \ + __glibcxx_check_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ + __glibcxx_check_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \ + __glibcxx_check_sorted_set(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ + __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) +# define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \ + __glibcxx_check_partitioned_lower(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \ + __glibcxx_check_partitioned_upper(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ + __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ + __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) \ + __glibcxx_check_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ + __glibcxx_check_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) \ + __glibcxx_check_string_len(_String,_Len) +# define __glibcxx_requires_irreflexive(_First,_Last) \ + __glibcxx_check_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) \ + __glibcxx_check_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) + +# include + +#endif + +#endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7d9804d4a7d7d36d0483c6be1d6aba87a46d68d2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@debug@debug.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque new file mode 100644 index 0000000000000000000000000000000000000000..dc5c2034b8f1c49020fbf2bf2e7dd77c89852c17 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque @@ -0,0 +1,137 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/deque + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_DEQUE +#define _GLIBCXX_DEQUE 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template + using deque = std::deque<_Tp, polymorphic_allocator<_Tp>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + inline typename deque<_Tp, _Alloc>::size_type + erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) + { + using namespace __gnu_cxx; + _GLIBCXX_STD_C::deque<_Tp, _Alloc>& __ucont = __cont; + const auto __osz = __cont.size(); + const auto __end = __ucont.end(); + auto __removed = std::__remove_if(__ucont.begin(), __end, + __ops::__pred_iter(std::ref(__pred))); + if (__removed != __end) + { + __cont.erase(__niter_wrap(__cont.begin(), __removed), + __cont.end()); + return __osz - __cont.size(); + } + + return 0; + } + + template + inline typename deque<_Tp, _Alloc>::size_type + erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) + { + using namespace __gnu_cxx; + _GLIBCXX_STD_C::deque<_Tp, _Alloc>& __ucont = __cont; + const auto __osz = __cont.size(); + const auto __end = __ucont.end(); + auto __removed = std::__remove_if(__ucont.begin(), __end, + __ops::__iter_equals_val(__value)); + if (__removed != __end) + { + __cont.erase(__niter_wrap(__cont.begin(), __removed), + __cont.end()); + return __osz - __cont.size(); + } + + return 0; + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_DEQUE */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque.blob new file mode 100644 index 0000000000000000000000000000000000000000..18873d26e7b2e227449f0fed97dd0dda67bafaa6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@deque.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception new file mode 100644 index 0000000000000000000000000000000000000000..ae2b0dd7f78d6d22b8dfc196b62b7578ccad9868 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception @@ -0,0 +1,172 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 1995-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file exception + * This is a Standard C++ Library header. + */ + +#ifndef __EXCEPTION__ +#define __EXCEPTION__ + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include +#include + +extern "C++" { + +namespace std +{ + /** @addtogroup exceptions + * @{ + */ + + /** If an %exception is thrown which is not listed in a function's + * %exception specification, one of these may be thrown. + * + * @ingroup exceptions + */ + class bad_exception : public exception + { + public: + bad_exception() _GLIBCXX_USE_NOEXCEPT { } + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; + + // See comment in eh_exception.cc. + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; + }; + + /// If you write a replacement %terminate handler, it must be of this type. + typedef void (*terminate_handler) (); + + /// Takes a new handler function as an argument, returns the old function. + terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + /// Return the current terminate handler. + terminate_handler get_terminate() noexcept; +#endif + + /** The runtime will call this function if %exception handling must be + * abandoned for any reason. It can also be called by the user. */ + void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); + +#if __cplusplus < 201703L || (__cplusplus <= 202002L && _GLIBCXX_USE_DEPRECATED) + /// If you write a replacement %unexpected handler, it must be of this type. + typedef void (*_GLIBCXX11_DEPRECATED unexpected_handler) (); + + /** Takes a new handler function as an argument, returns the old function. + * + * @deprecated Removed from the C++ standard in C++17 + */ + _GLIBCXX11_DEPRECATED + unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + /** Return the current unexpected handler. + * + * @since C++11 + * @deprecated Removed from the C++ standard in C++17 + */ + _GLIBCXX11_DEPRECATED + unexpected_handler get_unexpected() noexcept; +#endif + + /** The runtime will call this function if an %exception is thrown which + * violates the function's %exception specification. + * + * @deprecated Removed from the C++ standard in C++17 + */ + _GLIBCXX11_DEPRECATED + void unexpected() __attribute__ ((__noreturn__)); +#endif + + /** [18.6.4]/1: 'Returns true after completing evaluation of a + * throw-expression until either completing initialization of the + * exception-declaration in the matching handler or entering `unexpected()` + * due to the throw; or after entering `terminate()` for any reason + * other than an explicit call to `terminate()`. [Note: This includes + * stack unwinding [15.2]. end note]' + * + * 2: 'When `uncaught_exception()` is true, throwing an + * %exception can result in a call of 1terminate()` + * (15.5.1).' + */ + _GLIBCXX17_DEPRECATED_SUGGEST("std::uncaught_exceptions()") + bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); + +#if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++98 +#define __cpp_lib_uncaught_exceptions 201411L + /** The number of uncaught exceptions. + * @since C++17, or any non-strict mode, e.g. `-std=gnu++98` + * @see uncaught_exception() + */ + int uncaught_exceptions() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); +#endif + + /// @} group exceptions +} // namespace std + +namespace __gnu_cxx +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A replacement for the standard terminate_handler which + * prints more information about the terminating exception (if any) + * on stderr. + * + * @ingroup exceptions + * + * Call + * @code + * std::set_terminate(__gnu_cxx::__verbose_terminate_handler) + * @endcode + * to use. For more info, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch06s02.html + * + * In 3.4 and later, this is on by default. + */ + void __verbose_terminate_handler(); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +} // extern "C++" + +#pragma GCC visibility pop + +#if (__cplusplus >= 201103L) +#include +#include +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception.blob new file mode 100644 index 0000000000000000000000000000000000000000..edbed79dedb485932213dd0e7fc11259c5e9e604 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@exception.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..1ce17517b9bfdd68f6b90a666d77748350277697 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h @@ -0,0 +1,125 @@ +// Aligned memory buffer -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/aligned_buffer.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _ALIGNED_BUFFER_H +#define _ALIGNED_BUFFER_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +# include +#else +# include +#endif + +namespace __gnu_cxx +{ + // A utility type containing a POD object that can hold an object of type + // _Tp initialized via placement new or allocator_traits::construct. + // Intended for use as a data member subobject, use __aligned_buffer for + // complete objects. + template + struct __aligned_membuf + { + // Target macro ADJUST_FIELD_ALIGN can produce different alignment for + // types when used as class members. __aligned_membuf is intended + // for use as a class member, so align the buffer as for a class member. + // Since GCC 8 we could just use alignof(_Tp) instead, but older + // versions of non-GNU compilers might still need this trick. + struct _Tp2 { _Tp _M_t; }; + + alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)]; + + __aligned_membuf() = default; + + // Can be used to avoid value-initialization zeroing _M_storage. + __aligned_membuf(std::nullptr_t) { } + + void* + _M_addr() noexcept + { return static_cast(&_M_storage); } + + const void* + _M_addr() const noexcept + { return static_cast(&_M_storage); } + + _Tp* + _M_ptr() noexcept + { return static_cast<_Tp*>(_M_addr()); } + + const _Tp* + _M_ptr() const noexcept + { return static_cast(_M_addr()); } + }; + +#if _GLIBCXX_INLINE_VERSION + template + using __aligned_buffer = __aligned_membuf<_Tp>; +#else + // Similar to __aligned_membuf but aligned for complete objects, not members. + // This type is used in , , + // and , but ideally they would use __aligned_membuf + // instead, as it has smaller size for some types on some targets. + // This type is still used to avoid an ABI change. + template + struct __aligned_buffer + : std::aligned_storage + { + typename + std::aligned_storage::type _M_storage; + + __aligned_buffer() = default; + + // Can be used to avoid value-initialization + __aligned_buffer(std::nullptr_t) { } + + void* + _M_addr() noexcept + { + return static_cast(&_M_storage); + } + + const void* + _M_addr() const noexcept + { + return static_cast(&_M_storage); + } + + _Tp* + _M_ptr() noexcept + { return static_cast<_Tp*>(_M_addr()); } + + const _Tp* + _M_ptr() const noexcept + { return static_cast(_M_addr()); } + }; +#endif + +} // namespace + +#endif /* _ALIGNED_BUFFER_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6bad00c73792d010d4b545a5ae5fad7564996e7a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@aligned_buffer.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..1d7d9598cb2fa6fdcf5b32184e6f6f91b66a30cc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h @@ -0,0 +1,171 @@ +// Allocator traits -*- C++ -*- + +// Copyright (C) 2011-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/alloc_traits.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _EXT_ALLOC_TRAITS_H +#define _EXT_ALLOC_TRAITS_H 1 + +#pragma GCC system_header + +# include +#if __cplusplus < 201103L +# include // for __alloc_swap +#endif + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @brief Uniform interface to C++98 and C++11 allocators. + * @ingroup allocators +*/ +template + struct __alloc_traits +#if __cplusplus >= 201103L + : std::allocator_traits<_Alloc> +#endif + { + typedef _Alloc allocator_type; +#if __cplusplus >= 201103L + typedef std::allocator_traits<_Alloc> _Base_type; + typedef typename _Base_type::value_type value_type; + typedef typename _Base_type::pointer pointer; + typedef typename _Base_type::const_pointer const_pointer; + typedef typename _Base_type::size_type size_type; + typedef typename _Base_type::difference_type difference_type; + // C++11 allocators do not define reference or const_reference + typedef value_type& reference; + typedef const value_type& const_reference; + using _Base_type::allocate; + using _Base_type::deallocate; + using _Base_type::construct; + using _Base_type::destroy; + using _Base_type::max_size; + + private: + template + using __is_custom_pointer + = std::__and_, + std::__not_>>; + + public: + // overload construct for non-standard pointer types + template + static _GLIBCXX14_CONSTEXPR + std::__enable_if_t<__is_custom_pointer<_Ptr>::value> + construct(_Alloc& __a, _Ptr __p, _Args&&... __args) + noexcept(noexcept(_Base_type::construct(__a, std::__to_address(__p), + std::forward<_Args>(__args)...))) + { + _Base_type::construct(__a, std::__to_address(__p), + std::forward<_Args>(__args)...); + } + + // overload destroy for non-standard pointer types + template + static _GLIBCXX14_CONSTEXPR + std::__enable_if_t<__is_custom_pointer<_Ptr>::value> + destroy(_Alloc& __a, _Ptr __p) + noexcept(noexcept(_Base_type::destroy(__a, std::__to_address(__p)))) + { _Base_type::destroy(__a, std::__to_address(__p)); } + + static constexpr _Alloc _S_select_on_copy(const _Alloc& __a) + { return _Base_type::select_on_container_copy_construction(__a); } + + static _GLIBCXX14_CONSTEXPR void _S_on_swap(_Alloc& __a, _Alloc& __b) + { std::__alloc_on_swap(__a, __b); } + + static constexpr bool _S_propagate_on_copy_assign() + { return _Base_type::propagate_on_container_copy_assignment::value; } + + static constexpr bool _S_propagate_on_move_assign() + { return _Base_type::propagate_on_container_move_assignment::value; } + + static constexpr bool _S_propagate_on_swap() + { return _Base_type::propagate_on_container_swap::value; } + + static constexpr bool _S_always_equal() + { return _Base_type::is_always_equal::value; } + + static constexpr bool _S_nothrow_move() + { return _S_propagate_on_move_assign() || _S_always_equal(); } + + template + struct rebind + { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; +#else // ! C++11 + + typedef typename _Alloc::pointer pointer; + typedef typename _Alloc::const_pointer const_pointer; + typedef typename _Alloc::value_type value_type; + typedef typename _Alloc::reference reference; + typedef typename _Alloc::const_reference const_reference; + typedef typename _Alloc::size_type size_type; + typedef typename _Alloc::difference_type difference_type; + + _GLIBCXX_NODISCARD static pointer + allocate(_Alloc& __a, size_type __n) + { return __a.allocate(__n); } + + template + _GLIBCXX_NODISCARD static pointer + allocate(_Alloc& __a, size_type __n, _Hint __hint) + { return __a.allocate(__n, __hint); } + + static void deallocate(_Alloc& __a, pointer __p, size_type __n) + { __a.deallocate(__p, __n); } + + template + static void construct(_Alloc& __a, pointer __p, const _Tp& __arg) + { __a.construct(__p, __arg); } + + static void destroy(_Alloc& __a, pointer __p) + { __a.destroy(__p); } + + static size_type max_size(const _Alloc& __a) + { return __a.max_size(); } + + static const _Alloc& _S_select_on_copy(const _Alloc& __a) { return __a; } + + static void _S_on_swap(_Alloc& __a, _Alloc& __b) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Alloc>::_S_do_it(__a, __b); + } + + template + struct rebind + { typedef typename _Alloc::template rebind<_Tp>::other other; }; +#endif // C++11 + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace __gnu_cxx + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8f6721e988c7dab0281277b2a01870c39f39e4e9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@alloc_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h new file mode 100644 index 0000000000000000000000000000000000000000..de008c2cec0bff37dd41a000407bdbd2258ee844 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h @@ -0,0 +1,127 @@ +// Support for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/atomicity.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_ATOMICITY_H +#define _GLIBCXX_ATOMICITY_H 1 + +#pragma GCC system_header + +#include +#include +#include +#if __has_include() +# include +#endif + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + __attribute__((__always_inline__)) + inline bool + __is_single_threaded() _GLIBCXX_NOTHROW + { +#ifndef __GTHREADS + return true; +#elif __has_include() + return ::__libc_single_threaded; +#else + return !__gthread_active_p(); +#endif + } + + // Functions for portable atomic access. + // To abstract locking primitives across all thread policies, use: + // __exchange_and_add_dispatch + // __atomic_add_dispatch +#ifdef _GLIBCXX_ATOMIC_BUILTINS + inline _Atomic_word + __attribute__((__always_inline__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } + + inline void + __attribute__((__always_inline__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } +#else + _Atomic_word + __exchange_and_add(volatile _Atomic_word*, int) _GLIBCXX_NOTHROW; + + void + __atomic_add(volatile _Atomic_word*, int) _GLIBCXX_NOTHROW; +#endif + + inline _Atomic_word + __attribute__((__always_inline__)) + __exchange_and_add_single(_Atomic_word* __mem, int __val) + { + _Atomic_word __result = *__mem; + *__mem += __val; + return __result; + } + + inline void + __attribute__((__always_inline__)) + __atomic_add_single(_Atomic_word* __mem, int __val) + { *__mem += __val; } + + inline _Atomic_word + __attribute__ ((__always_inline__)) + __exchange_and_add_dispatch(_Atomic_word* __mem, int __val) + { + if (__is_single_threaded()) + return __exchange_and_add_single(__mem, __val); + else + return __exchange_and_add(__mem, __val); + } + + inline void + __attribute__ ((__always_inline__)) + __atomic_add_dispatch(_Atomic_word* __mem, int __val) + { + if (__is_single_threaded()) + __atomic_add_single(__mem, __val); + else + __atomic_add(__mem, __val); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// Even if the CPU doesn't need a memory barrier, we need to ensure +// that the compiler doesn't reorder memory accesses across the +// barriers. +#ifndef _GLIBCXX_READ_MEM_BARRIER +#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) +#endif +#ifndef _GLIBCXX_WRITE_MEM_BARRIER +#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE) +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..4b5c61193900c647f14ffd095e943708d3e1ac78 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@atomicity.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h new file mode 100644 index 0000000000000000000000000000000000000000..aea861b534f14c0b3556c5cf40a26d3e3c2de109 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h @@ -0,0 +1,315 @@ +// Support for concurrent programing -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/concurrence.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _CONCURRENCE_H +#define _CONCURRENCE_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Available locking policies: + // _S_single single-threaded code that doesn't need to be locked. + // _S_mutex multi-threaded code that requires additional support + // from gthr.h or abstraction layers in concurrence.h. + // _S_atomic multi-threaded code using atomic operations. + enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; + + // Compile time constant that indicates prefered locking policy in + // the current configuration. + static const _Lock_policy __default_lock_policy = +#ifndef __GTHREADS + _S_single; +#elif defined _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY + _S_atomic; +#else + _S_mutex; +#endif + + // NB: As this is used in libsupc++, need to only depend on + // exception. No stdexception classes, no use of std::string. + class __concurrence_lock_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_lock_error"; } + }; + + class __concurrence_unlock_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_unlock_error"; } + }; + + class __concurrence_broadcast_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_broadcast_error"; } + }; + + class __concurrence_wait_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_wait_error"; } + }; + + // Substitute for concurrence_error object in the case of -fno-exceptions. + inline void + __throw_concurrence_lock_error() + { _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); } + + inline void + __throw_concurrence_unlock_error() + { _GLIBCXX_THROW_OR_ABORT(__concurrence_unlock_error()); } + +#ifdef __GTHREAD_HAS_COND + inline void + __throw_concurrence_broadcast_error() + { _GLIBCXX_THROW_OR_ABORT(__concurrence_broadcast_error()); } + + inline void + __throw_concurrence_wait_error() + { _GLIBCXX_THROW_OR_ABORT(__concurrence_wait_error()); } +#endif + + class __mutex + { + private: +#if __GTHREADS && defined __GTHREAD_MUTEX_INIT + __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT; +#else + __gthread_mutex_t _M_mutex; +#endif + + __mutex(const __mutex&); + __mutex& operator=(const __mutex&); + + public: + __mutex() + { +#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT + if (__gthread_active_p()) + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + +#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT + ~__mutex() + { + if (__gthread_active_p()) + __gthread_mutex_destroy(&_M_mutex); + } +#endif + + void lock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_mutex_lock(&_M_mutex) != 0) + __throw_concurrence_lock_error(); + } +#endif + } + + void unlock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_mutex_unlock(&_M_mutex) != 0) + __throw_concurrence_unlock_error(); + } +#endif + } + + __gthread_mutex_t* gthread_mutex(void) + { return &_M_mutex; } + }; + + class __recursive_mutex + { + private: +#if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT + __gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT; +#else + __gthread_recursive_mutex_t _M_mutex; +#endif + + __recursive_mutex(const __recursive_mutex&); + __recursive_mutex& operator=(const __recursive_mutex&); + + public: + __recursive_mutex() + { +#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT + if (__gthread_active_p()) + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } + +#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT + ~__recursive_mutex() + { + if (__gthread_active_p()) + __gthread_recursive_mutex_destroy(&_M_mutex); + } +#endif + + void lock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_recursive_mutex_lock(&_M_mutex) != 0) + __throw_concurrence_lock_error(); + } +#endif + } + + void unlock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0) + __throw_concurrence_unlock_error(); + } +#endif + } + + __gthread_recursive_mutex_t* gthread_recursive_mutex(void) + { return &_M_mutex; } + }; + + /// Scoped lock idiom. + // Acquire the mutex here with a constructor call, then release with + // the destructor call in accordance with RAII style. + class __scoped_lock + { + public: + typedef __mutex __mutex_type; + + private: + __mutex_type& _M_device; + + __scoped_lock(const __scoped_lock&); + __scoped_lock& operator=(const __scoped_lock&); + + public: + explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) + { _M_device.lock(); } + + ~__scoped_lock() throw() + { _M_device.unlock(); } + }; + +#ifdef __GTHREAD_HAS_COND + class __cond + { + private: +#if __GTHREADS && defined __GTHREAD_COND_INIT + __gthread_cond_t _M_cond = __GTHREAD_COND_INIT; +#else + __gthread_cond_t _M_cond; +#endif + + __cond(const __cond&); + __cond& operator=(const __cond&); + + public: + __cond() + { +#if __GTHREADS && ! defined __GTHREAD_COND_INIT + if (__gthread_active_p()) + __GTHREAD_COND_INIT_FUNCTION(&_M_cond); +#endif + } + +#if __GTHREADS && ! defined __GTHREAD_COND_INIT + ~__cond() + { + if (__gthread_active_p()) + __gthread_cond_destroy(&_M_cond); + } +#endif + + void broadcast() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_cond_broadcast(&_M_cond) != 0) + __throw_concurrence_broadcast_error(); + } +#endif + } + + void wait(__mutex *mutex) + { +#if __GTHREADS + { + if (__gthread_cond_wait(&_M_cond, mutex->gthread_mutex()) != 0) + __throw_concurrence_wait_error(); + } +#endif + } + + void wait_recursive(__recursive_mutex *mutex) + { +#if __GTHREADS + { + if (__gthread_cond_wait_recursive(&_M_cond, + mutex->gthread_recursive_mutex()) + != 0) + __throw_concurrence_wait_error(); + } +#endif + } + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f73ab107d98ba6b1571cea3b0e156c13b9fca42e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@concurrence.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..87e20cc804bd59c15af48b3bb7c0d97e6a94c97e --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h @@ -0,0 +1,241 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software +// Foundation; either version 3, or (at your option) any later +// version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/numeric_traits.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _EXT_NUMERIC_TRAITS +#define _EXT_NUMERIC_TRAITS 1 + +#pragma GCC system_header + +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Compile time constants for builtin types. + // In C++98 std::numeric_limits member functions are not constant expressions + // (that changed in C++11 with the addition of 'constexpr'). + // Even for C++11, this header is smaller than and can be used + // when only is_signed, digits, min, or max values are needed for integers, + // or is_signed, digits10, max_digits10, or max_exponent10 for floats. + + // Unlike __is_integer (and std::is_integral) this trait is true for + // non-standard built-in integer types such as __int128 and __int20. + template + struct __is_integer_nonstrict + : public std::__is_integer<_Tp> + { + using std::__is_integer<_Tp>::__value; + + // The number of bits in the value representation. + enum { __width = __value ? sizeof(_Tp) * __CHAR_BIT__ : 0 }; + }; + + template + struct __numeric_traits_integer + { +#if __cplusplus >= 201103L + static_assert(__is_integer_nonstrict<_Value>::__value, + "invalid specialization"); +#endif + + // NB: these two are also available in std::numeric_limits as compile + // time constants, but is big and we can avoid including it. + static const bool __is_signed = (_Value)(-1) < 0; + static const int __digits + = __is_integer_nonstrict<_Value>::__width - __is_signed; + + // The initializers must be constants so that __max and __min are too. + static const _Value __max = __is_signed + ? (((((_Value)1 << (__digits - 1)) - 1) << 1) + 1) + : ~(_Value)0; + static const _Value __min = __is_signed ? -__max - 1 : (_Value)0; + }; + + template + const _Value __numeric_traits_integer<_Value>::__min; + + template + const _Value __numeric_traits_integer<_Value>::__max; + + template + const bool __numeric_traits_integer<_Value>::__is_signed; + + template + const int __numeric_traits_integer<_Value>::__digits; + + // Enable __numeric_traits_integer for types where the __is_integer_nonstrict + // primary template doesn't give the right answer. +#define _GLIBCXX_INT_N_TRAITS(T, WIDTH) \ + __extension__ \ + template<> struct __is_integer_nonstrict \ + { \ + enum { __value = 1 }; \ + typedef std::__true_type __type; \ + enum { __width = WIDTH }; \ + }; \ + __extension__ \ + template<> struct __is_integer_nonstrict \ + { \ + enum { __value = 1 }; \ + typedef std::__true_type __type; \ + enum { __width = WIDTH }; \ + }; + + // We need to specify the width for some __intNN types because they + // have padding bits, e.g. the object representation of __int20 has 32 bits, + // but its width (number of bits in the value representation) is only 20. +#if defined __GLIBCXX_TYPE_INT_N_0 && __GLIBCXX_BITSIZE_INT_N_0 % __CHAR_BIT__ + _GLIBCXX_INT_N_TRAITS(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0) +#endif +#if defined __GLIBCXX_TYPE_INT_N_1 && __GLIBCXX_BITSIZE_INT_N_1 % __CHAR_BIT__ + _GLIBCXX_INT_N_TRAITS(__GLIBCXX_TYPE_INT_N_1, __GLIBCXX_BITSIZE_INT_N_1) +#endif +#if defined __GLIBCXX_TYPE_INT_N_2 && __GLIBCXX_BITSIZE_INT_N_2 % __CHAR_BIT__ + _GLIBCXX_INT_N_TRAITS(__GLIBCXX_TYPE_INT_N_2, __GLIBCXX_BITSIZE_INT_N_2) +#endif +#if defined __GLIBCXX_TYPE_INT_N_3 && __GLIBCXX_BITSIZE_INT_N_3 % __CHAR_BIT__ + _GLIBCXX_INT_N_TRAITS(__GLIBCXX_TYPE_INT_N_3, __GLIBCXX_BITSIZE_INT_N_3) +#endif + +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + // In strict modes __is_integer<__int128> is false, + // but we still want to define __numeric_traits_integer<__int128>. + _GLIBCXX_INT_N_TRAITS(__int128, 128) +#endif + +#undef _GLIBCXX_INT_N_TRAITS + +#if __cplusplus >= 201103L + /// Convenience alias for __numeric_traits. + template + using __int_traits = __numeric_traits_integer<_Tp>; +#endif + +#define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \ + (std::__are_same<_Tp, float>::__value ? _Fval \ + : std::__are_same<_Tp, double>::__value ? _Dval : _LDval) + +#define __glibcxx_max_digits10(_Tp) \ + (2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \ + __LDBL_MANT_DIG__) * 643L / 2136) + +#define __glibcxx_digits10(_Tp) \ + __glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__) + +#define __glibcxx_max_exponent10(_Tp) \ + __glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \ + __LDBL_MAX_10_EXP__) + + // N.B. this only supports float, double and long double (no __float128 etc.) + template + struct __numeric_traits_floating + { + // Only floating point types. See N1822. + static const int __max_digits10 = __glibcxx_max_digits10(_Value); + + // See above comment... + static const bool __is_signed = true; + static const int __digits10 = __glibcxx_digits10(_Value); + static const int __max_exponent10 = __glibcxx_max_exponent10(_Value); + }; + + template + const int __numeric_traits_floating<_Value>::__max_digits10; + + template + const bool __numeric_traits_floating<_Value>::__is_signed; + + template + const int __numeric_traits_floating<_Value>::__digits10; + + template + const int __numeric_traits_floating<_Value>::__max_exponent10; + +#undef __glibcxx_floating +#undef __glibcxx_max_digits10 +#undef __glibcxx_digits10 +#undef __glibcxx_max_exponent10 + + template + struct __numeric_traits + : public __numeric_traits_integer<_Value> + { }; + + template<> + struct __numeric_traits + : public __numeric_traits_floating + { }; + + template<> + struct __numeric_traits + : public __numeric_traits_floating + { }; + + template<> + struct __numeric_traits + : public __numeric_traits_floating + { }; + +#ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT +# if defined __LONG_DOUBLE_IEEE128__ + // long double is __ieee128, define traits for __ibm128 + template<> + struct __numeric_traits_floating<__ibm128> + { + static const int __max_digits10 = 33; + static const bool __is_signed = true; + static const int __digits10 = 31; + static const int __max_exponent10 = 308; + }; + template<> + struct __numeric_traits<__ibm128> + : public __numeric_traits_floating<__ibm128> + { }; +# elif defined __LONG_DOUBLE_IBM128__ + // long double is __ibm128, define traits for __ieee128 + template<> + struct __numeric_traits_floating<__ieee128> + { + static const int __max_digits10 = 36; + static const bool __is_signed = true; + static const int __digits10 = 33; + static const int __max_exponent10 = 4932; + }; + template<> + struct __numeric_traits<__ieee128> + : public __numeric_traits_floating<__ieee128> + { }; +# endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..58a93f2387b3681db1ad8d41e63a8a3622d59852 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@numeric_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..fc03974b5a0935f268d99e0e1355f1719e3a7291 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h @@ -0,0 +1,123 @@ +// String Conversions -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/string_conversions.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _STRING_CONVERSIONS_H +#define _STRING_CONVERSIONS_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Helper for all the sto* functions. + template + _Ret + __stoa(_TRet (*__convf) (const _CharT*, _CharT**, _Base...), + const char* __name, const _CharT* __str, std::size_t* __idx, + _Base... __base) + { + _Ret __ret; + + _CharT* __endptr; + + struct _Save_errno { + _Save_errno() : _M_errno(errno) { errno = 0; } + ~_Save_errno() { if (errno == 0) errno = _M_errno; } + int _M_errno; + } const __save_errno; + + struct _Range_chk { + static bool + _S_chk(_TRet, std::false_type) { return false; } + + static bool + _S_chk(_TRet __val, std::true_type) // only called when _Ret is int + { + return __val < _TRet(__numeric_traits::__min) + || __val > _TRet(__numeric_traits::__max); + } + }; + + const _TRet __tmp = __convf(__str, &__endptr, __base...); + + if (__endptr == __str) + std::__throw_invalid_argument(__name); + else if (errno == ERANGE + || _Range_chk::_S_chk(__tmp, std::is_same<_Ret, int>{})) + std::__throw_out_of_range(__name); + else + __ret = __tmp; + + if (__idx) + *__idx = __endptr - __str; + + return __ret; + } + + // Helper for the to_string / to_wstring functions. + template + _String + __to_xstring(int (*__convf) (_CharT*, std::size_t, const _CharT*, + __builtin_va_list), std::size_t __n, + const _CharT* __fmt, ...) + { + // XXX Eventually the result should be constructed in-place in + // the __cxx11 string, likely with the help of internal hooks. + _CharT* __s = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __n)); + + __builtin_va_list __args; + __builtin_va_start(__args, __fmt); + + const int __len = __convf(__s, __n, __fmt, __args); + + __builtin_va_end(__args); + + return _String(__s, __s + __len); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _STRING_CONVERSIONS_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..7520137fd7039b6e2463a86a5ab74ec1fe6eb41a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@string_conversions.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..27fae8234363ecc50f955dca4843d9e06b6379ba --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h @@ -0,0 +1,243 @@ +// -*- C++ -*- + +// Copyright (C) 2005-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software +// Foundation; either version 3, or (at your option) any later +// version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/type_traits.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _EXT_TYPE_TRAITS +#define _EXT_TYPE_TRAITS 1 + +#pragma GCC system_header + +#include +#include + +extern "C++" { + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Define a nested type if some predicate holds. + template + struct __enable_if + { }; + + template + struct __enable_if + { typedef _Tp __type; }; + + + // Conditional expression for types. If true, first, if false, second. + template + struct __conditional_type + { typedef _Iftrue __type; }; + + template + struct __conditional_type + { typedef _Iffalse __type; }; + + + // Given an integral builtin type, return the corresponding unsigned type. + template + struct __add_unsigned + { + private: + typedef __enable_if::__value, _Tp> __if_type; + + public: + typedef typename __if_type::__type __type; + }; + + template<> + struct __add_unsigned + { typedef unsigned char __type; }; + + template<> + struct __add_unsigned + { typedef unsigned char __type; }; + + template<> + struct __add_unsigned + { typedef unsigned short __type; }; + + template<> + struct __add_unsigned + { typedef unsigned int __type; }; + + template<> + struct __add_unsigned + { typedef unsigned long __type; }; + + template<> + struct __add_unsigned + { typedef unsigned long long __type; }; + + // Declare but don't define. + template<> + struct __add_unsigned; + + template<> + struct __add_unsigned; + + + // Given an integral builtin type, return the corresponding signed type. + template + struct __remove_unsigned + { + private: + typedef __enable_if::__value, _Tp> __if_type; + + public: + typedef typename __if_type::__type __type; + }; + + template<> + struct __remove_unsigned + { typedef signed char __type; }; + + template<> + struct __remove_unsigned + { typedef signed char __type; }; + + template<> + struct __remove_unsigned + { typedef short __type; }; + + template<> + struct __remove_unsigned + { typedef int __type; }; + + template<> + struct __remove_unsigned + { typedef long __type; }; + + template<> + struct __remove_unsigned + { typedef long long __type; }; + + // Declare but don't define. + template<> + struct __remove_unsigned; + + template<> + struct __remove_unsigned; + + + // For use in string and vstring. + template + _GLIBCXX_CONSTEXPR + inline bool + __is_null_pointer(_Type* __ptr) + { return __ptr == 0; } + + template + _GLIBCXX_CONSTEXPR + inline bool + __is_null_pointer(_Type) + { return false; } + +#if __cplusplus >= 201103L + constexpr bool + __is_null_pointer(std::nullptr_t) + { return true; } +#endif + + // For arithmetic promotions in and + + template::__value> + struct __promote + { typedef double __type; }; + + // No nested __type member for non-integer non-floating point types, + // allows this type to be used for SFINAE to constrain overloads in + // and to only the intended types. + template + struct __promote<_Tp, false> + { }; + + template<> + struct __promote + { typedef long double __type; }; + + template<> + struct __promote + { typedef double __type; }; + + template<> + struct __promote + { typedef float __type; }; + +#if __cpp_fold_expressions + + template + using __promoted_t = decltype((typename __promote<_Tp>::__type(0) + ...)); + + // Deducing the promoted type is done by __promoted_t<_Tp...>, + // then __promote is used to provide the nested __type member. + template + using __promote_2 = __promote<__promoted_t<_Tp, _Up>>; + + template + using __promote_3 = __promote<__promoted_t<_Tp, _Up, _Vp>>; + + template + using __promote_4 = __promote<__promoted_t<_Tp, _Up, _Vp, _Wp>>; + +#else + + template::__type, + typename _Up2 = typename __promote<_Up>::__type> + struct __promote_2 + { + typedef __typeof__(_Tp2() + _Up2()) __type; + }; + + template::__type, + typename _Up2 = typename __promote<_Up>::__type, + typename _Vp2 = typename __promote<_Vp>::__type> + struct __promote_3 + { + typedef __typeof__(_Tp2() + _Up2() + _Vp2()) __type; + }; + + template::__type, + typename _Up2 = typename __promote<_Up>::__type, + typename _Vp2 = typename __promote<_Vp>::__type, + typename _Wp2 = typename __promote<_Wp>::__type> + struct __promote_4 + { + typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type; + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..ee9af496acafae9991326e6ef0410fd144301813 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ext@type_traits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h new file mode 100644 index 0000000000000000000000000000000000000000..b841599b7d4afebff2fb523a91403bbd596c2fec --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h @@ -0,0 +1,81 @@ +// -*- C++ -*- compatibility header. + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file fenv.h + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FENV_H +#define _GLIBCXX_FENV_H 1 + +#pragma GCC system_header + +#include +#if _GLIBCXX_HAVE_FENV_H +# include_next +#endif + +#if __cplusplus >= 201103L + +#if _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +namespace std +{ + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; +} // namespace + +#endif // _GLIBCXX_USE_C99_FENV_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_FENV_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..9a19def7942809eeb97560d6372f51b7bd654d5b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fenv.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list new file mode 100644 index 0000000000000000000000000000000000000000..21d617b00e9ae96c2eccf16a2b44e4a9b854b50a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list @@ -0,0 +1,87 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/forward_list + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FORWARD_LIST +#define _GLIBCXX_FORWARD_LIST 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template + using forward_list = std::forward_list<_Tp, polymorphic_allocator<_Tp>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + inline typename forward_list<_Tp, _Alloc>::size_type + erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred) + { return __cont.remove_if(__pred); } + + template + inline typename forward_list<_Tp, _Alloc>::size_type + erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value) + { + using __elem_type = typename forward_list<_Tp, _Alloc>::value_type; + return std::erase_if(__cont, [&](__elem_type& __elem) { + return __elem == __value; + }); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif // C++11 + +#endif // _GLIBCXX_FORWARD_LIST diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list.blob new file mode 100644 index 0000000000000000000000000000000000000000..5325ccc607da2e7ac1b9359983ae98b0d9e3ad6b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@forward_list.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream new file mode 100644 index 0000000000000000000000000000000000000000..e62a1ade3c20d5c18eb567df222b21546580a1c0 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream @@ -0,0 +1,1300 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/fstream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.8 File-based streams +// + +#ifndef _GLIBCXX_FSTREAM +#define _GLIBCXX_FSTREAM 1 + +#pragma GCC system_header + +#include +#include +#include +#include // For BUFSIZ +#include // For __basic_file, __c_lock +#if __cplusplus >= 201103L +#include // For std::string overloads. +#endif + +// This can be overridden by the target's os_defines.h +#ifndef _GLIBCXX_BUFSIZ +# define _GLIBCXX_BUFSIZ BUFSIZ +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + // Enable if _Path is a filesystem::path or experimental::filesystem::path + template().make_preferred().filename())> + using _If_fs_path = enable_if_t, _Result>; +#endif // C++17 + + + // [27.8.1.1] template class basic_filebuf + /** + * @brief The actual work of input and output (for files). + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This class associates both its input and output sequence with an + * external disk file, and maintains a joint file position for both + * sequences. Many of its semantics are described in terms of similar + * behavior in the Standard C Library's @c FILE streams. + * + * Requirements on traits_type, specific to this class: + * - traits_type::pos_type must be fpos + * - traits_type::off_type must be streamoff + * - traits_type::state_type must be Assignable and DefaultConstructible, + * - traits_type::state_type() must be the initial state for codecvt. + */ + template + class basic_filebuf : public basic_streambuf<_CharT, _Traits> + { +#if __cplusplus >= 201103L + template + using __chk_state = __and_, + is_copy_constructible<_Tp>, + is_default_constructible<_Tp>>; + + static_assert(__chk_state::value, + "state_type must be CopyAssignable, CopyConstructible" + " and DefaultConstructible"); + + static_assert(is_same>::value, + "pos_type must be fpos"); +#endif + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + typedef basic_streambuf __streambuf_type; + typedef basic_filebuf __filebuf_type; + typedef __basic_file __file_type; + typedef typename traits_type::state_type __state_type; + typedef codecvt __codecvt_type; + + friend class ios_base; // For sync_with_stdio. + + protected: + // Data Members: + // MT lock inherited from libio or other low-level io library. + __c_lock _M_lock; + + // External buffer. + __file_type _M_file; + + /// Place to stash in || out || in | out settings for current filebuf. + ios_base::openmode _M_mode; + + // Beginning state type for codecvt. + __state_type _M_state_beg; + + // During output, the state that corresponds to pptr(), + // during input, the state that corresponds to egptr() and + // _M_ext_next. + __state_type _M_state_cur; + + // Not used for output. During input, the state that corresponds + // to eback() and _M_ext_buf. + __state_type _M_state_last; + + /// Pointer to the beginning of internal buffer. + char_type* _M_buf; + + /** + * Actual size of internal buffer. This number is equal to the size + * of the put area + 1 position, reserved for the overflow char of + * a full area. + */ + size_t _M_buf_size; + + // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. + bool _M_buf_allocated; + + /** + * _M_reading == false && _M_writing == false for @b uncommitted mode; + * _M_reading == true for @b read mode; + * _M_writing == true for @b write mode; + * + * NB: _M_reading == true && _M_writing == true is unused. + */ + bool _M_reading; + bool _M_writing; + + ///@{ + /** + * Necessary bits for putback buffer management. + * + * @note pbacks of over one character are not currently supported. + */ + char_type _M_pback; + char_type* _M_pback_cur_save; + char_type* _M_pback_end_save; + bool _M_pback_init; + ///@} + + // Cached codecvt facet. + const __codecvt_type* _M_codecvt; + + /** + * Buffer for external characters. Used for input when + * codecvt::always_noconv() == false. When valid, this corresponds + * to eback(). + */ + char* _M_ext_buf; + + /** + * Size of buffer held by _M_ext_buf. + */ + streamsize _M_ext_buf_size; + + /** + * Pointers into the buffer held by _M_ext_buf that delimit a + * subsequence of bytes that have been read but not yet converted. + * When valid, _M_ext_next corresponds to egptr(). + */ + const char* _M_ext_next; + char* _M_ext_end; + + /** + * Initializes pback buffers, and moves normal buffers to safety. + * Assumptions: + * _M_in_cur has already been moved back + */ + void + _M_create_pback() + { + if (!_M_pback_init) + { + _M_pback_cur_save = this->gptr(); + _M_pback_end_save = this->egptr(); + this->setg(&_M_pback, &_M_pback, &_M_pback + 1); + _M_pback_init = true; + } + } + + /** + * Deactivates pback buffer contents, and restores normal buffer. + * Assumptions: + * The pback buffer has only moved forward. + */ + void + _M_destroy_pback() throw() + { + if (_M_pback_init) + { + // Length _M_in_cur moved in the pback buffer. + _M_pback_cur_save += this->gptr() != this->eback(); + this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save); + _M_pback_init = false; + } + } + + public: + // Constructors/destructor: + /** + * @brief Does not open any files. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ + basic_filebuf(); + +#if __cplusplus >= 201103L + basic_filebuf(const basic_filebuf&) = delete; + basic_filebuf(basic_filebuf&&); +#endif + + /** + * @brief The destructor closes the file first. + */ + virtual + ~basic_filebuf() + { + __try + { this->close(); } + __catch(...) + { } + } + +#if __cplusplus >= 201103L + basic_filebuf& operator=(const basic_filebuf&) = delete; + basic_filebuf& operator=(basic_filebuf&&); + void swap(basic_filebuf&); +#endif + + // Members: + /** + * @brief Returns true if the external file is open. + */ + bool + is_open() const throw() + { return _M_file.is_open(); } + + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * @return @c this on success, NULL on failure + * + * If a file is already open, this function immediately fails. + * Otherwise it tries to open the file named @a __s using the flags + * given in @a __mode. + * + * Table 92, adapted here, gives the relation between openmode + * combinations and the equivalent @c fopen() flags. + * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, + * and binary|in|app per DR 596) + *

+       *  +---------------------------------------------------------+
+       *  | ios_base Flag combination            stdio equivalent   |
+       *  |binary  in  out  trunc  app                              |
+       *  +---------------------------------------------------------+
+       *  |             +                        w                  |
+       *  |             +           +            a                  |
+       *  |                         +            a                  |
+       *  |             +     +                  w                  |
+       *  |         +                            r                  |
+       *  |         +   +                        r+                 |
+       *  |         +   +     +                  w+                 |
+       *  |         +   +           +            a+                 |
+       *  |         +               +            a+                 |
+       *  +---------------------------------------------------------+
+       *  |   +         +                        wb                 |
+       *  |   +         +           +            ab                 |
+       *  |   +                     +            ab                 |
+       *  |   +         +     +                  wb                 |
+       *  |   +     +                            rb                 |
+       *  |   +     +   +                        r+b                |
+       *  |   +     +   +     +                  w+b                |
+       *  |   +     +   +           +            a+b                |
+       *  |   +     +               +            a+b                |
+       *  +---------------------------------------------------------+
+       *  
+ */ + __filebuf_type* + open(const char* __s, ios_base::openmode __mode); + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @brief Opens an external file. + * @param __s The name of the file, as a wide character string. + * @param __mode The open mode flags. + * @return @c this on success, NULL on failure + */ + __filebuf_type* + open(const wchar_t* __s, ios_base::openmode __mode); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * @return @c this on success, NULL on failure + */ + __filebuf_type* + open(const std::string& __s, ios_base::openmode __mode) + { return open(__s.c_str(), __mode); } + +#if __cplusplus >= 201703L + /** + * @brief Opens an external file. + * @param __s The name of the file, as a filesystem::path. + * @param __mode The open mode flags. + * @return @c this on success, NULL on failure + */ + template + _If_fs_path<_Path, __filebuf_type*> + open(const _Path& __s, ios_base::openmode __mode) + { return open(__s.c_str(), __mode); } +#endif // C++17 +#endif // C++11 + + /** + * @brief Closes the currently associated file. + * @return @c this on success, NULL on failure + * + * If no file is currently open, this function immediately fails. + * + * If a put buffer area exists, @c overflow(eof) is + * called to flush all the characters. The file is then + * closed. + * + * If any operations fail, this function also fails. + */ + __filebuf_type* + close(); + + protected: + void + _M_allocate_internal_buffer(); + + void + _M_destroy_internal_buffer() throw(); + + // [27.8.1.4] overridden virtual functions + virtual streamsize + showmanyc(); + + // Stroustrup, 1998, p. 628 + // underflow() and uflow() functions are called to get the next + // character from the real input source when the buffer is empty. + // Buffered input uses underflow() + + virtual int_type + underflow(); + + virtual int_type + pbackfail(int_type __c = _Traits::eof()); + + // Stroustrup, 1998, p 648 + // The overflow() function is called to transfer characters to the + // real output destination when the buffer is full. A call to + // overflow(c) outputs the contents of the buffer plus the + // character c. + // 27.5.2.4.5 + // Consume some sequence of the characters in the pending sequence. + virtual int_type + overflow(int_type __c = _Traits::eof()); + + // Convert internal byte sequence to external, char-based + // sequence via codecvt. + bool + _M_convert_to_external(char_type*, streamsize); + + /** + * @brief Manipulates the buffer. + * @param __s Pointer to a buffer area. + * @param __n Size of @a __s. + * @return @c this + * + * If no file has been opened, and both @a __s and @a __n are zero, then + * the stream becomes unbuffered. Otherwise, @c __s is used as a + * buffer; see + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering + * for more. + */ + virtual __streambuf_type* + setbuf(char_type* __s, streamsize __n); + + virtual pos_type + seekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + virtual pos_type + seekpos(pos_type __pos, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + // Common code for seekoff, seekpos, and overflow + pos_type + _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); + + int + _M_get_ext_pos(__state_type &__state); + + virtual int + sync(); + + virtual void + imbue(const locale& __loc); + + virtual streamsize + xsgetn(char_type* __s, streamsize __n); + + virtual streamsize + xsputn(const char_type* __s, streamsize __n); + + // Flushes output buffer, then writes unshift sequence. + bool + _M_terminate_output(); + + /** + * This function sets the pointers of the internal buffer, both get + * and put areas. Typically: + * + * __off == egptr() - eback() upon underflow/uflow (@b read mode); + * __off == 0 upon overflow (@b write mode); + * __off == -1 upon open, setbuf, seekoff/pos (@b uncommitted mode). + * + * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size + * reflects the actual allocated memory and the last cell is reserved + * for the overflow char of a full put area. + */ + void + _M_set_buffer(streamsize __off) + { + const bool __testin = _M_mode & ios_base::in; + const bool __testout = (_M_mode & ios_base::out + || _M_mode & ios_base::app); + + if (__testin && __off > 0) + this->setg(_M_buf, _M_buf, _M_buf + __off); + else + this->setg(_M_buf, _M_buf, _M_buf); + + if (__testout && __off == 0 && _M_buf_size > 1 ) + this->setp(_M_buf, _M_buf + _M_buf_size - 1); + else + this->setp(0, 0); + } + }; + + // [27.8.1.5] Template class basic_ifstream + /** + * @brief Controlling input for files. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This class supports reading from named files, using the inherited + * functions from std::basic_istream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. + */ + template + class basic_ifstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf __filebuf_type; + typedef basic_istream __istream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors/Destructors: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_ifstream() : __istream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an input file stream. + * @param __s Null terminated string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a __mode. + */ + explicit + basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @param Create an input file stream. + * @param __s Wide string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a __mode. + */ + basic_ifstream(const wchar_t* __s, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Create an input file stream. + * @param __s std::string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a __mode. + */ + explicit + basic_ifstream(const std::string& __s, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if __cplusplus >= 201703L + /** + * @brief Create an input file stream. + * @param __s filesystem::path specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::in is automatically included in @a __mode. + */ + template> + basic_ifstream(const _Path& __s, + ios_base::openmode __mode = ios_base::in) + : basic_ifstream(__s.c_str(), __mode) + { } +#endif // C++17 + + basic_ifstream(const basic_ifstream&) = delete; + + basic_ifstream(basic_ifstream&& __rhs) + : __istream_type(std::move(__rhs)), + _M_filebuf(std::move(__rhs._M_filebuf)) + { __istream_type::set_rdbuf(&_M_filebuf); } +#endif // C++11 + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_ifstream() + { } + +#if __cplusplus >= 201103L + // 27.8.3.2 Assign and swap: + + basic_ifstream& + operator=(const basic_ifstream&) = delete; + + basic_ifstream& + operator=(basic_ifstream&& __rhs) + { + __istream_type::operator=(std::move(__rhs)); + _M_filebuf = std::move(__rhs._M_filebuf); + return *this; + } + + void + swap(basic_ifstream& __rhs) + { + __istream_type::swap(__rhs); + _M_filebuf.swap(__rhs._M_filebuf); + } +#endif + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 365. Lack of const-qualification in clause 27 + bool + is_open() const + { return _M_filebuf.is_open(); } + + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,__mode|in). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + open(const char* __s, ios_base::openmode __mode = ios_base::in) + { + if (!_M_filebuf.open(__s, __mode | ios_base::in)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @brief Opens an external file. + * @param __s The name of the file, as a wide character string. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in) + { + if (!_M_filebuf.open(__s, __mode | ios_base::in)) + this->setstate(ios_base::failbit); + else + this->clear(); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, ios_base::openmode __mode = ios_base::in) + { + if (!_M_filebuf.open(__s, __mode | ios_base::in)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if __cplusplus >= 201703L + /** + * @brief Opens an external file. + * @param __s The name of the file, as a filesystem::path. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function + * fails, @c failbit is set in the stream's error state. + */ + template + _If_fs_path<_Path, void> + open(const _Path& __s, ios_base::openmode __mode = ios_base::in) + { open(__s.c_str(), __mode); } +#endif // C++17 +#endif // C++11 + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + + + // [27.8.1.8] Template class basic_ofstream + /** + * @brief Controlling output for files. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This class supports reading from named files, using the inherited + * functions from std::basic_ostream. To control the associated + * sequence, an instance of std::basic_filebuf is used, which this page + * refers to as @c sb. + */ + template + class basic_ofstream : public basic_ostream<_CharT,_Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf __filebuf_type; + typedef basic_ostream __ostream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_ofstream(): __ostream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an output file stream. + * @param __s Null terminated string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out is automatically included in @a __mode. + */ + explicit + basic_ofstream(const char* __s, + ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @param Create an output file stream. + * @param __s Wide string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out | @c ios_base::trunc is automatically included in + * @a __mode. + */ + basic_ofstream(const wchar_t* __s, + ios_base::openmode __mode = ios_base::out|ios_base::trunc) + : __ostream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Create an output file stream. + * @param __s std::string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out is automatically included in @a __mode. + */ + explicit + basic_ofstream(const std::string& __s, + ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if __cplusplus >= 201703L + /** + * @brief Create an output file stream. + * @param __s filesystem::path specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + * + * @c ios_base::out is automatically included in @a __mode. + */ + template> + basic_ofstream(const _Path& __s, + ios_base::openmode __mode = ios_base::out) + : basic_ofstream(__s.c_str(), __mode) + { } +#endif // C++17 + + basic_ofstream(const basic_ofstream&) = delete; + + basic_ofstream(basic_ofstream&& __rhs) + : __ostream_type(std::move(__rhs)), + _M_filebuf(std::move(__rhs._M_filebuf)) + { __ostream_type::set_rdbuf(&_M_filebuf); } +#endif + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_ofstream() + { } + +#if __cplusplus >= 201103L + // 27.8.3.2 Assign and swap: + + basic_ofstream& + operator=(const basic_ofstream&) = delete; + + basic_ofstream& + operator=(basic_ofstream&& __rhs) + { + __ostream_type::operator=(std::move(__rhs)); + _M_filebuf = std::move(__rhs._M_filebuf); + return *this; + } + + void + swap(basic_ofstream& __rhs) + { + __ostream_type::swap(__rhs); + _M_filebuf.swap(__rhs._M_filebuf); + } +#endif + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 365. Lack of const-qualification in clause 27 + bool + is_open() const + { return _M_filebuf.is_open(); } + + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|out). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const char* __s, ios_base::openmode __mode = ios_base::out) + { + if (!_M_filebuf.open(__s, __mode | ios_base::out)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|out). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out) + { + if (!_M_filebuf.open(__s, __mode | ios_base::out)) + this->setstate(ios_base::failbit); + else + this->clear(); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(s,mode|out). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, ios_base::openmode __mode = ios_base::out) + { + if (!_M_filebuf.open(__s, __mode | ios_base::out)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if __cplusplus >= 201703L + /** + * @brief Opens an external file. + * @param __s The name of the file, as a filesystem::path. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode|out). If that + * function fails, @c failbit is set in the stream's error state. + */ + template + _If_fs_path<_Path, void> + open(const _Path& __s, ios_base::openmode __mode = ios_base::out) + { open(__s.c_str(), __mode); } +#endif // C++17 +#endif // C++11 + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + + + // [27.8.1.11] Template class basic_fstream + /** + * @brief Controlling input and output for files. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This class supports reading from and writing to named files, using + * the inherited functions from std::basic_iostream. To control the + * associated sequence, an instance of std::basic_filebuf is used, which + * this page refers to as @c sb. + */ + template + class basic_fstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_filebuf __filebuf_type; + typedef basic_ios __ios_type; + typedef basic_iostream __iostream_type; + + private: + __filebuf_type _M_filebuf; + + public: + // Constructors/destructor: + /** + * @brief Default constructor. + * + * Initializes @c sb using its default constructor, and passes + * @c &sb to the base class initializer. Does not open any files + * (you haven't given it a filename to open). + */ + basic_fstream() + : __iostream_type(), _M_filebuf() + { this->init(&_M_filebuf); } + + /** + * @brief Create an input/output file stream. + * @param __s Null terminated string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + */ + explicit + basic_fstream(const char* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __iostream_type(0), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @param Create an input/output file stream. + * @param __s Wide string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + */ + basic_fstream(const wchar_t* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __iostream_type(0), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Create an input/output file stream. + * @param __s Null terminated string specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + */ + explicit + basic_fstream(const std::string& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __iostream_type(0), _M_filebuf() + { + this->init(&_M_filebuf); + this->open(__s, __mode); + } + +#if __cplusplus >= 201703L + /** + * @brief Create an input/output file stream. + * @param __s filesystem::path specifying the filename. + * @param __mode Open file in specified mode (see std::ios_base). + */ + template> + basic_fstream(const _Path& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : basic_fstream(__s.c_str(), __mode) + { } +#endif // C++17 + + basic_fstream(const basic_fstream&) = delete; + + basic_fstream(basic_fstream&& __rhs) + : __iostream_type(std::move(__rhs)), + _M_filebuf(std::move(__rhs._M_filebuf)) + { __iostream_type::set_rdbuf(&_M_filebuf); } +#endif + + /** + * @brief The destructor does nothing. + * + * The file is closed by the filebuf object, not the formatting + * stream. + */ + ~basic_fstream() + { } + +#if __cplusplus >= 201103L + // 27.8.3.2 Assign and swap: + + basic_fstream& + operator=(const basic_fstream&) = delete; + + basic_fstream& + operator=(basic_fstream&& __rhs) + { + __iostream_type::operator=(std::move(__rhs)); + _M_filebuf = std::move(__rhs._M_filebuf); + return *this; + } + + void + swap(basic_fstream& __rhs) + { + __iostream_type::swap(__rhs); + _M_filebuf.swap(__rhs._M_filebuf); + } +#endif + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_filebuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __filebuf_type* + rdbuf() const + { return const_cast<__filebuf_type*>(&_M_filebuf); } + + /** + * @brief Wrapper to test for an open file. + * @return @c rdbuf()->is_open() + */ + bool + is_open() + { return _M_filebuf.is_open(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 365. Lack of const-qualification in clause 27 + bool + is_open() const + { return _M_filebuf.is_open(); } + + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const char* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { + if (!_M_filebuf.open(__s, __mode)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const wchar_t* __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { + if (!_M_filebuf.open(__s, __mode)) + this->setstate(ios_base::failbit); + else + this->clear(); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Opens an external file. + * @param __s The name of the file. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode). If that + * function fails, @c failbit is set in the stream's error state. + */ + void + open(const std::string& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { + if (!_M_filebuf.open(__s, __mode)) + this->setstate(ios_base::failbit); + else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 409. Closing an fstream should clear error state + this->clear(); + } + +#if __cplusplus >= 201703L + /** + * @brief Opens an external file. + * @param __s The name of the file, as a filesystem::path. + * @param __mode The open mode flags. + * + * Calls @c std::basic_filebuf::open(__s,__mode). If that + * function fails, @c failbit is set in the stream's error state. + */ + template + _If_fs_path<_Path, void> + open(const _Path& __s, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { open(__s.c_str(), __mode); } +#endif // C++17 +#endif // C++11 + + /** + * @brief Close the file. + * + * Calls @c std::basic_filebuf::close(). If that function + * fails, @c failbit is set in the stream's error state. + */ + void + close() + { + if (!_M_filebuf.close()) + this->setstate(ios_base::failbit); + } + }; + +#if __cplusplus >= 201103L + /// Swap specialization for filebufs. + template + inline void + swap(basic_filebuf<_CharT, _Traits>& __x, + basic_filebuf<_CharT, _Traits>& __y) + { __x.swap(__y); } + + /// Swap specialization for ifstreams. + template + inline void + swap(basic_ifstream<_CharT, _Traits>& __x, + basic_ifstream<_CharT, _Traits>& __y) + { __x.swap(__y); } + + /// Swap specialization for ofstreams. + template + inline void + swap(basic_ofstream<_CharT, _Traits>& __x, + basic_ofstream<_CharT, _Traits>& __y) + { __x.swap(__y); } + + /// Swap specialization for fstreams. + template + inline void + swap(basic_fstream<_CharT, _Traits>& __x, + basic_fstream<_CharT, _Traits>& __y) + { __x.swap(__y); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _GLIBCXX_FSTREAM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream.blob new file mode 100644 index 0000000000000000000000000000000000000000..a18fb540861d79d1263a56c1c9247eb45463265c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@fstream.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional new file mode 100644 index 0000000000000000000000000000000000000000..685a3e167ee3577e0aa2317eaee2571a5f9271ee --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional @@ -0,0 +1,1370 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file include/functional + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FUNCTIONAL +#define _GLIBCXX_FUNCTIONAL 1 + +#pragma GCC system_header + +#include +#include + +#if __cplusplus >= 201103L + +#include +#include +#include +#include +#include +#include // std::reference_wrapper and _Mem_fn_traits +#include // std::function +#if __cplusplus > 201402L +# include +# include +# include +# include +#endif +#if __cplusplus > 201703L +# include +# include +#endif +#if __cplusplus > 202002L +# include +#endif + +#endif // C++11 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @brief The type of placeholder objects defined by libstdc++. + * @ingroup binders + * @since C++11 + */ + template struct _Placeholder { }; + +#if __cplusplus >= 201103L + +#if __cplusplus >= 201703L +# define __cpp_lib_invoke 201411L +# if __cplusplus > 201703L +# define __cpp_lib_constexpr_functional 201907L +# endif + + /** Invoke a callable object. + * + * `std::invoke` takes a callable object as its first argument and calls it + * with the remaining arguments. The callable object can be a pointer or + * reference to a function, a lambda closure, a class with `operator()`, + * or even a pointer-to-member. For a pointer-to-member the first argument + * must be a reference or pointer to the object that the pointer-to-member + * will be applied to. + * + * @since C++17 + */ + template + inline _GLIBCXX20_CONSTEXPR invoke_result_t<_Callable, _Args...> + invoke(_Callable&& __fn, _Args&&... __args) + noexcept(is_nothrow_invocable_v<_Callable, _Args...>) + { + return std::__invoke(std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } + +#if __cplusplus > 202002L +# define __cpp_lib_invoke_r 202106L + + /** Invoke a callable object and convert the result to `_Res`. + * + * `std::invoke_r(f, args...)` is equivalent to `std::invoke(f, args...)` + * with the result implicitly converted to `R`. + * + * @since C++23 + */ + template + requires is_invocable_r_v<_Res, _Callable, _Args...> + constexpr _Res + invoke_r(_Callable&& __fn, _Args&&... __args) + noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>) + { + return std::__invoke_r<_Res>(std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } +#endif // C++23 +#endif // C++17 + + /// @cond undocumented + + template::value> + class _Mem_fn_base + : public _Mem_fn_traits<_MemFunPtr>::__maybe_type + { + using _Traits = _Mem_fn_traits<_MemFunPtr>; + + using _Arity = typename _Traits::__arity; + using _Varargs = typename _Traits::__vararg; + + template + friend struct _Bind_check_arity; + + _MemFunPtr _M_pmf; + + public: + + using result_type = typename _Traits::__result_type; + + explicit constexpr + _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { } + + template + _GLIBCXX20_CONSTEXPR + auto + operator()(_Args&&... __args) const + noexcept(noexcept( + std::__invoke(_M_pmf, std::forward<_Args>(__args)...))) + -> decltype(std::__invoke(_M_pmf, std::forward<_Args>(__args)...)) + { return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); } + }; + + // Partial specialization for member object pointers. + template + class _Mem_fn_base<_MemObjPtr, false> + { + using _Arity = integral_constant; + using _Varargs = false_type; + + template + friend struct _Bind_check_arity; + + _MemObjPtr _M_pm; + + public: + explicit constexpr + _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { } + + template + _GLIBCXX20_CONSTEXPR + auto + operator()(_Tp&& __obj) const + noexcept(noexcept(std::__invoke(_M_pm, std::forward<_Tp>(__obj)))) + -> decltype(std::__invoke(_M_pm, std::forward<_Tp>(__obj))) + { return std::__invoke(_M_pm, std::forward<_Tp>(__obj)); } + }; + + template + struct _Mem_fn; // undefined + + template + struct _Mem_fn<_Res _Class::*> + : _Mem_fn_base<_Res _Class::*> + { + using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base; + }; + /// @endcond + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2048. Unnecessary mem_fn overloads + /** + * @brief Returns a function object that forwards to the member pointer + * pointer `pm`. + * + * This allows a pointer-to-member to be transformed into a function object + * that can be called with an object expression as its first argument. + * + * For a pointer-to-data-member the result must be called with exactly one + * argument, the object expression that would be used as the first operand + * in a `obj.*memptr` or `objp->*memptr` expression. + * + * For a pointer-to-member-function the result must be called with an object + * expression and any additional arguments to pass to the member function, + * as in an expression like `(obj.*memfun)(args...)` or + * `(objp->*memfun)(args...)`. + * + * The object expression can be a pointer, reference, `reference_wrapper`, + * or smart pointer, and the call wrapper will dereference it as needed + * to apply the pointer-to-member. + * + * @ingroup functors + * @since C++11 + */ + template + _GLIBCXX20_CONSTEXPR + inline _Mem_fn<_Tp _Class::*> + mem_fn(_Tp _Class::* __pm) noexcept + { + return _Mem_fn<_Tp _Class::*>(__pm); + } + + /** + * @brief Trait that identifies a bind expression. + * + * Determines if the given type `_Tp` is a function object that + * should be treated as a subexpression when evaluating calls to + * function objects returned by `std::bind`. + * + * C++11 [func.bind.isbind]. + * @ingroup binders + * @since C++11 + */ + template + struct is_bind_expression + : public false_type { }; + + /** + * @brief Determines if the given type _Tp is a placeholder in a + * bind() expression and, if so, which placeholder it is. + * + * C++11 [func.bind.isplace]. + * @ingroup binders + * @since C++11 + */ + template + struct is_placeholder + : public integral_constant + { }; + +#if __cplusplus > 201402L + template inline constexpr bool is_bind_expression_v + = is_bind_expression<_Tp>::value; + template inline constexpr int is_placeholder_v + = is_placeholder<_Tp>::value; +#endif // C++17 + + /** @namespace std::placeholders + * @brief ISO C++ 2011 namespace for std::bind placeholders. + * @ingroup binders + * @since C++11 + */ + namespace placeholders + { + /* Define a large number of placeholders. There is no way to + * simplify this with variadic templates, because we're introducing + * unique names for each. + */ + extern const _Placeholder<1> _1; + extern const _Placeholder<2> _2; + extern const _Placeholder<3> _3; + extern const _Placeholder<4> _4; + extern const _Placeholder<5> _5; + extern const _Placeholder<6> _6; + extern const _Placeholder<7> _7; + extern const _Placeholder<8> _8; + extern const _Placeholder<9> _9; + extern const _Placeholder<10> _10; + extern const _Placeholder<11> _11; + extern const _Placeholder<12> _12; + extern const _Placeholder<13> _13; + extern const _Placeholder<14> _14; + extern const _Placeholder<15> _15; + extern const _Placeholder<16> _16; + extern const _Placeholder<17> _17; + extern const _Placeholder<18> _18; + extern const _Placeholder<19> _19; + extern const _Placeholder<20> _20; + extern const _Placeholder<21> _21; + extern const _Placeholder<22> _22; + extern const _Placeholder<23> _23; + extern const _Placeholder<24> _24; + extern const _Placeholder<25> _25; + extern const _Placeholder<26> _26; + extern const _Placeholder<27> _27; + extern const _Placeholder<28> _28; + extern const _Placeholder<29> _29; + } + + /** + * Partial specialization of is_placeholder that provides the placeholder + * number for the placeholder objects defined by libstdc++. + * @ingroup binders + * @since C++11 + */ + template + struct is_placeholder<_Placeholder<_Num> > + : public integral_constant + { }; + + template + struct is_placeholder > + : public integral_constant + { }; + + /// @cond undocumented + + // Like tuple_element_t but SFINAE-friendly. + template + using _Safe_tuple_element_t + = typename enable_if<(__i < tuple_size<_Tuple>::value), + tuple_element<__i, _Tuple>>::type::type; + + /** + * Maps an argument to bind() into an actual argument to the bound + * function object [func.bind.bind]/10. Only the first parameter should + * be specified: the rest are used to determine among the various + * implementations. Note that, although this class is a function + * object, it isn't entirely normal because it takes only two + * parameters regardless of the number of parameters passed to the + * bind expression. The first parameter is the bound argument and + * the second parameter is a tuple containing references to the + * rest of the arguments. + */ + template::value, + bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)> + class _Mu; + + /** + * If the argument is reference_wrapper<_Tp>, returns the + * underlying reference. + * C++11 [func.bind.bind] p10 bullet 1. + */ + template + class _Mu, false, false> + { + public: + /* Note: This won't actually work for const volatile + * reference_wrappers, because reference_wrapper::get() is const + * but not volatile-qualified. This might be a defect in the TR. + */ + template + _GLIBCXX20_CONSTEXPR + _Tp& + operator()(_CVRef& __arg, _Tuple&) const volatile + { return __arg.get(); } + }; + + /** + * If the argument is a bind expression, we invoke the underlying + * function object with the same cv-qualifiers as we are given and + * pass along all of our arguments (unwrapped). + * C++11 [func.bind.bind] p10 bullet 2. + */ + template + class _Mu<_Arg, true, false> + { + public: + template + _GLIBCXX20_CONSTEXPR + auto + operator()(_CVArg& __arg, + tuple<_Args...>& __tuple) const volatile + -> decltype(__arg(declval<_Args>()...)) + { + // Construct an index tuple and forward to __call + typedef typename _Build_index_tuple::__type + _Indexes; + return this->__call(__arg, __tuple, _Indexes()); + } + + private: + // Invokes the underlying function object __arg by unpacking all + // of the arguments in the tuple. + template + _GLIBCXX20_CONSTEXPR + auto + __call(_CVArg& __arg, tuple<_Args...>& __tuple, + const _Index_tuple<_Indexes...>&) const volatile + -> decltype(__arg(declval<_Args>()...)) + { + return __arg(std::get<_Indexes>(std::move(__tuple))...); + } + }; + + /** + * If the argument is a placeholder for the Nth argument, returns + * a reference to the Nth argument to the bind function object. + * C++11 [func.bind.bind] p10 bullet 3. + */ + template + class _Mu<_Arg, false, true> + { + public: + template + _GLIBCXX20_CONSTEXPR + _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&& + operator()(const volatile _Arg&, _Tuple& __tuple) const volatile + { + return + ::std::get<(is_placeholder<_Arg>::value - 1)>(std::move(__tuple)); + } + }; + + /** + * If the argument is just a value, returns a reference to that + * value. The cv-qualifiers on the reference are determined by the caller. + * C++11 [func.bind.bind] p10 bullet 4. + */ + template + class _Mu<_Arg, false, false> + { + public: + template + _GLIBCXX20_CONSTEXPR + _CVArg&& + operator()(_CVArg&& __arg, _Tuple&) const volatile + { return std::forward<_CVArg>(__arg); } + }; + + // std::get for volatile-qualified tuples + template + inline auto + __volget(volatile tuple<_Tp...>& __tuple) + -> __tuple_element_t<_Ind, tuple<_Tp...>> volatile& + { return std::get<_Ind>(const_cast&>(__tuple)); } + + // std::get for const-volatile-qualified tuples + template + inline auto + __volget(const volatile tuple<_Tp...>& __tuple) + -> __tuple_element_t<_Ind, tuple<_Tp...>> const volatile& + { return std::get<_Ind>(const_cast&>(__tuple)); } + + /// @endcond + + /// Type of the function object returned from bind(). + template + class _Bind; + + template + class _Bind<_Functor(_Bound_args...)> + : public _Weak_result_type<_Functor> + { + typedef typename _Build_index_tuple::__type + _Bound_indexes; + + _Functor _M_f; + tuple<_Bound_args...> _M_bound_args; + + // Call unqualified + template + _GLIBCXX20_CONSTEXPR + _Result + __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) + { + return std::__invoke(_M_f, + _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)... + ); + } + + // Call as const + template + _GLIBCXX20_CONSTEXPR + _Result + __call_c(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const + { + return std::__invoke(_M_f, + _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)... + ); + } + + // Call as volatile + template + _Result + __call_v(tuple<_Args...>&& __args, + _Index_tuple<_Indexes...>) volatile + { + return std::__invoke(_M_f, + _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)... + ); + } + + // Call as const volatile + template + _Result + __call_c_v(tuple<_Args...>&& __args, + _Index_tuple<_Indexes...>) const volatile + { + return std::__invoke(_M_f, + _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)... + ); + } + + template + using _Mu_type = decltype( + _Mu::type>()( + std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) ); + + template + using _Res_type_impl + = typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type; + + template + using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>; + + template + using __dependent = typename + enable_if::value+1), _Functor>::type; + + template class __cv_quals> + using _Res_type_cv = _Res_type_impl< + typename __cv_quals<__dependent<_CallArgs>>::type, + _CallArgs, + typename __cv_quals<_Bound_args>::type...>; + + public: + template + explicit _GLIBCXX20_CONSTEXPR + _Bind(const _Functor& __f, _Args&&... __args) + : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...) + { } + + template + explicit _GLIBCXX20_CONSTEXPR + _Bind(_Functor&& __f, _Args&&... __args) + : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...) + { } + + _Bind(const _Bind&) = default; + _Bind(_Bind&&) = default; + + // Call unqualified + template>> + _GLIBCXX20_CONSTEXPR + _Result + operator()(_Args&&... __args) + { + return this->__call<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + + // Call as const + template, add_const>> + _GLIBCXX20_CONSTEXPR + _Result + operator()(_Args&&... __args) const + { + return this->__call_c<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + +#if __cplusplus > 201402L +# define _GLIBCXX_DEPR_BIND \ + [[deprecated("std::bind does not support volatile in C++17")]] +#else +# define _GLIBCXX_DEPR_BIND +#endif + // Call as volatile + template, add_volatile>> + _GLIBCXX_DEPR_BIND + _Result + operator()(_Args&&... __args) volatile + { + return this->__call_v<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + + // Call as const volatile + template, add_cv>> + _GLIBCXX_DEPR_BIND + _Result + operator()(_Args&&... __args) const volatile + { + return this->__call_c_v<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + }; + + /// Type of the function object returned from bind(). + template + class _Bind_result; + + template + class _Bind_result<_Result, _Functor(_Bound_args...)> + { + typedef typename _Build_index_tuple::__type + _Bound_indexes; + + _Functor _M_f; + tuple<_Bound_args...> _M_bound_args; + + // Call unqualified + template + _GLIBCXX20_CONSTEXPR + _Res + __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) + { + return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() + (std::get<_Indexes>(_M_bound_args), __args)...); + } + + // Call as const + template + _GLIBCXX20_CONSTEXPR + _Res + __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const + { + return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() + (std::get<_Indexes>(_M_bound_args), __args)...); + } + + // Call as volatile + template + _GLIBCXX20_CONSTEXPR + _Res + __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile + { + return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() + (__volget<_Indexes>(_M_bound_args), __args)...); + } + + // Call as const volatile + template + _GLIBCXX20_CONSTEXPR + _Res + __call(tuple<_Args...>&& __args, + _Index_tuple<_Indexes...>) const volatile + { + return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() + (__volget<_Indexes>(_M_bound_args), __args)...); + } + + public: + typedef _Result result_type; + + template + explicit _GLIBCXX20_CONSTEXPR + _Bind_result(const _Functor& __f, _Args&&... __args) + : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...) + { } + + template + explicit _GLIBCXX20_CONSTEXPR + _Bind_result(_Functor&& __f, _Args&&... __args) + : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...) + { } + + _Bind_result(const _Bind_result&) = default; + _Bind_result(_Bind_result&&) = default; + + // Call unqualified + template + _GLIBCXX20_CONSTEXPR + result_type + operator()(_Args&&... __args) + { + return this->__call<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + + // Call as const + template + _GLIBCXX20_CONSTEXPR + result_type + operator()(_Args&&... __args) const + { + return this->__call<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + + // Call as volatile + template + _GLIBCXX_DEPR_BIND + result_type + operator()(_Args&&... __args) volatile + { + return this->__call<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + + // Call as const volatile + template + _GLIBCXX_DEPR_BIND + result_type + operator()(_Args&&... __args) const volatile + { + return this->__call<_Result>( + std::forward_as_tuple(std::forward<_Args>(__args)...), + _Bound_indexes()); + } + }; +#undef _GLIBCXX_DEPR_BIND + + /** + * @brief Class template _Bind is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression<_Bind<_Signature> > + : public true_type { }; + + /** + * @brief Class template _Bind is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression > + : public true_type { }; + + /** + * @brief Class template _Bind is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression > + : public true_type { }; + + /** + * @brief Class template _Bind is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression> + : public true_type { }; + + /** + * @brief Class template _Bind_result is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression<_Bind_result<_Result, _Signature>> + : public true_type { }; + + /** + * @brief Class template _Bind_result is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression> + : public true_type { }; + + /** + * @brief Class template _Bind_result is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression> + : public true_type { }; + + /** + * @brief Class template _Bind_result is always a bind expression. + * @ingroup binders + */ + template + struct is_bind_expression> + : public true_type { }; + + template + struct _Bind_check_arity { }; + + template + struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...> + { + static_assert(sizeof...(_BoundArgs) == sizeof...(_Args), + "Wrong number of arguments for function"); + }; + + template + struct _Bind_check_arity<_Ret (*)(_Args......), _BoundArgs...> + { + static_assert(sizeof...(_BoundArgs) >= sizeof...(_Args), + "Wrong number of arguments for function"); + }; + + template + struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...> + { + using _Arity = typename _Mem_fn<_Tp _Class::*>::_Arity; + using _Varargs = typename _Mem_fn<_Tp _Class::*>::_Varargs; + static_assert(_Varargs::value + ? sizeof...(_BoundArgs) >= _Arity::value + 1 + : sizeof...(_BoundArgs) == _Arity::value + 1, + "Wrong number of arguments for pointer-to-member"); + }; + + // Trait type used to remove std::bind() from overload set via SFINAE + // when first argument has integer type, so that std::bind() will + // not be a better match than ::bind() from the BSD Sockets API. + template::type> + using __is_socketlike = __or_, is_enum<_Tp2>>; + + template + struct _Bind_helper + : _Bind_check_arity::type, _BoundArgs...> + { + typedef typename decay<_Func>::type __func_type; + typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type; + }; + + // Partial specialization for is_socketlike == true, does not define + // nested type so std::bind() will not participate in overload resolution + // when the first argument might be a socket file descriptor. + template + struct _Bind_helper + { }; + + /** + * @brief Function template for std::bind. + * @ingroup binders + * @since C++11 + */ + template + inline _GLIBCXX20_CONSTEXPR typename + _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type + bind(_Func&& __f, _BoundArgs&&... __args) + { + typedef _Bind_helper __helper_type; + return typename __helper_type::type(std::forward<_Func>(__f), + std::forward<_BoundArgs>(__args)...); + } + + template + struct _Bindres_helper + : _Bind_check_arity::type, _BoundArgs...> + { + typedef typename decay<_Func>::type __functor_type; + typedef _Bind_result<_Result, + __functor_type(typename decay<_BoundArgs>::type...)> + type; + }; + + /** + * @brief Function template for std::bind. + * @ingroup binders + * @since C++11 + */ + template + inline _GLIBCXX20_CONSTEXPR + typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type + bind(_Func&& __f, _BoundArgs&&... __args) + { + typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type; + return typename __helper_type::type(std::forward<_Func>(__f), + std::forward<_BoundArgs>(__args)...); + } + +#if __cplusplus > 201703L +#define __cpp_lib_bind_front 201907L + + template + struct _Bind_front + { + static_assert(is_move_constructible_v<_Fd>); + static_assert((is_move_constructible_v<_BoundArgs> && ...)); + + // First parameter is to ensure this constructor is never used + // instead of the copy/move constructor. + template + explicit constexpr + _Bind_front(int, _Fn&& __fn, _Args&&... __args) + noexcept(__and_, + is_nothrow_constructible<_BoundArgs, _Args>...>::value) + : _M_fd(std::forward<_Fn>(__fn)), + _M_bound_args(std::forward<_Args>(__args)...) + { static_assert(sizeof...(_Args) == sizeof...(_BoundArgs)); } + + _Bind_front(const _Bind_front&) = default; + _Bind_front(_Bind_front&&) = default; + _Bind_front& operator=(const _Bind_front&) = default; + _Bind_front& operator=(_Bind_front&&) = default; + ~_Bind_front() = default; + + template + constexpr + invoke_result_t<_Fd&, _BoundArgs&..., _CallArgs...> + operator()(_CallArgs&&... __call_args) & + noexcept(is_nothrow_invocable_v<_Fd&, _BoundArgs&..., _CallArgs...>) + { + return _S_call(*this, _BoundIndices(), + std::forward<_CallArgs>(__call_args)...); + } + + template + constexpr + invoke_result_t + operator()(_CallArgs&&... __call_args) const & + noexcept(is_nothrow_invocable_v) + { + return _S_call(*this, _BoundIndices(), + std::forward<_CallArgs>(__call_args)...); + } + + template + constexpr + invoke_result_t<_Fd, _BoundArgs..., _CallArgs...> + operator()(_CallArgs&&... __call_args) && + noexcept(is_nothrow_invocable_v<_Fd, _BoundArgs..., _CallArgs...>) + { + return _S_call(std::move(*this), _BoundIndices(), + std::forward<_CallArgs>(__call_args)...); + } + + template + constexpr + invoke_result_t + operator()(_CallArgs&&... __call_args) const && + noexcept(is_nothrow_invocable_v) + { + return _S_call(std::move(*this), _BoundIndices(), + std::forward<_CallArgs>(__call_args)...); + } + + private: + using _BoundIndices = index_sequence_for<_BoundArgs...>; + + template + static constexpr + decltype(auto) + _S_call(_Tp&& __g, index_sequence<_Ind...>, _CallArgs&&... __call_args) + { + return std::invoke(std::forward<_Tp>(__g)._M_fd, + std::get<_Ind>(std::forward<_Tp>(__g)._M_bound_args)..., + std::forward<_CallArgs>(__call_args)...); + } + + _Fd _M_fd; + std::tuple<_BoundArgs...> _M_bound_args; + }; + + template + using _Bind_front_t + = _Bind_front, decay_t<_Args>...>; + + /** Create call wrapper by partial application of arguments to function. + * + * The result of `std::bind_front(f, args...)` is a function object that + * stores `f` and the bound arguments, `args...`. When that function + * object is invoked with `call_args...` it returns the result of calling + * `f(args..., call_args...)`. + * + * @since C++20 + */ + template + constexpr _Bind_front_t<_Fn, _Args...> + bind_front(_Fn&& __fn, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Bind_front_t<_Fn, _Args...>, + int, _Fn, _Args...>) + { + return _Bind_front_t<_Fn, _Args...>(0, std::forward<_Fn>(__fn), + std::forward<_Args>(__args)...); + } +#endif // C++20 + +#if __cplusplus >= 201402L + /// Generalized negator. + template + class _Not_fn + { + template + using __inv_res_t = typename __invoke_result<_Fn2, _Args...>::type; + + template + static decltype(!std::declval<_Tp>()) + _S_not() noexcept(noexcept(!std::declval<_Tp>())); + + public: + template + constexpr + _Not_fn(_Fn2&& __fn, int) + : _M_fn(std::forward<_Fn2>(__fn)) { } + + _Not_fn(const _Not_fn& __fn) = default; + _Not_fn(_Not_fn&& __fn) = default; + ~_Not_fn() = default; + + // Macro to define operator() with given cv-qualifiers ref-qualifiers, + // forwarding _M_fn and the function arguments with the same qualifiers, + // and deducing the return type and exception-specification. +#define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \ + template \ + _GLIBCXX20_CONSTEXPR \ + decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \ + operator()(_Args&&... __args) _QUALS \ + noexcept(__is_nothrow_invocable<_Fn _QUALS, _Args...>::value \ + && noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \ + { \ + return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \ + std::forward<_Args>(__args)...); \ + } + _GLIBCXX_NOT_FN_CALL_OP( & ) + _GLIBCXX_NOT_FN_CALL_OP( const & ) + _GLIBCXX_NOT_FN_CALL_OP( && ) + _GLIBCXX_NOT_FN_CALL_OP( const && ) +#undef _GLIBCXX_NOT_FN_CALL_OP + + private: + _Fn _M_fn; + }; + + template + struct __is_byte_like : false_type { }; + + template + struct __is_byte_like<_Tp, equal_to<_Tp>> + : __bool_constant::value> { }; + + template + struct __is_byte_like<_Tp, equal_to> + : __bool_constant::value> { }; + +#if __cplusplus >= 201703L + // Declare std::byte (full definition is in ). + enum class byte : unsigned char; + + template<> + struct __is_byte_like> + : true_type { }; + + template<> + struct __is_byte_like> + : true_type { }; + + // [func.not_fn] Function template not_fn +#define __cpp_lib_not_fn 201603L + /** Wrap a function object to create one that negates its result. + * + * The function template `std::not_fn` creates a "forwarding call wrapper", + * which is a function object that wraps another function object and + * when called, forwards its arguments to the wrapped function object. + * + * The result of invoking the wrapper is the negation (using `!`) of + * the wrapped function object. + * + * @ingroup functors + * @since C++17 + */ + template + _GLIBCXX20_CONSTEXPR + inline auto + not_fn(_Fn&& __fn) + noexcept(std::is_nothrow_constructible, _Fn&&>::value) + { + return _Not_fn>{std::forward<_Fn>(__fn), 0}; + } + + // Searchers +#define __cpp_lib_boyer_moore_searcher 201603L + + template> + class default_searcher + { + public: + _GLIBCXX20_CONSTEXPR + default_searcher(_ForwardIterator1 __pat_first, + _ForwardIterator1 __pat_last, + _BinaryPredicate __pred = _BinaryPredicate()) + : _M_m(__pat_first, __pat_last, std::move(__pred)) + { } + + template + _GLIBCXX20_CONSTEXPR + pair<_ForwardIterator2, _ForwardIterator2> + operator()(_ForwardIterator2 __first, _ForwardIterator2 __last) const + { + _ForwardIterator2 __first_ret = + std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m), + std::get<2>(_M_m)); + auto __ret = std::make_pair(__first_ret, __first_ret); + if (__ret.first != __last) + std::advance(__ret.second, std::distance(std::get<0>(_M_m), + std::get<1>(_M_m))); + return __ret; + } + + private: + tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m; + }; + + template + struct __boyer_moore_map_base + { + template + __boyer_moore_map_base(_RAIter __pat, size_t __patlen, + _Hash&& __hf, _Pred&& __pred) + : _M_bad_char{ __patlen, std::move(__hf), std::move(__pred) } + { + if (__patlen > 0) + for (__diff_type __i = 0; __i < __patlen - 1; ++__i) + _M_bad_char[__pat[__i]] = __patlen - 1 - __i; + } + + using __diff_type = _Tp; + + __diff_type + _M_lookup(_Key __key, __diff_type __not_found) const + { + auto __iter = _M_bad_char.find(__key); + if (__iter == _M_bad_char.end()) + return __not_found; + return __iter->second; + } + + _Pred + _M_pred() const { return _M_bad_char.key_eq(); } + + _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char; + }; + + template + struct __boyer_moore_array_base + { + template + __boyer_moore_array_base(_RAIter __pat, size_t __patlen, + _Unused&&, _Pred&& __pred) + : _M_bad_char{ array<_Tp, _Len>{}, std::move(__pred) } + { + std::get<0>(_M_bad_char).fill(__patlen); + if (__patlen > 0) + for (__diff_type __i = 0; __i < __patlen - 1; ++__i) + { + auto __ch = __pat[__i]; + using _UCh = make_unsigned_t; + auto __uch = static_cast<_UCh>(__ch); + std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i; + } + } + + using __diff_type = _Tp; + + template + __diff_type + _M_lookup(_Key __key, __diff_type __not_found) const + { + auto __ukey = static_cast>(__key); + if (__ukey >= _Len) + return __not_found; + return std::get<0>(_M_bad_char)[__ukey]; + } + + const _Pred& + _M_pred() const { return std::get<1>(_M_bad_char); } + + tuple, _Pred> _M_bad_char; + }; + + // Use __boyer_moore_array_base when pattern consists of narrow characters + // (or std::byte) and uses std::equal_to as the predicate. + template::value_type, + typename _Diff = typename iterator_traits<_RAIter>::difference_type> + using __boyer_moore_base_t + = __conditional_t<__is_byte_like<_Val, _Pred>::value, + __boyer_moore_array_base<_Diff, 256, _Pred>, + __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>; + + template::value_type>, + typename _BinaryPredicate = equal_to<>> + class boyer_moore_searcher + : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> + { + using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; + using typename _Base::__diff_type; + + public: + boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last, + _Hash __hf = _Hash(), + _BinaryPredicate __pred = _BinaryPredicate()); + + template + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const; + + private: + bool + _M_is_prefix(_RAIter __word, __diff_type __len, + __diff_type __pos) + { + const auto& __pred = this->_M_pred(); + __diff_type __suffixlen = __len - __pos; + for (__diff_type __i = 0; __i < __suffixlen; ++__i) + if (!__pred(__word[__i], __word[__pos + __i])) + return false; + return true; + } + + __diff_type + _M_suffix_length(_RAIter __word, __diff_type __len, + __diff_type __pos) + { + const auto& __pred = this->_M_pred(); + __diff_type __i = 0; + while (__pred(__word[__pos - __i], __word[__len - 1 - __i]) + && __i < __pos) + { + ++__i; + } + return __i; + } + + template + __diff_type + _M_bad_char_shift(_Tp __c) const + { return this->_M_lookup(__c, _M_pat_end - _M_pat); } + + _RAIter _M_pat; + _RAIter _M_pat_end; + _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix; + }; + + template::value_type>, + typename _BinaryPredicate = equal_to<>> + class boyer_moore_horspool_searcher + : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> + { + using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; + using typename _Base::__diff_type; + + public: + boyer_moore_horspool_searcher(_RAIter __pat, + _RAIter __pat_end, + _Hash __hf = _Hash(), + _BinaryPredicate __pred + = _BinaryPredicate()) + : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), + _M_pat(__pat), _M_pat_end(__pat_end) + { } + + template + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const + { + const auto& __pred = this->_M_pred(); + auto __patlen = _M_pat_end - _M_pat; + if (__patlen == 0) + return std::make_pair(__first, __first); + auto __len = __last - __first; + while (__len >= __patlen) + { + for (auto __scan = __patlen - 1; + __pred(__first[__scan], _M_pat[__scan]); --__scan) + if (__scan == 0) + return std::make_pair(__first, __first + __patlen); + auto __shift = _M_bad_char_shift(__first[__patlen - 1]); + __len -= __shift; + __first += __shift; + } + return std::make_pair(__last, __last); + } + + private: + template + __diff_type + _M_bad_char_shift(_Tp __c) const + { return this->_M_lookup(__c, _M_pat_end - _M_pat); } + + _RAIter _M_pat; + _RAIter _M_pat_end; + }; + + template + boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: + boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end, + _Hash __hf, _BinaryPredicate __pred) + : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), + _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat) + { + auto __patlen = __pat_end - __pat; + if (__patlen == 0) + return; + __diff_type __last_prefix = __patlen - 1; + for (__diff_type __p = __patlen - 1; __p >= 0; --__p) + { + if (_M_is_prefix(__pat, __patlen, __p + 1)) + __last_prefix = __p + 1; + _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p); + } + for (__diff_type __p = 0; __p < __patlen - 1; ++__p) + { + auto __slen = _M_suffix_length(__pat, __patlen, __p); + auto __pos = __patlen - 1 - __slen; + if (!__pred(__pat[__p - __slen], __pat[__pos])) + _M_good_suffix[__pos] = __patlen - 1 - __p + __slen; + } + } + + template + template + pair<_RandomAccessIterator2, _RandomAccessIterator2> + boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const + { + auto __patlen = _M_pat_end - _M_pat; + if (__patlen == 0) + return std::make_pair(__first, __first); + const auto& __pred = this->_M_pred(); + __diff_type __i = __patlen - 1; + auto __stringlen = __last - __first; + while (__i < __stringlen) + { + __diff_type __j = __patlen - 1; + while (__j >= 0 && __pred(__first[__i], _M_pat[__j])) + { + --__i; + --__j; + } + if (__j < 0) + { + const auto __match = __first + __i + 1; + return std::make_pair(__match, __match + __patlen); + } + __i += std::max(_M_bad_char_shift(__first[__i]), + _M_good_suffix[__j]); + } + return std::make_pair(__last, __last); + } + +#endif // C++17 +#endif // C++14 +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _GLIBCXX_FUNCTIONAL diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional.blob new file mode 100644 index 0000000000000000000000000000000000000000..4c4589458b9bfb499731e58620e1c9f0d73670e6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@functional.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future new file mode 100644 index 0000000000000000000000000000000000000000..3bdbc636f691dd43cd9ba14f7cb2ed725f91d7bf --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future @@ -0,0 +1,1819 @@ +// -*- C++ -*- + +// Copyright (C) 2009-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/future + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FUTURE +#define _GLIBCXX_FUTURE 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include // call_once +#include // __at_thread_exit_elt +#include +#include // atomic_flag +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup futures Futures + * @ingroup concurrency + * + * Classes for futures support. + * @{ + */ + + /// Error code for futures + enum class future_errc + { + future_already_retrieved = 1, + promise_already_satisfied, + no_state, + broken_promise + }; + + /// Specialization. + template<> + struct is_error_code_enum : public true_type { }; + + /// Points to a statically-allocated object derived from error_category. + const error_category& + future_category() noexcept; + + /// Overload for make_error_code. + inline error_code + make_error_code(future_errc __errc) noexcept + { return error_code(static_cast(__errc), future_category()); } + + /// Overload for make_error_condition. + inline error_condition + make_error_condition(future_errc __errc) noexcept + { return error_condition(static_cast(__errc), future_category()); } + + /** + * @brief Exception type thrown by futures. + * @ingroup exceptions + */ + class future_error : public logic_error + { + public: + explicit + future_error(future_errc __errc) + : future_error(std::make_error_code(__errc)) + { } + + virtual ~future_error() noexcept; + + virtual const char* + what() const noexcept; + + const error_code& + code() const noexcept { return _M_code; } + + private: + explicit + future_error(error_code __ec) + : logic_error("std::future_error: " + __ec.message()), _M_code(__ec) + { } + + friend void __throw_future_error(int); + + error_code _M_code; + }; + + // Forward declarations. + template + class future; + + template + class shared_future; + + template + class packaged_task; + + template + class promise; + + /// Launch code for futures + enum class launch + { + async = 1, + deferred = 2 + }; + + constexpr launch operator&(launch __x, launch __y) noexcept + { + return static_cast( + static_cast(__x) & static_cast(__y)); + } + + constexpr launch operator|(launch __x, launch __y) noexcept + { + return static_cast( + static_cast(__x) | static_cast(__y)); + } + + constexpr launch operator^(launch __x, launch __y) noexcept + { + return static_cast( + static_cast(__x) ^ static_cast(__y)); + } + + constexpr launch operator~(launch __x) noexcept + { return static_cast(~static_cast(__x)); } + + inline launch& operator&=(launch& __x, launch __y) noexcept + { return __x = __x & __y; } + + inline launch& operator|=(launch& __x, launch __y) noexcept + { return __x = __x | __y; } + + inline launch& operator^=(launch& __x, launch __y) noexcept + { return __x = __x ^ __y; } + + /// Status code for futures + enum class future_status + { + ready, + timeout, + deferred + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2021. Further incorrect usages of result_of + template + using __async_result_of = typename __invoke_result< + typename decay<_Fn>::type, typename decay<_Args>::type...>::type; + + template + future<__async_result_of<_Fn, _Args...>> + async(launch __policy, _Fn&& __fn, _Args&&... __args); + + template + future<__async_result_of<_Fn, _Args...>> + async(_Fn&& __fn, _Args&&... __args); + +#if defined(_GLIBCXX_HAS_GTHREADS) + + /// Base class and enclosing scope. + struct __future_base + { + /// Base class for results. + struct _Result_base + { + exception_ptr _M_error; + + _Result_base(const _Result_base&) = delete; + _Result_base& operator=(const _Result_base&) = delete; + + // _M_destroy() allows derived classes to control deallocation + virtual void _M_destroy() = 0; + + struct _Deleter + { + void operator()(_Result_base* __fr) const { __fr->_M_destroy(); } + }; + + protected: + _Result_base(); + virtual ~_Result_base(); + }; + + /// A unique_ptr for result objects. + template + using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>; + + /// A result object that has storage for an object of type _Res. + template + struct _Result : _Result_base + { + private: + __gnu_cxx::__aligned_buffer<_Res> _M_storage; + bool _M_initialized; + + public: + typedef _Res result_type; + + _Result() noexcept : _M_initialized() { } + + ~_Result() + { + if (_M_initialized) + _M_value().~_Res(); + } + + // Return lvalue, future will add const or rvalue-reference + _Res& + _M_value() noexcept { return *_M_storage._M_ptr(); } + + void + _M_set(const _Res& __res) + { + ::new (_M_storage._M_addr()) _Res(__res); + _M_initialized = true; + } + + void + _M_set(_Res&& __res) + { + ::new (_M_storage._M_addr()) _Res(std::move(__res)); + _M_initialized = true; + } + + private: + void _M_destroy() { delete this; } + }; + + /// A result object that uses an allocator. + template + struct _Result_alloc final : _Result<_Res>, _Alloc + { + using __allocator_type = __alloc_rebind<_Alloc, _Result_alloc>; + + explicit + _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a) + { } + + private: + void _M_destroy() + { + __allocator_type __a(*this); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; + this->~_Result_alloc(); + } + }; + + // Create a result object that uses an allocator. + template + static _Ptr<_Result_alloc<_Res, _Allocator>> + _S_allocate_result(const _Allocator& __a) + { + using __result_type = _Result_alloc<_Res, _Allocator>; + typename __result_type::__allocator_type __a2(__a); + auto __guard = std::__allocate_guarded(__a2); + __result_type* __p = ::new((void*)__guard.get()) __result_type{__a}; + __guard = nullptr; + return _Ptr<__result_type>(__p); + } + + // Keep it simple for std::allocator. + template + static _Ptr<_Result<_Res>> + _S_allocate_result(const std::allocator<_Tp>& __a) + { + return _Ptr<_Result<_Res>>(new _Result<_Res>); + } + + // Base class for various types of shared state created by an + // asynchronous provider (such as a std::promise) and shared with one + // or more associated futures. + class _State_baseV2 + { + typedef _Ptr<_Result_base> _Ptr_type; + + enum _Status : unsigned { + __not_ready, + __ready + }; + + _Ptr_type _M_result; + __atomic_futex_unsigned<> _M_status; + atomic_flag _M_retrieved = ATOMIC_FLAG_INIT; + once_flag _M_once; + + public: + _State_baseV2() noexcept : _M_result(), _M_status(_Status::__not_ready) + { } + _State_baseV2(const _State_baseV2&) = delete; + _State_baseV2& operator=(const _State_baseV2&) = delete; + virtual ~_State_baseV2() = default; + + _Result_base& + wait() + { + // Run any deferred function or join any asynchronous thread: + _M_complete_async(); + // Acquire MO makes sure this synchronizes with the thread that made + // the future ready. + _M_status._M_load_when_equal(_Status::__ready, memory_order_acquire); + return *_M_result; + } + + template + future_status + wait_for(const chrono::duration<_Rep, _Period>& __rel) + { + // First, check if the future has been made ready. Use acquire MO + // to synchronize with the thread that made it ready. + if (_M_status._M_load(memory_order_acquire) == _Status::__ready) + return future_status::ready; + + if (_M_is_deferred_future()) + return future_status::deferred; + + // Don't wait unless the relative time is greater than zero. + if (__rel > __rel.zero() + && _M_status._M_load_when_equal_for(_Status::__ready, + memory_order_acquire, + __rel)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2100. timed waiting functions must also join + // This call is a no-op by default except on an async future, + // in which case the async thread is joined. It's also not a + // no-op for a deferred future, but such a future will never + // reach this point because it returns future_status::deferred + // instead of waiting for the future to become ready (see + // above). Async futures synchronize in this call, so we need + // no further synchronization here. + _M_complete_async(); + + return future_status::ready; + } + return future_status::timeout; + } + + template + future_status + wait_until(const chrono::time_point<_Clock, _Duration>& __abs) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + // First, check if the future has been made ready. Use acquire MO + // to synchronize with the thread that made it ready. + if (_M_status._M_load(memory_order_acquire) == _Status::__ready) + return future_status::ready; + + if (_M_is_deferred_future()) + return future_status::deferred; + + if (_M_status._M_load_when_equal_until(_Status::__ready, + memory_order_acquire, + __abs)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2100. timed waiting functions must also join + // See wait_for(...) above. + _M_complete_async(); + + return future_status::ready; + } + return future_status::timeout; + } + + // Provide a result to the shared state and make it ready. + // Calls at most once: _M_result = __res(); + void + _M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false) + { + bool __did_set = false; + // all calls to this function are serialized, + // side-effects of invoking __res only happen once + call_once(_M_once, &_State_baseV2::_M_do_set, this, + std::__addressof(__res), std::__addressof(__did_set)); + if (__did_set) + // Use release MO to synchronize with observers of the ready state. + _M_status._M_store_notify_all(_Status::__ready, + memory_order_release); + else if (!__ignore_failure) + __throw_future_error(int(future_errc::promise_already_satisfied)); + } + + // Provide a result to the shared state but delay making it ready + // until the calling thread exits. + // Calls at most once: _M_result = __res(); + void + _M_set_delayed_result(function<_Ptr_type()> __res, + weak_ptr<_State_baseV2> __self) + { + bool __did_set = false; + unique_ptr<_Make_ready> __mr{new _Make_ready}; + // all calls to this function are serialized, + // side-effects of invoking __res only happen once + call_once(_M_once, &_State_baseV2::_M_do_set, this, + std::__addressof(__res), std::__addressof(__did_set)); + if (!__did_set) + __throw_future_error(int(future_errc::promise_already_satisfied)); + __mr->_M_shared_state = std::move(__self); + __mr->_M_set(); + __mr.release(); + } + + // Abandon this shared state. + void + _M_break_promise(_Ptr_type __res) + { + if (static_cast(__res)) + { + __res->_M_error = + make_exception_ptr(future_error(future_errc::broken_promise)); + // This function is only called when the last asynchronous result + // provider is abandoning this shared state, so noone can be + // trying to make the shared state ready at the same time, and + // we can access _M_result directly instead of through call_once. + _M_result.swap(__res); + // Use release MO to synchronize with observers of the ready state. + _M_status._M_store_notify_all(_Status::__ready, + memory_order_release); + } + } + + // Called when this object is first passed to a future. + void + _M_set_retrieved_flag() + { + if (_M_retrieved.test_and_set()) + __throw_future_error(int(future_errc::future_already_retrieved)); + } + + template + struct _Setter; + + // set lvalues + template + struct _Setter<_Res, _Arg&> + { + // check this is only used by promise::set_value(const R&) + // or promise::set_value(R&) + static_assert(is_same<_Res, _Arg&>::value // promise + || is_same::value, // promise + "Invalid specialisation"); + + // Used by std::promise to copy construct the result. + typename promise<_Res>::_Ptr_type operator()() const + { + _M_promise->_M_storage->_M_set(*_M_arg); + return std::move(_M_promise->_M_storage); + } + promise<_Res>* _M_promise; + _Arg* _M_arg; + }; + + // set rvalues + template + struct _Setter<_Res, _Res&&> + { + // Used by std::promise to move construct the result. + typename promise<_Res>::_Ptr_type operator()() const + { + _M_promise->_M_storage->_M_set(std::move(*_M_arg)); + return std::move(_M_promise->_M_storage); + } + promise<_Res>* _M_promise; + _Res* _M_arg; + }; + + // set void + template + struct _Setter<_Res, void> + { + static_assert(is_void<_Res>::value, "Only used for promise"); + + typename promise<_Res>::_Ptr_type operator()() const + { return std::move(_M_promise->_M_storage); } + + promise<_Res>* _M_promise; + }; + + struct __exception_ptr_tag { }; + + // set exceptions + template + struct _Setter<_Res, __exception_ptr_tag> + { + // Used by std::promise to store an exception as the result. + typename promise<_Res>::_Ptr_type operator()() const + { + _M_promise->_M_storage->_M_error = *_M_ex; + return std::move(_M_promise->_M_storage); + } + + promise<_Res>* _M_promise; + exception_ptr* _M_ex; + }; + + template + __attribute__((__always_inline__)) + static _Setter<_Res, _Arg&&> + __setter(promise<_Res>* __prom, _Arg&& __arg) noexcept + { + return _Setter<_Res, _Arg&&>{ __prom, std::__addressof(__arg) }; + } + + template + __attribute__((__always_inline__)) + static _Setter<_Res, __exception_ptr_tag> + __setter(exception_ptr& __ex, promise<_Res>* __prom) noexcept + { + return _Setter<_Res, __exception_ptr_tag>{ __prom, &__ex }; + } + + template + __attribute__((__always_inline__)) + static _Setter<_Res, void> + __setter(promise<_Res>* __prom) noexcept + { + return _Setter<_Res, void>{ __prom }; + } + + template + static void + _S_check(const shared_ptr<_Tp>& __p) + { + if (!static_cast(__p)) + __throw_future_error((int)future_errc::no_state); + } + + private: + // The function invoked with std::call_once(_M_once, ...). + void + _M_do_set(function<_Ptr_type()>* __f, bool* __did_set) + { + _Ptr_type __res = (*__f)(); + // Notify the caller that we did try to set; if we do not throw an + // exception, the caller will be aware that it did set (e.g., see + // _M_set_result). + *__did_set = true; + _M_result.swap(__res); // nothrow + } + + // Wait for completion of async function. + virtual void _M_complete_async() { } + + // Return true if state corresponds to a deferred function. + virtual bool _M_is_deferred_future() const { return false; } + + struct _Make_ready final : __at_thread_exit_elt + { + weak_ptr<_State_baseV2> _M_shared_state; + static void _S_run(void*); + void _M_set(); + }; + }; + +#ifdef _GLIBCXX_ASYNC_ABI_COMPAT + class _State_base; + class _Async_state_common; +#else + using _State_base = _State_baseV2; + class _Async_state_commonV2; +#endif + + template()())> + class _Deferred_state; + + template()())> + class _Async_state_impl; + + template + class _Task_state_base; + + template + class _Task_state; + + template + struct _Task_setter; + + template + static _Task_setter<_Res_ptr, _BoundFn> + _S_task_setter(_Res_ptr& __ptr, _BoundFn& __call) + { + return { std::__addressof(__ptr), std::__addressof(__call) }; + } + }; + + /// Partial specialization for reference types. + template + struct __future_base::_Result<_Res&> : __future_base::_Result_base + { + typedef _Res& result_type; + + _Result() noexcept : _M_value_ptr() { } + + void + _M_set(_Res& __res) noexcept + { _M_value_ptr = std::addressof(__res); } + + _Res& _M_get() noexcept { return *_M_value_ptr; } + + private: + _Res* _M_value_ptr; + + void _M_destroy() { delete this; } + }; + + /// Explicit specialization for void. + template<> + struct __future_base::_Result : __future_base::_Result_base + { + typedef void result_type; + + private: + void _M_destroy() { delete this; } + }; + +#ifndef _GLIBCXX_ASYNC_ABI_COMPAT + + // Allow _Setter objects to be stored locally in std::function + template + struct __is_location_invariant + <__future_base::_State_base::_Setter<_Res, _Arg>> + : true_type { }; + + // Allow _Task_setter objects to be stored locally in std::function + template + struct __is_location_invariant + <__future_base::_Task_setter<_Res_ptr, _Fn, _Res>> + : true_type { }; + + /// Common implementation for future and shared_future. + template + class __basic_future : public __future_base + { + protected: + typedef shared_ptr<_State_base> __state_type; + typedef __future_base::_Result<_Res>& __result_type; + + private: + __state_type _M_state; + + public: + // Disable copying. + __basic_future(const __basic_future&) = delete; + __basic_future& operator=(const __basic_future&) = delete; + + bool + valid() const noexcept { return static_cast(_M_state); } + + void + wait() const + { + _State_base::_S_check(_M_state); + _M_state->wait(); + } + + template + future_status + wait_for(const chrono::duration<_Rep, _Period>& __rel) const + { + _State_base::_S_check(_M_state); + return _M_state->wait_for(__rel); + } + + template + future_status + wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const + { + _State_base::_S_check(_M_state); + return _M_state->wait_until(__abs); + } + + protected: + /// Wait for the state to be ready and rethrow any stored exception + __result_type + _M_get_result() const + { + _State_base::_S_check(_M_state); + _Result_base& __res = _M_state->wait(); + if (!(__res._M_error == nullptr)) + rethrow_exception(__res._M_error); + return static_cast<__result_type>(__res); + } + + void _M_swap(__basic_future& __that) noexcept + { + _M_state.swap(__that._M_state); + } + + // Construction of a future by promise::get_future() + explicit + __basic_future(const __state_type& __state) : _M_state(__state) + { + _State_base::_S_check(_M_state); + _M_state->_M_set_retrieved_flag(); + } + + // Copy construction from a shared_future + explicit + __basic_future(const shared_future<_Res>&) noexcept; + + // Move construction from a shared_future + explicit + __basic_future(shared_future<_Res>&&) noexcept; + + // Move construction from a future + explicit + __basic_future(future<_Res>&&) noexcept; + + constexpr __basic_future() noexcept : _M_state() { } + + struct _Reset + { + explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { } + ~_Reset() { _M_fut._M_state.reset(); } + __basic_future& _M_fut; + }; + }; + + + /// Primary template for future. + template + class future : public __basic_future<_Res> + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3458. Is shared_future intended to work with arrays or function types? + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); + + friend class promise<_Res>; + template friend class packaged_task; + template + friend future<__async_result_of<_Fn, _Args...>> + async(launch, _Fn&&, _Args&&...); + + typedef __basic_future<_Res> _Base_type; + typedef typename _Base_type::__state_type __state_type; + + explicit + future(const __state_type& __state) : _Base_type(__state) { } + + public: + constexpr future() noexcept : _Base_type() { } + + /// Move constructor + future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } + + // Disable copying + future(const future&) = delete; + future& operator=(const future&) = delete; + + future& operator=(future&& __fut) noexcept + { + future(std::move(__fut))._M_swap(*this); + return *this; + } + + /// Retrieving the value + _Res + get() + { + typename _Base_type::_Reset __reset(*this); + return std::move(this->_M_get_result()._M_value()); + } + + shared_future<_Res> share() noexcept; + }; + + /// Partial specialization for future + template + class future<_Res&> : public __basic_future<_Res&> + { + friend class promise<_Res&>; + template friend class packaged_task; + template + friend future<__async_result_of<_Fn, _Args...>> + async(launch, _Fn&&, _Args&&...); + + typedef __basic_future<_Res&> _Base_type; + typedef typename _Base_type::__state_type __state_type; + + explicit + future(const __state_type& __state) : _Base_type(__state) { } + + public: + constexpr future() noexcept : _Base_type() { } + + /// Move constructor + future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } + + // Disable copying + future(const future&) = delete; + future& operator=(const future&) = delete; + + future& operator=(future&& __fut) noexcept + { + future(std::move(__fut))._M_swap(*this); + return *this; + } + + /// Retrieving the value + _Res& + get() + { + typename _Base_type::_Reset __reset(*this); + return this->_M_get_result()._M_get(); + } + + shared_future<_Res&> share() noexcept; + }; + + /// Explicit specialization for future + template<> + class future : public __basic_future + { + friend class promise; + template friend class packaged_task; + template + friend future<__async_result_of<_Fn, _Args...>> + async(launch, _Fn&&, _Args&&...); + + typedef __basic_future _Base_type; + typedef typename _Base_type::__state_type __state_type; + + explicit + future(const __state_type& __state) : _Base_type(__state) { } + + public: + constexpr future() noexcept : _Base_type() { } + + /// Move constructor + future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } + + // Disable copying + future(const future&) = delete; + future& operator=(const future&) = delete; + + future& operator=(future&& __fut) noexcept + { + future(std::move(__fut))._M_swap(*this); + return *this; + } + + /// Retrieving the value + void + get() + { + typename _Base_type::_Reset __reset(*this); + this->_M_get_result(); + } + + shared_future share() noexcept; + }; + + + /// Primary template for shared_future. + template + class shared_future : public __basic_future<_Res> + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3458. Is shared_future intended to work with arrays or function types? + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); + + typedef __basic_future<_Res> _Base_type; + + public: + constexpr shared_future() noexcept : _Base_type() { } + + /// Copy constructor + shared_future(const shared_future& __sf) noexcept : _Base_type(__sf) { } + + /// Construct from a future rvalue + shared_future(future<_Res>&& __uf) noexcept + : _Base_type(std::move(__uf)) + { } + + /// Construct from a shared_future rvalue + shared_future(shared_future&& __sf) noexcept + : _Base_type(std::move(__sf)) + { } + + shared_future& operator=(const shared_future& __sf) noexcept + { + shared_future(__sf)._M_swap(*this); + return *this; + } + + shared_future& operator=(shared_future&& __sf) noexcept + { + shared_future(std::move(__sf))._M_swap(*this); + return *this; + } + + /// Retrieving the value + const _Res& + get() const { return this->_M_get_result()._M_value(); } + }; + + /// Partial specialization for shared_future + template + class shared_future<_Res&> : public __basic_future<_Res&> + { + typedef __basic_future<_Res&> _Base_type; + + public: + constexpr shared_future() noexcept : _Base_type() { } + + /// Copy constructor + shared_future(const shared_future& __sf) : _Base_type(__sf) { } + + /// Construct from a future rvalue + shared_future(future<_Res&>&& __uf) noexcept + : _Base_type(std::move(__uf)) + { } + + /// Construct from a shared_future rvalue + shared_future(shared_future&& __sf) noexcept + : _Base_type(std::move(__sf)) + { } + + shared_future& operator=(const shared_future& __sf) + { + shared_future(__sf)._M_swap(*this); + return *this; + } + + shared_future& operator=(shared_future&& __sf) noexcept + { + shared_future(std::move(__sf))._M_swap(*this); + return *this; + } + + /// Retrieving the value + _Res& + get() const { return this->_M_get_result()._M_get(); } + }; + + /// Explicit specialization for shared_future + template<> + class shared_future : public __basic_future + { + typedef __basic_future _Base_type; + + public: + constexpr shared_future() noexcept : _Base_type() { } + + /// Copy constructor + shared_future(const shared_future& __sf) : _Base_type(__sf) { } + + /// Construct from a future rvalue + shared_future(future&& __uf) noexcept + : _Base_type(std::move(__uf)) + { } + + /// Construct from a shared_future rvalue + shared_future(shared_future&& __sf) noexcept + : _Base_type(std::move(__sf)) + { } + + shared_future& operator=(const shared_future& __sf) + { + shared_future(__sf)._M_swap(*this); + return *this; + } + + shared_future& operator=(shared_future&& __sf) noexcept + { + shared_future(std::move(__sf))._M_swap(*this); + return *this; + } + + // Retrieving the value + void + get() const { this->_M_get_result(); } + }; + + // Now we can define the protected __basic_future constructors. + template + inline __basic_future<_Res>:: + __basic_future(const shared_future<_Res>& __sf) noexcept + : _M_state(__sf._M_state) + { } + + template + inline __basic_future<_Res>:: + __basic_future(shared_future<_Res>&& __sf) noexcept + : _M_state(std::move(__sf._M_state)) + { } + + template + inline __basic_future<_Res>:: + __basic_future(future<_Res>&& __uf) noexcept + : _M_state(std::move(__uf._M_state)) + { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2556. Wide contract for future::share() + template + inline shared_future<_Res> + future<_Res>::share() noexcept + { return shared_future<_Res>(std::move(*this)); } + + template + inline shared_future<_Res&> + future<_Res&>::share() noexcept + { return shared_future<_Res&>(std::move(*this)); } + + inline shared_future + future::share() noexcept + { return shared_future(std::move(*this)); } + + /// Primary template for promise + template + class promise + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3466: Specify the requirements for promise/future/[...] consistently + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); + + typedef __future_base::_State_base _State; + typedef __future_base::_Result<_Res> _Res_type; + typedef __future_base::_Ptr<_Res_type> _Ptr_type; + template friend struct _State::_Setter; + friend _State; + + shared_ptr<_State> _M_future; + _Ptr_type _M_storage; + + public: + promise() + : _M_future(std::make_shared<_State>()), + _M_storage(new _Res_type()) + { } + + promise(promise&& __rhs) noexcept + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + template + promise(allocator_arg_t, const _Allocator& __a) + : _M_future(std::allocate_shared<_State>(__a)), + _M_storage(__future_base::_S_allocate_result<_Res>(__a)) + { } + + template + promise(allocator_arg_t, const _Allocator&, promise&& __rhs) + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + promise(const promise&) = delete; + + ~promise() + { + if (static_cast(_M_future) && !_M_future.unique()) + _M_future->_M_break_promise(std::move(_M_storage)); + } + + // Assignment + promise& + operator=(promise&& __rhs) noexcept + { + promise(std::move(__rhs)).swap(*this); + return *this; + } + + promise& operator=(const promise&) = delete; + + void + swap(promise& __rhs) noexcept + { + _M_future.swap(__rhs._M_future); + _M_storage.swap(__rhs._M_storage); + } + + // Retrieving the result + future<_Res> + get_future() + { return future<_Res>(_M_future); } + + // Setting the result + void + set_value(const _Res& __r) + { _M_state()._M_set_result(_State::__setter(this, __r)); } + + void + set_value(_Res&& __r) + { _M_state()._M_set_result(_State::__setter(this, std::move(__r))); } + + void + set_exception(exception_ptr __p) + { _M_state()._M_set_result(_State::__setter(__p, this)); } + + void + set_value_at_thread_exit(const _Res& __r) + { + _M_state()._M_set_delayed_result(_State::__setter(this, __r), + _M_future); + } + + void + set_value_at_thread_exit(_Res&& __r) + { + _M_state()._M_set_delayed_result( + _State::__setter(this, std::move(__r)), _M_future); + } + + void + set_exception_at_thread_exit(exception_ptr __p) + { + _M_state()._M_set_delayed_result(_State::__setter(__p, this), + _M_future); + } + + private: + _State& + _M_state() + { + __future_base::_State_base::_S_check(_M_future); + return *_M_future; + } + }; + + template + inline void + swap(promise<_Res>& __x, promise<_Res>& __y) noexcept + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public true_type { }; + + + /// Partial specialization for promise + template + class promise<_Res&> + { + typedef __future_base::_State_base _State; + typedef __future_base::_Result<_Res&> _Res_type; + typedef __future_base::_Ptr<_Res_type> _Ptr_type; + template friend struct _State::_Setter; + friend _State; + + shared_ptr<_State> _M_future; + _Ptr_type _M_storage; + + public: + promise() + : _M_future(std::make_shared<_State>()), + _M_storage(new _Res_type()) + { } + + promise(promise&& __rhs) noexcept + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + template + promise(allocator_arg_t, const _Allocator& __a) + : _M_future(std::allocate_shared<_State>(__a)), + _M_storage(__future_base::_S_allocate_result<_Res&>(__a)) + { } + + template + promise(allocator_arg_t, const _Allocator&, promise&& __rhs) + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + promise(const promise&) = delete; + + ~promise() + { + if (static_cast(_M_future) && !_M_future.unique()) + _M_future->_M_break_promise(std::move(_M_storage)); + } + + // Assignment + promise& + operator=(promise&& __rhs) noexcept + { + promise(std::move(__rhs)).swap(*this); + return *this; + } + + promise& operator=(const promise&) = delete; + + void + swap(promise& __rhs) noexcept + { + _M_future.swap(__rhs._M_future); + _M_storage.swap(__rhs._M_storage); + } + + // Retrieving the result + future<_Res&> + get_future() + { return future<_Res&>(_M_future); } + + // Setting the result + void + set_value(_Res& __r) + { _M_state()._M_set_result(_State::__setter(this, __r)); } + + void + set_exception(exception_ptr __p) + { _M_state()._M_set_result(_State::__setter(__p, this)); } + + void + set_value_at_thread_exit(_Res& __r) + { + _M_state()._M_set_delayed_result(_State::__setter(this, __r), + _M_future); + } + + void + set_exception_at_thread_exit(exception_ptr __p) + { + _M_state()._M_set_delayed_result(_State::__setter(__p, this), + _M_future); + } + + private: + _State& + _M_state() + { + __future_base::_State_base::_S_check(_M_future); + return *_M_future; + } + }; + + /// Explicit specialization for promise + template<> + class promise + { + typedef __future_base::_State_base _State; + typedef __future_base::_Result _Res_type; + typedef __future_base::_Ptr<_Res_type> _Ptr_type; + template friend struct _State::_Setter; + friend _State; + + shared_ptr<_State> _M_future; + _Ptr_type _M_storage; + + public: + promise() + : _M_future(std::make_shared<_State>()), + _M_storage(new _Res_type()) + { } + + promise(promise&& __rhs) noexcept + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + template + promise(allocator_arg_t, const _Allocator& __a) + : _M_future(std::allocate_shared<_State>(__a)), + _M_storage(__future_base::_S_allocate_result(__a)) + { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2095. missing constructors needed for uses-allocator construction + template + promise(allocator_arg_t, const _Allocator&, promise&& __rhs) + : _M_future(std::move(__rhs._M_future)), + _M_storage(std::move(__rhs._M_storage)) + { } + + promise(const promise&) = delete; + + ~promise() + { + if (static_cast(_M_future) && !_M_future.unique()) + _M_future->_M_break_promise(std::move(_M_storage)); + } + + // Assignment + promise& + operator=(promise&& __rhs) noexcept + { + promise(std::move(__rhs)).swap(*this); + return *this; + } + + promise& operator=(const promise&) = delete; + + void + swap(promise& __rhs) noexcept + { + _M_future.swap(__rhs._M_future); + _M_storage.swap(__rhs._M_storage); + } + + // Retrieving the result + future + get_future() + { return future(_M_future); } + + // Setting the result + void + set_value() + { _M_state()._M_set_result(_State::__setter(this)); } + + void + set_exception(exception_ptr __p) + { _M_state()._M_set_result(_State::__setter(__p, this)); } + + void + set_value_at_thread_exit() + { _M_state()._M_set_delayed_result(_State::__setter(this), _M_future); } + + void + set_exception_at_thread_exit(exception_ptr __p) + { + _M_state()._M_set_delayed_result(_State::__setter(__p, this), + _M_future); + } + + private: + _State& + _M_state() + { + __future_base::_State_base::_S_check(_M_future); + return *_M_future; + } + }; + + template + struct __future_base::_Task_setter + { + // Invoke the function and provide the result to the caller. + _Ptr_type operator()() const + { + __try + { + (*_M_result)->_M_set((*_M_fn)()); + } + __catch(const __cxxabiv1::__forced_unwind&) + { + __throw_exception_again; // will cause broken_promise + } + __catch(...) + { + (*_M_result)->_M_error = current_exception(); + } + return std::move(*_M_result); + } + _Ptr_type* _M_result; + _Fn* _M_fn; + }; + + template + struct __future_base::_Task_setter<_Ptr_type, _Fn, void> + { + _Ptr_type operator()() const + { + __try + { + (*_M_fn)(); + } + __catch(const __cxxabiv1::__forced_unwind&) + { + __throw_exception_again; // will cause broken_promise + } + __catch(...) + { + (*_M_result)->_M_error = current_exception(); + } + return std::move(*_M_result); + } + _Ptr_type* _M_result; + _Fn* _M_fn; + }; + + // Holds storage for a packaged_task's result. + template + struct __future_base::_Task_state_base<_Res(_Args...)> + : __future_base::_State_base + { + typedef _Res _Res_type; + + template + _Task_state_base(const _Alloc& __a) + : _M_result(_S_allocate_result<_Res>(__a)) + { } + + // Invoke the stored task and make the state ready. + virtual void + _M_run(_Args&&... __args) = 0; + + // Invoke the stored task and make the state ready at thread exit. + virtual void + _M_run_delayed(_Args&&... __args, weak_ptr<_State_base>) = 0; + + virtual shared_ptr<_Task_state_base> + _M_reset() = 0; + + typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; + _Ptr_type _M_result; + }; + + // Holds a packaged_task's stored task. + template + struct __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)> final + : __future_base::_Task_state_base<_Res(_Args...)> + { + template + _Task_state(_Fn2&& __fn, const _Alloc& __a) + : _Task_state_base<_Res(_Args...)>(__a), + _M_impl(std::forward<_Fn2>(__fn), __a) + { } + + private: + virtual void + _M_run(_Args&&... __args) + { + auto __boundfn = [&] () -> _Res { + return std::__invoke_r<_Res>(_M_impl._M_fn, + std::forward<_Args>(__args)...); + }; + this->_M_set_result(_S_task_setter(this->_M_result, __boundfn)); + } + + virtual void + _M_run_delayed(_Args&&... __args, weak_ptr<_State_base> __self) + { + auto __boundfn = [&] () -> _Res { + return std::__invoke_r<_Res>(_M_impl._M_fn, + std::forward<_Args>(__args)...); + }; + this->_M_set_delayed_result(_S_task_setter(this->_M_result, __boundfn), + std::move(__self)); + } + + virtual shared_ptr<_Task_state_base<_Res(_Args...)>> + _M_reset(); + + struct _Impl : _Alloc + { + template + _Impl(_Fn2&& __fn, const _Alloc& __a) + : _Alloc(__a), _M_fn(std::forward<_Fn2>(__fn)) { } + _Fn _M_fn; + } _M_impl; + }; + + template> + static shared_ptr<__future_base::_Task_state_base<_Signature>> + __create_task_state(_Fn&& __fn, const _Alloc& __a = _Alloc()) + { + typedef typename decay<_Fn>::type _Fn2; + typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State; + return std::allocate_shared<_State>(__a, std::forward<_Fn>(__fn), __a); + } + + template + shared_ptr<__future_base::_Task_state_base<_Res(_Args...)>> + __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)>::_M_reset() + { + return __create_task_state<_Res(_Args...)>(std::move(_M_impl._M_fn), + static_cast<_Alloc&>(_M_impl)); + } + + /// packaged_task + template + class packaged_task<_Res(_ArgTypes...)> + { + typedef __future_base::_Task_state_base<_Res(_ArgTypes...)> _State_type; + shared_ptr<_State_type> _M_state; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3039. Unnecessary decay in thread and packaged_task + template> + using __not_same + = typename enable_if::value>::type; + + public: + // Construction and destruction + packaged_task() noexcept { } + + template> + explicit + packaged_task(_Fn&& __fn) + : _M_state( + __create_task_state<_Res(_ArgTypes...)>(std::forward<_Fn>(__fn))) + { } + +#if __cplusplus < 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2097. packaged_task constructors should be constrained + // 2407. [this constructor should not be] explicit + // 2921. packaged_task and type-erased allocators + template> + packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn) + : _M_state(__create_task_state<_Res(_ArgTypes...)>( + std::forward<_Fn>(__fn), __a)) + { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2095. missing constructors needed for uses-allocator construction + template + packaged_task(allocator_arg_t, const _Allocator& __a) noexcept + { } + + template + packaged_task(allocator_arg_t, const _Allocator&, + const packaged_task&) = delete; + + template + packaged_task(allocator_arg_t, const _Allocator&, + packaged_task&& __other) noexcept + { this->swap(__other); } +#endif + + ~packaged_task() + { + if (static_cast(_M_state) && !_M_state.unique()) + _M_state->_M_break_promise(std::move(_M_state->_M_result)); + } + + // No copy + packaged_task(const packaged_task&) = delete; + packaged_task& operator=(const packaged_task&) = delete; + + // Move support + packaged_task(packaged_task&& __other) noexcept + { this->swap(__other); } + + packaged_task& operator=(packaged_task&& __other) noexcept + { + packaged_task(std::move(__other)).swap(*this); + return *this; + } + + void + swap(packaged_task& __other) noexcept + { _M_state.swap(__other._M_state); } + + bool + valid() const noexcept + { return static_cast(_M_state); } + + // Result retrieval + future<_Res> + get_future() + { return future<_Res>(_M_state); } + + // Execution + void + operator()(_ArgTypes... __args) + { + __future_base::_State_base::_S_check(_M_state); + _M_state->_M_run(std::forward<_ArgTypes>(__args)...); + } + + void + make_ready_at_thread_exit(_ArgTypes... __args) + { + __future_base::_State_base::_S_check(_M_state); + _M_state->_M_run_delayed(std::forward<_ArgTypes>(__args)..., _M_state); + } + + void + reset() + { + __future_base::_State_base::_S_check(_M_state); + packaged_task __tmp; + __tmp._M_state = _M_state; + _M_state = _M_state->_M_reset(); + } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3117. Missing packaged_task deduction guides +#if __cpp_deduction_guides >= 201606 + template + packaged_task(_Res(*)(_ArgTypes...)) -> packaged_task<_Res(_ArgTypes...)>; + + template::type> + packaged_task(_Fun) -> packaged_task<_Signature>; +#endif + + /// swap + template + inline void + swap(packaged_task<_Res(_ArgTypes...)>& __x, + packaged_task<_Res(_ArgTypes...)>& __y) noexcept + { __x.swap(__y); } + +#if __cplusplus < 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2976. Dangling uses_allocator specialization for packaged_task + template + struct uses_allocator, _Alloc> + : public true_type { }; +#endif + + // Shared state created by std::async(). + // Holds a deferred function and storage for its result. + template + class __future_base::_Deferred_state final + : public __future_base::_State_base + { + public: + template + explicit + _Deferred_state(_Args&&... __args) + : _M_result(new _Result<_Res>()), + _M_fn{{std::forward<_Args>(__args)...}} + { } + + private: + typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; + _Ptr_type _M_result; + _BoundFn _M_fn; + + // Run the deferred function. + virtual void + _M_complete_async() + { + // Multiple threads can call a waiting function on the future and + // reach this point at the same time. The call_once in _M_set_result + // ensures only the first one run the deferred function, stores the + // result in _M_result, swaps that with the base _M_result and makes + // the state ready. Tell _M_set_result to ignore failure so all later + // calls do nothing. + _M_set_result(_S_task_setter(_M_result, _M_fn), true); + } + + // Caller should check whether the state is ready first, because this + // function will return true even after the deferred function has run. + virtual bool _M_is_deferred_future() const { return true; } + }; + + // Common functionality hoisted out of the _Async_state_impl template. + class __future_base::_Async_state_commonV2 + : public __future_base::_State_base + { + protected: + ~_Async_state_commonV2() = default; + + // Make waiting functions block until the thread completes, as if joined. + // + // This function is used by wait() to satisfy the first requirement below + // and by wait_for() / wait_until() to satisfy the second. + // + // [futures.async]: + // + // - a call to a waiting function on an asynchronous return object that + // shares the shared state created by this async call shall block until + // the associated thread has completed, as if joined, or else time out. + // + // - the associated thread completion synchronizes with the return from + // the first function that successfully detects the ready status of the + // shared state or with the return from the last function that releases + // the shared state, whichever happens first. + virtual void _M_complete_async() { _M_join(); } + + void _M_join() { std::call_once(_M_once, &thread::join, &_M_thread); } + + thread _M_thread; + once_flag _M_once; + }; + + // Shared state created by std::async(). + // Starts a new thread that runs a function and makes the shared state ready. + template + class __future_base::_Async_state_impl final + : public __future_base::_Async_state_commonV2 + { + public: + template + explicit + _Async_state_impl(_Args&&... __args) + : _M_result(new _Result<_Res>()), + _M_fn{{std::forward<_Args>(__args)...}} + { + _M_thread = std::thread{&_Async_state_impl::_M_run, this}; + } + + // Must not destroy _M_result and _M_fn until the thread finishes. + // Call join() directly rather than through _M_join() because no other + // thread can be referring to this state if it is being destroyed. + ~_Async_state_impl() + { + if (_M_thread.joinable()) + _M_thread.join(); + } + + private: + void + _M_run() + { + __try + { + _M_set_result(_S_task_setter(_M_result, _M_fn)); + } + __catch (const __cxxabiv1::__forced_unwind&) + { + // make the shared state ready on thread cancellation + if (static_cast(_M_result)) + this->_M_break_promise(std::move(_M_result)); + __throw_exception_again; + } + } + + typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; + _Ptr_type _M_result; + _BoundFn _M_fn; + }; + + + /// async + template + _GLIBCXX_NODISCARD future<__async_result_of<_Fn, _Args...>> + async(launch __policy, _Fn&& __fn, _Args&&... __args) + { + using _Wr = std::thread::_Call_wrapper<_Fn, _Args...>; + using _As = __future_base::_Async_state_impl<_Wr>; + using _Ds = __future_base::_Deferred_state<_Wr>; + + std::shared_ptr<__future_base::_State_base> __state; + if ((__policy & launch::async) == launch::async) + { + __try + { + __state = std::make_shared<_As>(std::forward<_Fn>(__fn), + std::forward<_Args>(__args)...); + } +#if __cpp_exceptions + catch(const system_error& __e) + { + if (__e.code() != errc::resource_unavailable_try_again + || (__policy & launch::deferred) != launch::deferred) + throw; + } +#endif + } + if (!__state) + { + __state = std::make_shared<_Ds>(std::forward<_Fn>(__fn), + std::forward<_Args>(__args)...); + } + return future<__async_result_of<_Fn, _Args...>>(std::move(__state)); + } + + /// async, potential overload + template + _GLIBCXX_NODISCARD inline future<__async_result_of<_Fn, _Args...>> + async(_Fn&& __fn, _Args&&... __args) + { + return std::async(launch::async|launch::deferred, + std::forward<_Fn>(__fn), + std::forward<_Args>(__args)...); + } + +#endif // _GLIBCXX_ASYNC_ABI_COMPAT +#endif // _GLIBCXX_HAS_GTHREADS + + /// @} group futures +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_FUTURE diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future.blob new file mode 100644 index 0000000000000000000000000000000000000000..07a1b1dbaf7f9e42edb36c3f1db892b37ef52c67 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@future.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list new file mode 100644 index 0000000000000000000000000000000000000000..79d32b219b47f491703910ce2777ca9ccdb5590b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list @@ -0,0 +1,109 @@ +// std::initializer_list support -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file initializer_list + * This is a Standard C++ Library header. + */ + +#ifndef _INITIALIZER_LIST +#define _INITIALIZER_LIST + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else // C++0x + +#pragma GCC visibility push(default) + +#include + +namespace std +{ + /// initializer_list + template + class initializer_list + { + public: + typedef _E value_type; + typedef const _E& reference; + typedef const _E& const_reference; + typedef size_t size_type; + typedef const _E* iterator; + typedef const _E* const_iterator; + + private: + iterator _M_array; + size_type _M_len; + + // The compiler can call a private constructor. + constexpr initializer_list(const_iterator __a, size_type __l) + : _M_array(__a), _M_len(__l) { } + + public: + constexpr initializer_list() noexcept + : _M_array(0), _M_len(0) { } + + // Number of elements. + constexpr size_type + size() const noexcept { return _M_len; } + + // First element. + constexpr const_iterator + begin() const noexcept { return _M_array; } + + // One past the last element. + constexpr const_iterator + end() const noexcept { return begin() + size(); } + }; + + /** + * @brief Return an iterator pointing to the first element of + * the initializer_list. + * @param __ils Initializer list. + * @relates initializer_list + */ + template + constexpr const _Tp* + begin(initializer_list<_Tp> __ils) noexcept + { return __ils.begin(); } + + /** + * @brief Return an iterator pointing to one past the last element + * of the initializer_list. + * @param __ils Initializer list. + * @relates initializer_list + */ + template + constexpr const _Tp* + end(initializer_list<_Tp> __ils) noexcept + { return __ils.end(); } +} + +#pragma GCC visibility pop + +#endif // C++11 + +#endif // _INITIALIZER_LIST diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list.blob new file mode 100644 index 0000000000000000000000000000000000000000..3241e08563ddfc73943507e971849178b53bf225 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@initializer_list.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip new file mode 100644 index 0000000000000000000000000000000000000000..537168139936af245b494d0ca9e89d34335b8435 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip @@ -0,0 +1,540 @@ +// Standard stream manipulators -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/iomanip + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.6.3 Standard manipulators +// + +#ifndef _GLIBCXX_IOMANIP +#define _GLIBCXX_IOMANIP 1 + +#pragma GCC system_header + +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#if __cplusplus > 201103L +#include +#endif +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // [27.6.3] standard manipulators + // Also see DR 183. + + struct _Resetiosflags { ios_base::fmtflags _M_mask; }; + + /** + * @brief Manipulator for @c setf. + * @param __mask A format flags mask. + * + * Sent to a stream object, this manipulator resets the specified flags, + * via @e stream.setf(0,__mask). + */ + inline _Resetiosflags + resetiosflags(ios_base::fmtflags __mask) + { return { __mask }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) + { + __is.setf(ios_base::fmtflags(0), __f._M_mask); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f) + { + __os.setf(ios_base::fmtflags(0), __f._M_mask); + return __os; + } + + + struct _Setiosflags { ios_base::fmtflags _M_mask; }; + + /** + * @brief Manipulator for @c setf. + * @param __mask A format flags mask. + * + * Sent to a stream object, this manipulator sets the format flags + * to @a __mask. + */ + inline _Setiosflags + setiosflags(ios_base::fmtflags __mask) + { return { __mask }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f) + { + __is.setf(__f._M_mask); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f) + { + __os.setf(__f._M_mask); + return __os; + } + + + struct _Setbase { int _M_base; }; + + /** + * @brief Manipulator for @c setf. + * @param __base A numeric base. + * + * Sent to a stream object, this manipulator changes the + * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base + * is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value. + */ + inline _Setbase + setbase(int __base) + { return { __base }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f) + { + __is.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : + ios_base::fmtflags(0), ios_base::basefield); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f) + { + __os.setf(__f._M_base == 8 ? ios_base::oct : + __f._M_base == 10 ? ios_base::dec : + __f._M_base == 16 ? ios_base::hex : + ios_base::fmtflags(0), ios_base::basefield); + return __os; + } + + + template + struct _Setfill { _CharT _M_c; }; + + /** + * @brief Manipulator for @c fill. + * @param __c The new fill character. + * + * Sent to a stream object, this manipulator calls @c fill(__c) for that + * object. + */ + template + inline _Setfill<_CharT> + setfill(_CharT __c) + { return { __c }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f) + { + __is.fill(__f._M_c); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f) + { + __os.fill(__f._M_c); + return __os; + } + + + struct _Setprecision { int _M_n; }; + + /** + * @brief Manipulator for @c precision. + * @param __n The new precision. + * + * Sent to a stream object, this manipulator calls @c precision(__n) for + * that object. + */ + inline _Setprecision + setprecision(int __n) + { return { __n }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f) + { + __is.precision(__f._M_n); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f) + { + __os.precision(__f._M_n); + return __os; + } + + + struct _Setw { int _M_n; }; + + /** + * @brief Manipulator for @c width. + * @param __n The new width. + * + * Sent to a stream object, this manipulator calls @c width(__n) for + * that object. + */ + inline _Setw + setw(int __n) + { return { __n }; } + + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f) + { + __is.width(__f._M_n); + return __is; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f) + { + __os.width(__f._M_n); + return __os; + } + +#if __cplusplus >= 201103L + + template + struct _Get_money { _MoneyT& _M_mon; bool _M_intl; }; + + /** + * @brief Extended manipulator for extracting money. + * @param __mon Either long double or a specialization of @c basic_string. + * @param __intl A bool indicating whether international format + * is to be used. + * + * Sent to a stream object, this manipulator extracts @a __mon. + */ + template + inline _Get_money<_MoneyT> + get_money(_MoneyT& __mon, bool __intl = false) + { return { __mon, __intl }; } + + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f) + { + typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + typedef istreambuf_iterator<_CharT, _Traits> _Iter; + typedef money_get<_CharT, _Iter> _MoneyGet; + + const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc()); + __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl, + __is, __err, __f._M_mon); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __is._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __is._M_setstate(ios_base::badbit); } + if (__err) + __is.setstate(__err); + } + return __is; + } + + + template + struct _Put_money { const _MoneyT& _M_mon; bool _M_intl; }; + + /** + * @brief Extended manipulator for inserting money. + * @param __mon Either long double or a specialization of @c basic_string. + * @param __intl A bool indicating whether international format + * is to be used. + * + * Sent to a stream object, this manipulator inserts @a __mon. + */ + template + inline _Put_money<_MoneyT> + put_money(const _MoneyT& __mon, bool __intl = false) + { return { __mon, __intl }; } + + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f) + { + typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + typedef ostreambuf_iterator<_CharT, _Traits> _Iter; + typedef money_put<_CharT, _Iter> _MoneyPut; + + const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc()); + if (__mp.put(_Iter(__os.rdbuf()), __f._M_intl, __os, + __os.fill(), __f._M_mon).failed()) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + __os._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __os._M_setstate(ios_base::badbit); } + if (__err) + __os.setstate(__err); + } + return __os; + } + + template + struct _Put_time + { + const std::tm* _M_tmb; + const _CharT* _M_fmt; + }; + + /** + * @brief Extended manipulator for formatting time. + * + * This manipulator uses time_put::put to format time. + * [ext.manip] + * + * @param __tmb struct tm time data to format. + * @param __fmt format string. + */ + template + inline _Put_time<_CharT> + put_time(const std::tm* __tmb, const _CharT* __fmt) + { return { __tmb, __fmt }; } + + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f) + { + typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + typedef ostreambuf_iterator<_CharT, _Traits> _Iter; + typedef time_put<_CharT, _Iter> _TimePut; + + const _CharT* const __fmt_end = __f._M_fmt + + _Traits::length(__f._M_fmt); + + const _TimePut& __mp = use_facet<_TimePut>(__os.getloc()); + if (__mp.put(_Iter(__os.rdbuf()), __os, __os.fill(), + __f._M_tmb, __f._M_fmt, __fmt_end).failed()) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + __os._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __os._M_setstate(ios_base::badbit); } + if (__err) + __os.setstate(__err); + } + return __os; + } + + template + struct _Get_time + { + std::tm* _M_tmb; + const _CharT* _M_fmt; + }; + + /** + * @brief Extended manipulator for extracting time. + * + * This manipulator uses time_get::get to extract time. + * [ext.manip] + * + * @param __tmb struct to extract the time data to. + * @param __fmt format string. + */ + template + inline _Get_time<_CharT> + get_time(std::tm* __tmb, const _CharT* __fmt) + { return { __tmb, __fmt }; } + + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f) + { + typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + typedef istreambuf_iterator<_CharT, _Traits> _Iter; + typedef time_get<_CharT, _Iter> _TimeGet; + + const _CharT* const __fmt_end = __f._M_fmt + + _Traits::length(__f._M_fmt); + + const _TimeGet& __mg = use_facet<_TimeGet>(__is.getloc()); + __mg.get(_Iter(__is.rdbuf()), _Iter(), __is, + __err, __f._M_tmb, __f._M_fmt, __fmt_end); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __is._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __is._M_setstate(ios_base::badbit); } + if (__err) + __is.setstate(__err); + } + return __is; + } + +#if __cplusplus >= 201402L + +#define __cpp_lib_quoted_string_io 201304L + + /** + * @brief Manipulator for quoted strings. + * @param __string String to quote. + * @param __delim Character to quote string with. + * @param __escape Escape character to escape itself or quote character. + */ + template + inline auto + quoted(const _CharT* __string, + _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) + { + return __detail::_Quoted_string(__string, __delim, + __escape); + } + + template + inline auto + quoted(const basic_string<_CharT, _Traits, _Alloc>& __string, + _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) + { + return __detail::_Quoted_string< + const basic_string<_CharT, _Traits, _Alloc>&, _CharT>( + __string, __delim, __escape); + } + + template + inline auto + quoted(basic_string<_CharT, _Traits, _Alloc>& __string, + _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) + { + return __detail::_Quoted_string< + basic_string<_CharT, _Traits, _Alloc>&, _CharT>( + __string, __delim, __escape); + } + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2785. quoted should work with basic_string_view + template + inline auto + quoted(basic_string_view<_CharT, _Traits> __sv, + _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) + { + return __detail::_Quoted_string< + basic_string_view<_CharT, _Traits>, _CharT>(__sv, __delim, __escape); + } +#endif // C++17 +#endif // C++14 + +#endif // __cplusplus >= 201103L + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. + // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template ostream& operator<<(ostream&, _Setfill); + extern template ostream& operator<<(ostream&, _Setiosflags); + extern template ostream& operator<<(ostream&, _Resetiosflags); + extern template ostream& operator<<(ostream&, _Setbase); + extern template ostream& operator<<(ostream&, _Setprecision); + extern template ostream& operator<<(ostream&, _Setw); + extern template istream& operator>>(istream&, _Setfill); + extern template istream& operator>>(istream&, _Setiosflags); + extern template istream& operator>>(istream&, _Resetiosflags); + extern template istream& operator>>(istream&, _Setbase); + extern template istream& operator>>(istream&, _Setprecision); + extern template istream& operator>>(istream&, _Setw); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wostream& operator<<(wostream&, _Setfill); + extern template wostream& operator<<(wostream&, _Setiosflags); + extern template wostream& operator<<(wostream&, _Resetiosflags); + extern template wostream& operator<<(wostream&, _Setbase); + extern template wostream& operator<<(wostream&, _Setprecision); + extern template wostream& operator<<(wostream&, _Setw); + extern template wistream& operator>>(wistream&, _Setfill); + extern template wistream& operator>>(wistream&, _Setiosflags); + extern template wistream& operator>>(wistream&, _Resetiosflags); + extern template wistream& operator>>(wistream&, _Setbase); + extern template wistream& operator>>(wistream&, _Setprecision); + extern template wistream& operator>>(wistream&, _Setw); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_IOMANIP */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip.blob new file mode 100644 index 0000000000000000000000000000000000000000..94f487eef8bd252bb5483f8ac630a7329a2f5a0d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iomanip.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios new file mode 100644 index 0000000000000000000000000000000000000000..50a66cd9886e262d8ccfd89c15fb7d36f9951cce --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios @@ -0,0 +1,46 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ios + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.4 Iostreams base classes +// + +#ifndef _GLIBCXX_IOS +#define _GLIBCXX_IOS 1 + +#pragma GCC system_header + +#include +#include // For ios_base::failure +#include // For char_traits, streamoff, streamsize, fpos +#include // For class locale +#include // For ios_base declarations. +#include +#include + +#endif /* _GLIBCXX_IOS */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios.blob new file mode 100644 index 0000000000000000000000000000000000000000..7c5844570100cb3cf3cd88ba3d54edfdc3d813e7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ios.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd new file mode 100644 index 0000000000000000000000000000000000000000..ddf0c953856c797ad3909de86306b0f52891e8fb --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd @@ -0,0 +1,256 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/iosfwd + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.2 Forward declarations +// + +#ifndef _GLIBCXX_IOSFWD +#define _GLIBCXX_IOSFWD 1 + +#pragma GCC system_header + +#include +#include // For string forward declarations. +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup io I/O + * + * Nearly all of the I/O classes are parameterized on the type of + * characters they read and write. (The major exception is ios_base at + * the top of the hierarchy.) This is a change from pre-Standard + * streams, which were not templates. + * + * For ease of use and compatibility, all of the basic_* I/O-related + * classes are given typedef names for both of the builtin character + * widths (wide and narrow). The typedefs are the same as the + * pre-Standard names, for example: + * + * @code + * typedef basic_ifstream ifstream; + * @endcode + * + * Because properly forward-declaring these classes can be difficult, you + * should not do it yourself. Instead, include the <iosfwd> + * header, which contains only declarations of all the I/O classes as + * well as the typedefs. Trying to forward-declare the typedefs + * themselves (e.g., class ostream;) is not valid ISO C++. + * + * For more specific declarations, see + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects + * + * @{ + */ + class ios_base; + + template > + class basic_ios; + + template > + class basic_streambuf; + + template > + class basic_istream; + + template > + class basic_ostream; + + template > + class basic_iostream; + + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + template, + typename _Alloc = allocator<_CharT> > + class basic_stringbuf; + + template, + typename _Alloc = allocator<_CharT> > + class basic_istringstream; + + template, + typename _Alloc = allocator<_CharT> > + class basic_ostringstream; + + template, + typename _Alloc = allocator<_CharT> > + class basic_stringstream; + +_GLIBCXX_END_NAMESPACE_CXX11 + + template > + class basic_filebuf; + + template > + class basic_ifstream; + + template > + class basic_ofstream; + + template > + class basic_fstream; + + template > + class istreambuf_iterator; + + template > + class ostreambuf_iterator; + + + /// Base class for @c char streams. + typedef basic_ios ios; + + /// Base class for @c char buffers. + typedef basic_streambuf streambuf; + + /// Base class for @c char input streams. + typedef basic_istream istream; + + /// Base class for @c char output streams. + typedef basic_ostream ostream; + + /// Base class for @c char mixed input and output streams. + typedef basic_iostream iostream; + + /// Class for @c char memory buffers. + typedef basic_stringbuf stringbuf; + + /// Class for @c char input memory streams. + typedef basic_istringstream istringstream; + + /// Class for @c char output memory streams. + typedef basic_ostringstream ostringstream; + + /// Class for @c char mixed input and output memory streams. + typedef basic_stringstream stringstream; + + /// Class for @c char file buffers. + typedef basic_filebuf filebuf; + + /// Class for @c char input file streams. + typedef basic_ifstream ifstream; + + /// Class for @c char output file streams. + typedef basic_ofstream ofstream; + + /// Class for @c char mixed input and output file streams. + typedef basic_fstream fstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + /// Base class for @c wchar_t streams. + typedef basic_ios wios; + + /// Base class for @c wchar_t buffers. + typedef basic_streambuf wstreambuf; + + /// Base class for @c wchar_t input streams. + typedef basic_istream wistream; + + /// Base class for @c wchar_t output streams. + typedef basic_ostream wostream; + + /// Base class for @c wchar_t mixed input and output streams. + typedef basic_iostream wiostream; + + /// Class for @c wchar_t memory buffers. + typedef basic_stringbuf wstringbuf; + + /// Class for @c wchar_t input memory streams. + typedef basic_istringstream wistringstream; + + /// Class for @c wchar_t output memory streams. + typedef basic_ostringstream wostringstream; + + /// Class for @c wchar_t mixed input and output memory streams. + typedef basic_stringstream wstringstream; + + /// Class for @c wchar_t file buffers. + typedef basic_filebuf wfilebuf; + + /// Class for @c wchar_t input file streams. + typedef basic_ifstream wifstream; + + /// Class for @c wchar_t output file streams. + typedef basic_ofstream wofstream; + + /// Class for @c wchar_t mixed input and output file streams. + typedef basic_fstream wfstream; +#endif + +#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI + template, + typename _Allocator = allocator<_CharT>> + class basic_syncbuf; + template, + typename _Allocator = allocator<_CharT>> + class basic_osyncstream; + + using syncbuf = basic_syncbuf; + using osyncstream = basic_osyncstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + using wsyncbuf = basic_syncbuf; + using wosyncstream = basic_osyncstream; +#endif +#endif // C++20 && CXX11_ABI + +#if __cplusplus > 202002L + template> + class basic_spanbuf; + template> + class basic_ispanstream; + template> + class basic_ospanstream; + template> + class basic_spanstream; + + using spanbuf = basic_spanbuf; + using ispanstream = basic_ispanstream; + using ospanstream = basic_ospanstream; + using spanstream = basic_spanstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + using wspanbuf = basic_spanbuf; + using wispanstream = basic_ispanstream; + using wospanstream = basic_ospanstream; + using wspanstream = basic_spanstream; +#endif +#endif // C++23 + + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_IOSFWD */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd.blob new file mode 100644 index 0000000000000000000000000000000000000000..dc1457ab64e9a76a5b6ccdcec44b29a21894afb6 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iosfwd.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream new file mode 100644 index 0000000000000000000000000000000000000000..d705913f53c61f12754ad745edd635e8d897dbd8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream @@ -0,0 +1,79 @@ +// Standard iostream objects -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/iostream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.3 Standard iostream objects +// + +#ifndef _GLIBCXX_IOSTREAM +#define _GLIBCXX_IOSTREAM 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @name Standard Stream Objects + * + * The <iostream> header declares the eight standard stream + * objects. For other declarations, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html + * and the @link iosfwd I/O forward declarations @endlink + * + * They are required by default to cooperate with the global C + * library's @c FILE streams, and to be available during program + * startup and termination. For more information, see the section of the + * manual linked to above. + */ + ///@{ + extern istream cin; /// Linked to standard input + extern ostream cout; /// Linked to standard output + extern ostream cerr; /// Linked to standard error (unbuffered) + extern ostream clog; /// Linked to standard error (buffered) + +#ifdef _GLIBCXX_USE_WCHAR_T + extern wistream wcin; /// Linked to standard input + extern wostream wcout; /// Linked to standard output + extern wostream wcerr; /// Linked to standard error (unbuffered) + extern wostream wclog; /// Linked to standard error (buffered) +#endif + ///@} + + // For construction of filebuffers for cout, cin, cerr, clog et. al. + static ios_base::Init __ioinit; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_IOSTREAM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream.blob new file mode 100644 index 0000000000000000000000000000000000000000..6ea926cde5f6645f1bbc20a8136a6740e10fdecf Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iostream.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream new file mode 100644 index 0000000000000000000000000000000000000000..416ef556fa1703a27103302249ddae79f0b30ed6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream @@ -0,0 +1,1018 @@ +// Input streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 27.6.1 Input streams +// + +/** @file include/istream + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ISTREAM +#define _GLIBCXX_ISTREAM 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Template class basic_istream. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This is the base class for all input streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual input. + */ + template + class basic_istream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios (27.4.4)): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_ios<_CharT, _Traits> __ios_type; + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > + __num_get_type; + typedef ctype<_CharT> __ctype_type; + + protected: + // Data Members: + /** + * The number of characters extracted in the previous unformatted + * function; see gcount(). + */ + streamsize _M_gcount; + + public: + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ + explicit + basic_istream(__streambuf_type* __sb) + : _M_gcount(streamsize(0)) + { this->init(__sb); } + + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ + virtual + ~basic_istream() + { _M_gcount = streamsize(0); } + + /// Safe prefix/suffix operations. + class sentry; + friend class sentry; + + ///@{ + /** + * @brief Interface for manipulators. + * + * Manipulators such as @c std::ws and @c std::dec use these + * functions in constructs like + * std::cin >> std::ws. + * For more information, see the iomanip header. + */ + __istream_type& + operator>>(__istream_type& (*__pf)(__istream_type&)) + { return __pf(*this); } + + __istream_type& + operator>>(__ios_type& (*__pf)(__ios_type&)) + { + __pf(*this); + return *this; + } + + __istream_type& + operator>>(ios_base& (*__pf)(ios_base&)) + { + __pf(*this); + return *this; + } + ///@} + + ///@{ + /** + * @name Extractors + * + * All the @c operator>> functions (aka formatted input + * functions) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_istream::sentry + * with the second argument (noskipws) set to false. This has several + * effects, concluding with the setting of a status flag; see the + * sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state (without causing an + * ios_base::failure to be thrown) and the original exception will + * be rethrown if badbit is set in the exceptions mask. + */ + + ///@{ + /** + * @brief Integer arithmetic extractors + * @param __n A variable of builtin integral type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to parse the input data. + */ + __istream_type& + operator>>(bool& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(short& __n); + + __istream_type& + operator>>(unsigned short& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(int& __n); + + __istream_type& + operator>>(unsigned int& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(long& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(unsigned long& __n) + { return _M_extract(__n); } + +#ifdef _GLIBCXX_USE_LONG_LONG + __istream_type& + operator>>(long long& __n) + { return _M_extract(__n); } + + __istream_type& + operator>>(unsigned long long& __n) + { return _M_extract(__n); } +#endif + ///@} + + ///@{ + /** + * @brief Floating point arithmetic extractors + * @param __f A variable of builtin floating point type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to parse the input data. + */ + __istream_type& + operator>>(float& __f) + { return _M_extract(__f); } + + __istream_type& + operator>>(double& __f) + { return _M_extract(__f); } + + __istream_type& + operator>>(long double& __f) + { return _M_extract(__f); } + ///@} + + /** + * @brief Basic arithmetic extractors + * @param __p A variable of pointer type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to parse the input data. + */ + __istream_type& + operator>>(void*& __p) + { return _M_extract(__p); } + + /** + * @brief Extracting into another streambuf. + * @param __sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry object and has the same error + * handling behavior. + * + * If @p __sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from this stream and inserted into the + * @p __sb streambuf until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs (and in this case is caught) + * + * If the function inserts no characters, failbit is set. + */ + __istream_type& + operator>>(__streambuf_type* __sb); + ///@} + + // [27.6.1.3] unformatted input + /** + * @brief Character counting + * @return The number of characters extracted by the previous + * unformatted input function dispatched for this stream. + */ + streamsize + gcount() const + { return _M_gcount; } + + ///@{ + /** + * @name Unformatted Input Functions + * + * All the unformatted input functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_istream::sentry with the second argument (noskipws) + * set to true. This has several effects, concluding with the + * setting of a status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to extract + * whatever data is appropriate for the type of the argument. + * + * The number of characters extracted is stored for later retrieval + * by gcount(). + * + * If an exception is thrown during extraction, ios_base::badbit + * will be turned on in the stream's error state (without causing an + * ios_base::failure to be thrown) and the original exception will + * be rethrown if badbit is set in the exceptions mask. + */ + + /** + * @brief Simple extraction. + * @return A character, or eof(). + * + * Tries to extract a character. If none are available, sets failbit + * and returns traits::eof(). + */ + int_type + get(); + + /** + * @brief Simple extraction. + * @param __c The character in which to store data. + * @return *this + * + * Tries to extract a character and store it in @a __c. If none are + * available, sets failbit and returns traits::eof(). + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + get(char_type& __c); + + /** + * @brief Simple multiple-character extraction. + * @param __s Pointer to an array. + * @param __n Maximum number of characters to store in @a __s. + * @param __delim A "stop" character. + * @return *this + * + * Characters are extracted and stored into @a __s until one of the + * following happens: + * + * - @c __n-1 characters are stored + * - the input sequence reaches EOF + * - the next character equals @a __delim, in which case the character + * is not extracted + * + * If no characters are stored, failbit is set in the stream's error + * state. + * + * In any case, a null character is stored into the next location in + * the array. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + get(char_type* __s, streamsize __n, char_type __delim); + + /** + * @brief Simple multiple-character extraction. + * @param __s Pointer to an array. + * @param __n Maximum number of characters to store in @a s. + * @return *this + * + * Returns @c get(__s,__n,widen('\\n')). + */ + __istream_type& + get(char_type* __s, streamsize __n) + { return this->get(__s, __n, this->widen('\n')); } + + /** + * @brief Extraction into another streambuf. + * @param __sb A streambuf in which to store data. + * @param __delim A "stop" character. + * @return *this + * + * Characters are extracted and inserted into @a __sb until one of the + * following happens: + * + * - the input sequence reaches EOF + * - insertion into the output buffer fails (in this case, the + * character that would have been inserted is not extracted) + * - the next character equals @a __delim (in this case, the character + * is not extracted) + * - an exception occurs (and in this case is caught) + * + * If no characters are stored, failbit is set in the stream's error + * state. + */ + __istream_type& + get(__streambuf_type& __sb, char_type __delim); + + /** + * @brief Extraction into another streambuf. + * @param __sb A streambuf in which to store data. + * @return *this + * + * Returns @c get(__sb,widen('\\n')). + */ + __istream_type& + get(__streambuf_type& __sb) + { return this->get(__sb, this->widen('\n')); } + + /** + * @brief String extraction. + * @param __s A character array in which to store the data. + * @param __n Maximum number of characters to extract. + * @param __delim A "stop" character. + * @return *this + * + * Extracts and stores characters into @a __s until one of the + * following happens. Note that these criteria are required to be + * tested in the order listed here, to allow an input line to exactly + * fill the @a __s array without setting failbit. + * + * -# the input sequence reaches end-of-file, in which case eofbit + * is set in the stream error state + * -# the next character equals @c __delim, in which case the character + * is extracted (and therefore counted in @c gcount()) but not stored + * -# @c __n-1 characters are stored, in which case failbit is set + * in the stream error state + * + * If no characters are extracted, failbit is set. (An empty line of + * input should therefore not cause failbit to be set.) + * + * In any case, a null character is stored in the next location in + * the array. + */ + __istream_type& + getline(char_type* __s, streamsize __n, char_type __delim); + + /** + * @brief String extraction. + * @param __s A character array in which to store the data. + * @param __n Maximum number of characters to extract. + * @return *this + * + * Returns @c getline(__s,__n,widen('\\n')). + */ + __istream_type& + getline(char_type* __s, streamsize __n) + { return this->getline(__s, __n, this->widen('\n')); } + + /** + * @brief Discarding characters + * @param __n Number of characters to discard. + * @param __delim A "stop" character. + * @return *this + * + * Extracts characters and throws them away until one of the + * following happens: + * - if @a __n @c != @c std::numeric_limits::max(), @a __n + * characters are extracted + * - the input sequence reaches end-of-file + * - the next character equals @a __delim (in this case, the character + * is extracted); note that this condition will never occur if + * @a __delim equals @c traits::eof(). + * + * NB: Provide three overloads, instead of the single function + * (with defaults) mandated by the Standard: this leads to a + * better performing implementation, while still conforming to + * the Standard. + */ + __istream_type& + ignore(streamsize __n, int_type __delim); + + __istream_type& + ignore(streamsize __n); + + __istream_type& + ignore(); + + /** + * @brief Looking ahead in the stream + * @return The next character, or eof(). + * + * If, after constructing the sentry object, @c good() is false, + * returns @c traits::eof(). Otherwise reads but does not extract + * the next input character. + */ + int_type + peek(); + + /** + * @brief Extraction without delimiters. + * @param __s A character array. + * @param __n Maximum number of characters to store. + * @return *this + * + * If the stream state is @c good(), extracts characters and stores + * them into @a __s until one of the following happens: + * - @a __n characters are stored + * - the input sequence reaches end-of-file, in which case the error + * state is set to @c failbit|eofbit. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __istream_type& + read(char_type* __s, streamsize __n); + + /** + * @brief Extraction until the buffer is exhausted, but no more. + * @param __s A character array. + * @param __n Maximum number of characters to store. + * @return The number of characters extracted. + * + * Extracts characters and stores them into @a __s depending on the + * number of characters remaining in the streambuf's buffer, + * @c rdbuf()->in_avail(), called @c A here: + * - if @c A @c == @c -1, sets eofbit and extracts no characters + * - if @c A @c == @c 0, extracts no characters + * - if @c A @c > @c 0, extracts @c min(A,n) + * + * The goal is to empty the current buffer, and to not request any + * more from the external input sequence controlled by the streambuf. + */ + streamsize + readsome(char_type* __s, streamsize __n); + + /** + * @brief Unextracting a single character. + * @param __c The character to push back into the input stream. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c). + * + * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in + * the error state. + * + * @note This function first clears eofbit. Since no characters + * are extracted, the next call to @c gcount() will return 0, + * as required by DR 60. + */ + __istream_type& + putback(char_type __c); + + /** + * @brief Unextracting the previous character. + * @return *this + * + * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c). + * + * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in + * the error state. + * + * @note This function first clears eofbit. Since no characters + * are extracted, the next call to @c gcount() will return 0, + * as required by DR 60. + */ + __istream_type& + unget(); + + /** + * @brief Synchronizing the stream buffer. + * @return 0 on success, -1 on failure + * + * If @c rdbuf() is a null pointer, returns -1. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit and returns -1. + * + * Otherwise, returns 0. + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). + */ + int + sync(); + + /** + * @brief Getting the current read position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in). + * + * @note This function does not count the number of characters + * extracted, if any, and therefore does not affect the next + * call to @c gcount(). At variance with putback, unget and + * seekg, eofbit is not cleared first. + */ + pos_type + tellg(); + + /** + * @brief Changing the current read position. + * @param __pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(__pos). If + * that function fails, sets failbit. + * + * @note This function first clears eofbit. It does not count the + * number of characters extracted, if any, and therefore does + * not affect the next call to @c gcount(). + */ + __istream_type& + seekg(pos_type); + + /** + * @brief Changing the current read position. + * @param __off A file offset object. + * @param __dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(__off,__dir). + * If that function fails, sets failbit. + * + * @note This function first clears eofbit. It does not count the + * number of characters extracted, if any, and therefore does + * not affect the next call to @c gcount(). + */ + __istream_type& + seekg(off_type, ios_base::seekdir); + ///@} + + protected: + basic_istream() + : _M_gcount(streamsize(0)) + { this->init(0); } + +#if __cplusplus >= 201103L + basic_istream(const basic_istream&) = delete; + + basic_istream(basic_istream&& __rhs) + : __ios_type(), _M_gcount(__rhs._M_gcount) + { + __ios_type::move(__rhs); + __rhs._M_gcount = 0; + } + + // 27.7.3.3 Assign/swap + + basic_istream& operator=(const basic_istream&) = delete; + + basic_istream& + operator=(basic_istream&& __rhs) + { + swap(__rhs); + return *this; + } + + void + swap(basic_istream& __rhs) + { + __ios_type::swap(__rhs); + std::swap(_M_gcount, __rhs._M_gcount); + } +#endif + + template + __istream_type& + _M_extract(_ValueT& __v); + }; + + /// Explicit specialization declarations, defined in src/istream.cc. + template<> + basic_istream& + basic_istream:: + getline(char_type* __s, streamsize __n, char_type __delim); + + template<> + basic_istream& + basic_istream:: + ignore(streamsize __n); + + template<> + basic_istream& + basic_istream:: + ignore(streamsize __n, int_type __delim); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + basic_istream& + basic_istream:: + getline(char_type* __s, streamsize __n, char_type __delim); + + template<> + basic_istream& + basic_istream:: + ignore(streamsize __n); + + template<> + basic_istream& + basic_istream:: + ignore(streamsize __n, int_type __delim); +#endif + + /** + * @brief Performs setup work for input streams. + * + * Objects of this class are created before all of the standard + * extractors are run. It is responsible for exception-safe + * prefix and suffix operations, although only prefix actions + * are currently required by the standard. + */ + template + class basic_istream<_CharT, _Traits>::sentry + { + // Data Members. + bool _M_ok; + + public: + /// Easy access to dependent types. + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::__ctype_type __ctype_type; + typedef typename _Traits::int_type __int_type; + + /** + * @brief The constructor performs all the work. + * @param __is The input stream to guard. + * @param __noskipws Whether to consume whitespace or not. + * + * If the stream state is good (@a __is.good() is true), then the + * following actions are performed, otherwise the sentry state + * is false (not okay) and failbit is set in the + * stream state. + * + * The sentry's preparatory actions are: + * + * -# if the stream is tied to an output stream, @c is.tie()->flush() + * is called to synchronize the output sequence + * -# if @a __noskipws is false, and @c ios_base::skipws is set in + * @c is.flags(), the sentry extracts and discards whitespace + * characters from the stream. The currently imbued locale is + * used to determine whether each character is whitespace. + * + * If the stream state is still good, then the sentry state becomes + * true (@a okay). + */ + explicit + sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); + + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ +#if __cplusplus >= 201103L + explicit +#endif + operator bool() const + { return _M_ok; } + }; + + ///@{ + /** + * @brief Character extractors + * @param __in An input stream. + * @param __c A character reference. + * @return in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts a character (if one is available) and + * stores it in @a __c. Otherwise, sets failbit in the input stream. + */ + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c); + + template + inline basic_istream& + operator>>(basic_istream& __in, unsigned char& __c) + { return (__in >> reinterpret_cast(__c)); } + + template + inline basic_istream& + operator>>(basic_istream& __in, signed char& __c) + { return (__in >> reinterpret_cast(__c)); } + ///@} + + + template + void + __istream_extract(basic_istream<_CharT, _Traits>&, _CharT*, streamsize); + + void __istream_extract(istream&, char*, streamsize); + + ///@{ + /** + * @brief Character string extractors + * @param __in An input stream. + * @param __s A character array (or a pointer to an array before C++20). + * @return __in + * + * Behaves like one of the formatted arithmetic extractors described in + * `std::basic_istream`. After constructing a sentry object with good + * status, this function extracts up to `n` characters and stores them + * into the array `__s`. `n` is defined as: + * + * - if `width()` is greater than zero, `n` is `min(width(), n)` + * - otherwise `n` is the number of elements of the array + * - (before C++20 the pointer is assumed to point to an array of + * the largest possible size for an array of `char_type`). + * + * Characters are extracted and stored until one of the following happens: + * - `n - 1` characters are stored + * - EOF is reached + * - the next character is whitespace according to the current locale + * + * `width(0)` is then called for the input stream. + * + * If no characters are extracted, sets failbit. + */ + +#if __cplusplus <= 201703L + template + __attribute__((__nonnull__(2), __access__(__write_only__, 2))) + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) + { +#ifdef __OPTIMIZE__ + // Function inlining might make the buffer size known, allowing us to + // prevent overflow. + size_t __n = __builtin_object_size(__s, 0); + if (__n < sizeof(_CharT)) + { + // There is not even space for the required null terminator. + __glibcxx_assert(__n >= sizeof(_CharT)); + // No point calling __istream_extract, but still need to reset width. + __in.width(0); + __in.setstate(ios_base::failbit); + } + else if (__n != (size_t)-1) + { + __n /= sizeof(_CharT); + streamsize __w = __in.width(); + std::__istream_extract(__in, __s, __n); + if (__in.good() && (__w <= 0 || __n < __w)) + { + // Stopped extracting early to avoid overflowing the buffer, + // but might have stopped anyway (and set eofbit) if at EOF. + const typename _Traits::int_type __c = __in.rdbuf()->sgetc(); + const bool __eof = _Traits::eq_int_type(__c, _Traits::eof()); + if (__builtin_expect(__eof, true)) // Assume EOF, not overflow. + __in.setstate(ios_base::eofbit); + } + } + else +#endif // __OPTIMIZE + { + // Buffer size is unknown, have to assume it's huge. + streamsize __n = __gnu_cxx::__numeric_traits::__max; + __n /= sizeof(_CharT); + std::__istream_extract(__in, __s, __n); + } + return __in; + } + + template + __attribute__((__nonnull__(2), __access__(__write_only__, 2))) + inline basic_istream& + operator>>(basic_istream& __in, unsigned char* __s) + { return __in >> reinterpret_cast(__s); } + + template + __attribute__((__nonnull__(2), __access__(__write_only__, 2))) + inline basic_istream& + operator>>(basic_istream& __in, signed char* __s) + { return __in >> reinterpret_cast(__s); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2499. operator>>(istream&, char*) makes it hard to avoid buffer overflows + template + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT (&__s)[_Num]) + { + static_assert(_Num <= __gnu_cxx::__numeric_traits::__max); + std::__istream_extract(__in, __s, _Num); + return __in; + } + + template + inline basic_istream& + operator>>(basic_istream& __in, unsigned char (&__s)[_Num]) + { return __in >> reinterpret_cast(__s); } + + template + inline basic_istream& + operator>>(basic_istream& __in, signed char (&__s)[_Num]) + { return __in >> reinterpret_cast(__s); } +#endif + ///@} + + /** + * @brief Template class basic_iostream + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This class multiply inherits from the input and output stream classes + * simply to provide a single interface. + */ + template + class basic_iostream + : public basic_istream<_CharT, _Traits>, + public basic_ostream<_CharT, _Traits> + { + public: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 271. basic_iostream missing typedefs + // Types (inherited): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_ostream<_CharT, _Traits> __ostream_type; + + /** + * @brief Constructor does nothing. + * + * Both of the parent classes are initialized with the same + * streambuf pointer passed to this constructor. + */ + explicit + basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) + : __istream_type(__sb), __ostream_type(__sb) { } + + /** + * @brief Destructor does nothing. + */ + virtual + ~basic_iostream() { } + + protected: + basic_iostream() + : __istream_type(), __ostream_type() { } + +#if __cplusplus >= 201103L + basic_iostream(const basic_iostream&) = delete; + + basic_iostream(basic_iostream&& __rhs) + : __istream_type(std::move(__rhs)), __ostream_type(*this) + { } + + // 27.7.3.3 Assign/swap + + basic_iostream& operator=(const basic_iostream&) = delete; + + basic_iostream& + operator=(basic_iostream&& __rhs) + { + swap(__rhs); + return *this; + } + + void + swap(basic_iostream& __rhs) + { __istream_type::swap(__rhs); } +#endif + }; + + /** + * @brief Quick and easy way to eat whitespace + * + * This manipulator extracts whitespace characters, stopping when the + * next character is non-whitespace, or when the input sequence is empty. + * If the sequence is empty, @c eofbit is set in the stream, but not + * @c failbit. + * + * The current locale is used to distinguish whitespace characters. + * + * Example: + * @code + * MyClass mc; + * + * std::cin >> std::ws >> mc; + * @endcode + * will skip leading whitespace before calling operator>> on cin and your + * object. Note that the same effect can be achieved by creating a + * std::basic_istream::sentry inside your definition of operator>>. + */ + template + basic_istream<_CharT, _Traits>& + ws(basic_istream<_CharT, _Traits>& __is); + +#if __cplusplus >= 201103L + // C++11 27.7.2.6 Rvalue stream extraction [istream.rvalue] + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2328. Rvalue stream extraction should use perfect forwarding + // 1203. More useful rvalue stream insertion + +#if __cpp_lib_concepts + template + requires __derived_from_ios_base<_Is> + && requires (_Is& __is, _Tp&& __t) { __is >> std::forward<_Tp>(__t); } + using __rvalue_stream_extraction_t = _Is&&; +#else + template, + typename = decltype(std::declval<_Is&>() >> std::declval<_Tp>())> + using __rvalue_stream_extraction_t = _Is&&; +#endif + + /** + * @brief Generic extractor for rvalue stream + * @param __is An input stream. + * @param __x A reference to the extraction target. + * @return __is + * + * This is just a forwarding function to allow extraction from + * rvalue streams since they won't bind to the extractor functions + * that take an lvalue reference. + */ + template + inline __rvalue_stream_extraction_t<_Istream, _Tp> + operator>>(_Istream&& __is, _Tp&& __x) + { + __is >> std::forward<_Tp>(__x); + return std::move(__is); + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _GLIBCXX_ISTREAM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream.blob new file mode 100644 index 0000000000000000000000000000000000000000..4d2ea2001e7715135c51a4391406cca2529fe860 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@istream.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator new file mode 100644 index 0000000000000000000000000000000000000000..7f8fc50b39d25e866fef017df0684bdc183e5a92 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator @@ -0,0 +1,73 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/iterator + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ITERATOR +#define _GLIBCXX_ITERATOR 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303 +# define __cpp_lib_null_iterators 201304L +#endif + +#endif /* _GLIBCXX_ITERATOR */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator.blob new file mode 100644 index 0000000000000000000000000000000000000000..a49b588d3afc5408e87f61817288fef436a72b97 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@iterator.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits new file mode 100644 index 0000000000000000000000000000000000000000..66201fa621533a682b6411956f20c8c6fdbba29a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits @@ -0,0 +1,1903 @@ +// The template and inlines for the numeric_limits classes. -*- C++ -*- + +// Copyright (C) 1999-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/limits + * This is a Standard C++ Library header. + */ + +// Note: this is not a conforming implementation. +// Written by Gabriel Dos Reis + +// +// ISO 14882:1998 +// 18.2.1 +// + +#ifndef _GLIBCXX_NUMERIC_LIMITS +#define _GLIBCXX_NUMERIC_LIMITS 1 + +#pragma GCC system_header + +#include + +// +// The numeric_limits<> traits document implementation-defined aspects +// of fundamental arithmetic data types (integers and floating points). +// From Standard C++ point of view, there are 14 such types: +// * integers +// bool (1) +// char, signed char, unsigned char, wchar_t (4) +// short, unsigned short (2) +// int, unsigned (2) +// long, unsigned long (2) +// +// * floating points +// float (1) +// double (1) +// long double (1) +// +// GNU C++ understands (where supported by the host C-library) +// * integer +// long long, unsigned long long (2) +// +// which brings us to 16 fundamental arithmetic data types in GNU C++. +// +// +// Since a numeric_limits<> is a bit tricky to get right, we rely on +// an interface composed of macros which should be defined in config/os +// or config/cpu when they differ from the generic (read arbitrary) +// definitions given here. +// + +// These values can be overridden in the target configuration file. +// The default values are appropriate for many 32-bit targets. + +// GCC only intrinsically supports modulo integral types. The only remaining +// integral exceptional values is division by zero. Only targets that do not +// signal division by zero in some "hard to ignore" way should use false. +#ifndef __glibcxx_integral_traps +# define __glibcxx_integral_traps true +#endif + +// float +// + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_float_has_denorm_loss +# define __glibcxx_float_has_denorm_loss false +#endif +#ifndef __glibcxx_float_traps +# define __glibcxx_float_traps false +#endif +#ifndef __glibcxx_float_tinyness_before +# define __glibcxx_float_tinyness_before false +#endif + +// double + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_double_has_denorm_loss +# define __glibcxx_double_has_denorm_loss false +#endif +#ifndef __glibcxx_double_traps +# define __glibcxx_double_traps false +#endif +#ifndef __glibcxx_double_tinyness_before +# define __glibcxx_double_tinyness_before false +#endif + +// long double + +// Default values. Should be overridden in configuration files if necessary. + +#ifndef __glibcxx_long_double_has_denorm_loss +# define __glibcxx_long_double_has_denorm_loss false +#endif +#ifndef __glibcxx_long_double_traps +# define __glibcxx_long_double_traps false +#endif +#ifndef __glibcxx_long_double_tinyness_before +# define __glibcxx_long_double_tinyness_before false +#endif + +// You should not need to define any macros below this point. + +#define __glibcxx_signed_b(T,B) ((T)(-1) < 0) + +#define __glibcxx_min_b(T,B) \ + (__glibcxx_signed_b (T,B) ? -__glibcxx_max_b (T,B) - 1 : (T)0) + +#define __glibcxx_max_b(T,B) \ + (__glibcxx_signed_b (T,B) ? \ + (((((T)1 << (__glibcxx_digits_b (T,B) - 1)) - 1) << 1) + 1) : ~(T)0) + +#define __glibcxx_digits_b(T,B) \ + (B - __glibcxx_signed_b (T,B)) + +// The fraction 643/2136 approximates log10(2) to 7 significant digits. +#define __glibcxx_digits10_b(T,B) \ + (__glibcxx_digits_b (T,B) * 643L / 2136) + +#define __glibcxx_signed(T) \ + __glibcxx_signed_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_min(T) \ + __glibcxx_min_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_max(T) \ + __glibcxx_max_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_digits(T) \ + __glibcxx_digits_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_digits10(T) \ + __glibcxx_digits10_b (T, sizeof(T) * __CHAR_BIT__) + +#define __glibcxx_max_digits10(T) \ + (2 + (T) * 643L / 2136) + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Describes the rounding style for floating-point types. + * + * This is used in the std::numeric_limits class. + */ + enum float_round_style + { + round_indeterminate = -1, /// Intermediate. + round_toward_zero = 0, /// To zero. + round_to_nearest = 1, /// To the nearest representable value. + round_toward_infinity = 2, /// To infinity. + round_toward_neg_infinity = 3 /// To negative infinity. + }; + + /** + * @brief Describes the denormalization for floating-point types. + * + * These values represent the presence or absence of a variable number + * of exponent bits. This type is used in the std::numeric_limits class. + */ + enum float_denorm_style + { + /// Indeterminate at compile time whether denormalized values are allowed. + denorm_indeterminate = -1, + /// The type does not allow denormalized values. + denorm_absent = 0, + /// The type allows denormalized values. + denorm_present = 1 + }; + + /** + * @brief Part of std::numeric_limits. + * + * The @c static @c const members are usable as integral constant + * expressions. + * + * @note This is a separate class for purposes of efficiency; you + * should only access these members as part of an instantiation + * of the std::numeric_limits class. + */ + struct __numeric_limits_base + { + /** This will be true for all fundamental types (which have + specializations), and false for everything else. */ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = false; + + /** The number of @c radix digits that be represented without change: for + integer types, the number of non-sign bits in the mantissa; for + floating types, the number of @c radix digits in the mantissa. */ + static _GLIBCXX_USE_CONSTEXPR int digits = 0; + + /** The number of base 10 digits that can be represented without change. */ + static _GLIBCXX_USE_CONSTEXPR int digits10 = 0; + +#if __cplusplus >= 201103L + /** The number of base 10 digits required to ensure that values which + differ are always differentiated. */ + static constexpr int max_digits10 = 0; +#endif + + /** True if the type is signed. */ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + + /** True if the type is integer. */ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; + + /** True if the type uses an exact representation. All integer types are + exact, but not all exact types are integer. For example, rational and + fixed-exponent representations are exact but not integer. */ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; + + /** For integer types, specifies the base of the representation. For + floating types, specifies the base of the exponent representation. */ + static _GLIBCXX_USE_CONSTEXPR int radix = 0; + + /** The minimum negative integer such that @c radix raised to the power of + (one less than that integer) is a normalized floating point number. */ + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + + /** The minimum negative integer such that 10 raised to that power is in + the range of normalized floating point numbers. */ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + + /** The maximum positive integer such that @c radix raised to the power of + (one less than that integer) is a representable finite floating point + number. */ + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + + /** The maximum positive integer such that 10 raised to that power is in + the range of representable finite floating point numbers. */ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + /** True if the type has a representation for positive infinity. */ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + + /** True if the type has a representation for a quiet (non-signaling) + Not a Number. */ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + + /** True if the type has a representation for a signaling + Not a Number. */ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + + /** See std::float_denorm_style for more information. */ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent; + + /** True if loss of accuracy is detected as a denormalization loss, + rather than as an inexact result. */ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + /** True if-and-only-if the type adheres to the IEC 559 standard, also + known as IEEE 754. (Only makes sense for floating point types.) */ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + + /** True if the set of values representable by the type is + finite. All built-in types are bounded, this member would be + false for arbitrary precision types. */ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = false; + + /** True if the type is @e modulo. A type is modulo if, for any + operation involving +, -, or * on values of that type whose + result would fall outside the range [min(),max()], the value + returned differs from the true value by an integer multiple of + max() - min() + 1. On most machines, this is false for floating + types, true for unsigned integers, and true for signed integers. + See PR22200 about signed integers. */ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + /** True if trapping is implemented for this type. */ + static _GLIBCXX_USE_CONSTEXPR bool traps = false; + + /** True if tininess is detected before rounding. (see IEC 559) */ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + + /** See std::float_round_style for more information. This is only + meaningful for floating types; integer types will all be + round_toward_zero. */ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = + round_toward_zero; + }; + + /** + * @brief Properties of fundamental types. + * + * This class allows a program to obtain information about the + * representation of a fundamental type on a given platform. For + * non-fundamental types, the functions will return 0 and the data + * members will all be @c false. + */ + template + struct numeric_limits : public __numeric_limits_base + { + /** The minimum finite value, or for floating types with + denormalization, the minimum positive normalized value. */ + static _GLIBCXX_CONSTEXPR _Tp + min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The maximum finite value. */ + static _GLIBCXX_CONSTEXPR _Tp + max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + +#if __cplusplus >= 201103L + /** A finite value x such that there is no other finite value y + * where y < x. */ + static constexpr _Tp + lowest() noexcept { return _Tp(); } +#endif + + /** The @e machine @e epsilon: the difference between 1 and the least + value greater than 1 that is representable. */ + static _GLIBCXX_CONSTEXPR _Tp + epsilon() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The maximum rounding error measurement (see LIA-1). */ + static _GLIBCXX_CONSTEXPR _Tp + round_error() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The representation of positive infinity, if @c has_infinity. */ + static _GLIBCXX_CONSTEXPR _Tp + infinity() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The representation of a quiet Not a Number, + if @c has_quiet_NaN. */ + static _GLIBCXX_CONSTEXPR _Tp + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The representation of a signaling Not a Number, if + @c has_signaling_NaN. */ + static _GLIBCXX_CONSTEXPR _Tp + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + + /** The minimum positive denormalized value. For types where + @c has_denorm is false, this is the minimum positive normalized + value. */ + static _GLIBCXX_CONSTEXPR _Tp + denorm_min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 559. numeric_limits + + template + struct numeric_limits + : public numeric_limits<_Tp> { }; + + template + struct numeric_limits + : public numeric_limits<_Tp> { }; + + template + struct numeric_limits + : public numeric_limits<_Tp> { }; + + // Now there follow 16 explicit specializations. Yes, 16. Make sure + // you get the count right. (18 in C++11 mode, with char16_t and char32_t.) + // (+1 if char8_t is enabled.) + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 184. numeric_limits wording problems + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR bool + min() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_CONSTEXPR bool + max() _GLIBCXX_USE_NOEXCEPT { return true; } + +#if __cplusplus >= 201103L + static constexpr bool + lowest() noexcept { return min(); } +#endif + static _GLIBCXX_USE_CONSTEXPR int digits = 1; + static _GLIBCXX_USE_CONSTEXPR int digits10 = 0; +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR bool + epsilon() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_CONSTEXPR bool + round_error() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR bool + infinity() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_CONSTEXPR bool + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_CONSTEXPR bool + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_CONSTEXPR bool + denorm_min() _GLIBCXX_USE_NOEXCEPT { return false; } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + // It is not clear what it means for a boolean type to trap. + // This is a DR on the LWG issue list. Here, I use integer + // promotion semantics. + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR char + min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); } + + static _GLIBCXX_CONSTEXPR char + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); } + +#if __cplusplus >= 201103L + static constexpr char + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (char); + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (char); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (char); + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR char + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR char + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR + char infinity() _GLIBCXX_USE_NOEXCEPT { return char(); } + + static _GLIBCXX_CONSTEXPR char + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } + + static _GLIBCXX_CONSTEXPR char + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); } + + static _GLIBCXX_CONSTEXPR char + denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR signed char + min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; } + + static _GLIBCXX_CONSTEXPR signed char + max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; } + +#if __cplusplus >= 201103L + static constexpr signed char + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (signed char); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (signed char); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR signed char + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR signed char + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR signed char + infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR signed char + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR signed char + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR signed char + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR unsigned char + min() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned char + max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; } + +#if __cplusplus >= 201103L + static constexpr unsigned char + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (unsigned char); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (unsigned char); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR unsigned char + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned char + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR unsigned char + infinity() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned char + quiet_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned char + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned char + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR wchar_t + min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); } + + static _GLIBCXX_CONSTEXPR wchar_t + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); } + +#if __cplusplus >= 201103L + static constexpr wchar_t + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (wchar_t); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (wchar_t); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (wchar_t); + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR wchar_t + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR wchar_t + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR wchar_t + infinity() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } + + static _GLIBCXX_CONSTEXPR wchar_t + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } + + static _GLIBCXX_CONSTEXPR wchar_t + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } + + static _GLIBCXX_CONSTEXPR wchar_t + denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + +#if _GLIBCXX_USE_CHAR8_T + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR char8_t + min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (char8_t); } + + static _GLIBCXX_CONSTEXPR char8_t + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (char8_t); } + + static _GLIBCXX_CONSTEXPR char8_t + lowest() _GLIBCXX_USE_NOEXCEPT { return min(); } + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (char8_t); + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (char8_t); + static _GLIBCXX_USE_CONSTEXPR int max_digits10 = 0; + static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (char8_t); + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR char8_t + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR char8_t + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR char8_t + infinity() _GLIBCXX_USE_NOEXCEPT { return char8_t(); } + + static _GLIBCXX_CONSTEXPR char8_t + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char8_t(); } + + static _GLIBCXX_CONSTEXPR char8_t + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char8_t(); } + + static _GLIBCXX_CONSTEXPR char8_t + denorm_min() _GLIBCXX_USE_NOEXCEPT { return char8_t(); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; +#endif + +#if __cplusplus >= 201103L + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static constexpr bool is_specialized = true; + + static constexpr char16_t + min() noexcept { return __glibcxx_min (char16_t); } + + static constexpr char16_t + max() noexcept { return __glibcxx_max (char16_t); } + + static constexpr char16_t + lowest() noexcept { return min(); } + + static constexpr int digits = __glibcxx_digits (char16_t); + static constexpr int digits10 = __glibcxx_digits10 (char16_t); + static constexpr int max_digits10 = 0; + static constexpr bool is_signed = __glibcxx_signed (char16_t); + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr int radix = 2; + + static constexpr char16_t + epsilon() noexcept { return 0; } + + static constexpr char16_t + round_error() noexcept { return 0; } + + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr float_denorm_style has_denorm = denorm_absent; + static constexpr bool has_denorm_loss = false; + + static constexpr char16_t + infinity() noexcept { return char16_t(); } + + static constexpr char16_t + quiet_NaN() noexcept { return char16_t(); } + + static constexpr char16_t + signaling_NaN() noexcept { return char16_t(); } + + static constexpr char16_t + denorm_min() noexcept { return char16_t(); } + + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = !is_signed; + + static constexpr bool traps = __glibcxx_integral_traps; + static constexpr bool tinyness_before = false; + static constexpr float_round_style round_style = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static constexpr bool is_specialized = true; + + static constexpr char32_t + min() noexcept { return __glibcxx_min (char32_t); } + + static constexpr char32_t + max() noexcept { return __glibcxx_max (char32_t); } + + static constexpr char32_t + lowest() noexcept { return min(); } + + static constexpr int digits = __glibcxx_digits (char32_t); + static constexpr int digits10 = __glibcxx_digits10 (char32_t); + static constexpr int max_digits10 = 0; + static constexpr bool is_signed = __glibcxx_signed (char32_t); + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr int radix = 2; + + static constexpr char32_t + epsilon() noexcept { return 0; } + + static constexpr char32_t + round_error() noexcept { return 0; } + + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr float_denorm_style has_denorm = denorm_absent; + static constexpr bool has_denorm_loss = false; + + static constexpr char32_t + infinity() noexcept { return char32_t(); } + + static constexpr char32_t + quiet_NaN() noexcept { return char32_t(); } + + static constexpr char32_t + signaling_NaN() noexcept { return char32_t(); } + + static constexpr char32_t + denorm_min() noexcept { return char32_t(); } + + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = !is_signed; + + static constexpr bool traps = __glibcxx_integral_traps; + static constexpr bool tinyness_before = false; + static constexpr float_round_style round_style = round_toward_zero; + }; +#endif + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR short + min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; } + + static _GLIBCXX_CONSTEXPR short + max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; } + +#if __cplusplus >= 201103L + static constexpr short + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (short); + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (short); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR short + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR short + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR short + infinity() _GLIBCXX_USE_NOEXCEPT { return short(); } + + static _GLIBCXX_CONSTEXPR short + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } + + static _GLIBCXX_CONSTEXPR short + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); } + + static _GLIBCXX_CONSTEXPR short + denorm_min() _GLIBCXX_USE_NOEXCEPT { return short(); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR unsigned short + min() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned short + max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; } + +#if __cplusplus >= 201103L + static constexpr unsigned short + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (unsigned short); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (unsigned short); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR unsigned short + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned short + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR unsigned short + infinity() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned short + quiet_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned short + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned short + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR int + min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; } + + static _GLIBCXX_CONSTEXPR int + max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; } + +#if __cplusplus >= 201103L + static constexpr int + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (int); + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (int); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR int + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR int + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR int + infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR int + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR int + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR int + denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR unsigned int + min() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned int + max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; } + +#if __cplusplus >= 201103L + static constexpr unsigned int + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (unsigned int); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (unsigned int); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR unsigned int + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned int + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR unsigned int + infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned int + quiet_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned int + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned int + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR long + min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; } + + static _GLIBCXX_CONSTEXPR long + max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; } + +#if __cplusplus >= 201103L + static constexpr long + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long); + static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR long + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR long + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR long + infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long + denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR unsigned long + min() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned long + max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; } + +#if __cplusplus >= 201103L + static constexpr unsigned long + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (unsigned long); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (unsigned long); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR unsigned long + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned long + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR unsigned long + infinity() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long + quiet_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR long long + min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; } + + static _GLIBCXX_CONSTEXPR long long + max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; } + +#if __cplusplus >= 201103L + static constexpr long long + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (long long); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (long long); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR long long + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR long long + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR long long + infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long long + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long long + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR long long + denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR unsigned long long + min() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned long long + max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; } + +#if __cplusplus >= 201103L + static constexpr unsigned long long + lowest() noexcept { return min(); } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits + = __glibcxx_digits (unsigned long long); + static _GLIBCXX_USE_CONSTEXPR int digits10 + = __glibcxx_digits10 (unsigned long long); +#if __cplusplus >= 201103L + static constexpr int max_digits10 = 0; +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; + static _GLIBCXX_USE_CONSTEXPR int radix = 2; + + static _GLIBCXX_CONSTEXPR unsigned long long + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_CONSTEXPR unsigned long long + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; + + static _GLIBCXX_CONSTEXPR unsigned long long + infinity() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long long + quiet_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long long + signaling_NaN() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_CONSTEXPR unsigned long long + denorm_min() _GLIBCXX_USE_NOEXCEPT + { return static_cast(0); } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_toward_zero; + }; + +#define __INT_N(TYPE, BITSIZE, EXT, UEXT) \ + __extension__ \ + template<> \ + struct numeric_limits \ + { \ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min_b (TYPE, BITSIZE); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max_b (TYPE, BITSIZE); } \ + \ + static _GLIBCXX_USE_CONSTEXPR int digits \ + = BITSIZE - 1; \ + static _GLIBCXX_USE_CONSTEXPR int digits10 \ + = (BITSIZE - 1) * 643L / 2136; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \ + static _GLIBCXX_USE_CONSTEXPR int radix = 2; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + EXT \ + \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \ + = denorm_absent; \ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + infinity() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + quiet_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + signaling_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + denorm_min() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool traps \ + = __glibcxx_integral_traps; \ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \ + = round_toward_zero; \ + }; \ + \ + __extension__ \ + template<> \ + struct numeric_limits \ + { \ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + min() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + max() _GLIBCXX_USE_NOEXCEPT \ + { return __glibcxx_max_b (unsigned TYPE, BITSIZE); } \ + \ + UEXT \ + \ + static _GLIBCXX_USE_CONSTEXPR int digits \ + = BITSIZE; \ + static _GLIBCXX_USE_CONSTEXPR int digits10 \ + = BITSIZE * 643L / 2136; \ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \ + static _GLIBCXX_USE_CONSTEXPR int radix = 2; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \ + = denorm_absent; \ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + infinity() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + quiet_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + signaling_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + denorm_min() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast(0); } \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; \ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \ + = round_toward_zero; \ + }; + +#if __cplusplus >= 201103L + +#define __INT_N_201103(TYPE) \ + static constexpr TYPE \ + lowest() noexcept { return min(); } \ + static constexpr int max_digits10 = 0; + +#define __INT_N_U201103(TYPE) \ + static constexpr unsigned TYPE \ + lowest() noexcept { return min(); } \ + static constexpr int max_digits10 = 0; + +#else +#define __INT_N_201103(TYPE) +#define __INT_N_U201103(TYPE) +#endif + +#if !defined(__STRICT_ANSI__) +#ifdef __GLIBCXX_TYPE_INT_N_0 + __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_0), + __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_0)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + __INT_N (__GLIBCXX_TYPE_INT_N_1, __GLIBCXX_BITSIZE_INT_N_1, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_1), + __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_1)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + __INT_N (__GLIBCXX_TYPE_INT_N_2, __GLIBCXX_BITSIZE_INT_N_2, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_2), + __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_2)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + __INT_N (__GLIBCXX_TYPE_INT_N_3, __GLIBCXX_BITSIZE_INT_N_3, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_3), + __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_3)) +#endif + +#elif defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + __INT_N(__int128, 128, + __INT_N_201103 (__int128), + __INT_N_U201103 (__int128)) +#endif + +#undef __INT_N +#undef __INT_N_201103 +#undef __INT_N_U201103 + + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR float + min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; } + + static _GLIBCXX_CONSTEXPR float + max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; } + +#if __cplusplus >= 201103L + static constexpr float + lowest() noexcept { return -__FLT_MAX__; } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __FLT_MANT_DIG__; + static _GLIBCXX_USE_CONSTEXPR int digits10 = __FLT_DIG__; +#if __cplusplus >= 201103L + static constexpr int max_digits10 + = __glibcxx_max_digits10 (__FLT_MANT_DIG__); +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; + static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; + + static _GLIBCXX_CONSTEXPR float + epsilon() _GLIBCXX_USE_NOEXCEPT { return __FLT_EPSILON__; } + + static _GLIBCXX_CONSTEXPR float + round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = __FLT_MIN_EXP__; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __FLT_MIN_10_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = __FLT_MAX_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __FLT_MAX_10_EXP__; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __FLT_HAS_INFINITY__; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss + = __glibcxx_float_has_denorm_loss; + + static _GLIBCXX_CONSTEXPR float + infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_valf(); } + + static _GLIBCXX_CONSTEXPR float + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanf(""); } + + static _GLIBCXX_CONSTEXPR float + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansf(""); } + + static _GLIBCXX_CONSTEXPR float + denorm_min() _GLIBCXX_USE_NOEXCEPT { return __FLT_DENORM_MIN__; } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_float_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before + = __glibcxx_float_tinyness_before; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_to_nearest; + }; + +#undef __glibcxx_float_has_denorm_loss +#undef __glibcxx_float_traps +#undef __glibcxx_float_tinyness_before + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR double + min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; } + + static _GLIBCXX_CONSTEXPR double + max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; } + +#if __cplusplus >= 201103L + static constexpr double + lowest() noexcept { return -__DBL_MAX__; } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __DBL_MANT_DIG__; + static _GLIBCXX_USE_CONSTEXPR int digits10 = __DBL_DIG__; +#if __cplusplus >= 201103L + static constexpr int max_digits10 + = __glibcxx_max_digits10 (__DBL_MANT_DIG__); +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; + static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; + + static _GLIBCXX_CONSTEXPR double + epsilon() _GLIBCXX_USE_NOEXCEPT { return __DBL_EPSILON__; } + + static _GLIBCXX_CONSTEXPR double + round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = __DBL_MIN_EXP__; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __DBL_MIN_10_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = __DBL_MAX_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __DBL_MAX_10_EXP__; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __DBL_HAS_INFINITY__; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss + = __glibcxx_double_has_denorm_loss; + + static _GLIBCXX_CONSTEXPR double + infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_val(); } + + static _GLIBCXX_CONSTEXPR double + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nan(""); } + + static _GLIBCXX_CONSTEXPR double + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nans(""); } + + static _GLIBCXX_CONSTEXPR double + denorm_min() _GLIBCXX_USE_NOEXCEPT { return __DBL_DENORM_MIN__; } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_double_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before + = __glibcxx_double_tinyness_before; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style + = round_to_nearest; + }; + +#undef __glibcxx_double_has_denorm_loss +#undef __glibcxx_double_traps +#undef __glibcxx_double_tinyness_before + + /// numeric_limits specialization. + template<> + struct numeric_limits + { + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; + + static _GLIBCXX_CONSTEXPR long double + min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; } + + static _GLIBCXX_CONSTEXPR long double + max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; } + +#if __cplusplus >= 201103L + static constexpr long double + lowest() noexcept { return -__LDBL_MAX__; } +#endif + + static _GLIBCXX_USE_CONSTEXPR int digits = __LDBL_MANT_DIG__; + static _GLIBCXX_USE_CONSTEXPR int digits10 = __LDBL_DIG__; +#if __cplusplus >= 201103L + static _GLIBCXX_USE_CONSTEXPR int max_digits10 + = __glibcxx_max_digits10 (__LDBL_MANT_DIG__); +#endif + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; + static _GLIBCXX_USE_CONSTEXPR bool is_integer = false; + static _GLIBCXX_USE_CONSTEXPR bool is_exact = false; + static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__; + + static _GLIBCXX_CONSTEXPR long double + epsilon() _GLIBCXX_USE_NOEXCEPT { return __LDBL_EPSILON__; } + + static _GLIBCXX_CONSTEXPR long double + round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5L; } + + static _GLIBCXX_USE_CONSTEXPR int min_exponent = __LDBL_MIN_EXP__; + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __LDBL_MIN_10_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent = __LDBL_MAX_EXP__; + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __LDBL_MAX_10_EXP__; + + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __LDBL_HAS_INFINITY__; + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__; + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN; + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm + = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent; + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss + = __glibcxx_long_double_has_denorm_loss; + + static _GLIBCXX_CONSTEXPR long double + infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_vall(); } + + static _GLIBCXX_CONSTEXPR long double + quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanl(""); } + + static _GLIBCXX_CONSTEXPR long double + signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansl(""); } + + static _GLIBCXX_CONSTEXPR long double + denorm_min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_DENORM_MIN__; } + + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; + + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_long_double_traps; + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = + __glibcxx_long_double_tinyness_before; + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style = + round_to_nearest; + }; + +#undef __glibcxx_long_double_has_denorm_loss +#undef __glibcxx_long_double_traps +#undef __glibcxx_long_double_tinyness_before + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#undef __glibcxx_signed +#undef __glibcxx_min +#undef __glibcxx_max +#undef __glibcxx_digits +#undef __glibcxx_digits10 +#undef __glibcxx_max_digits10 + +#endif // _GLIBCXX_NUMERIC_LIMITS diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits.blob new file mode 100644 index 0000000000000000000000000000000000000000..4d275e8e373718bac0ab310e6051313604d71ff7 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@limits.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list new file mode 100644 index 0000000000000000000000000000000000000000..d7ef94317b19e6dd0a8879c398b14751ff91cd63 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list @@ -0,0 +1,109 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/list + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_LIST +#define _GLIBCXX_LIST 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template + using list = std::list<_Tp, polymorphic_allocator<_Tp>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + inline typename list<_Tp, _Alloc>::size_type + erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred) + { return __cont.remove_if(__pred); } + + template + inline typename list<_Tp, _Alloc>::size_type + erase(list<_Tp, _Alloc>& __cont, const _Up& __value) + { + using __elem_type = typename list<_Tp, _Alloc>::value_type; + return std::erase_if(__cont, [&](__elem_type& __elem) { + return __elem == __value; + }); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_LIST */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list.blob new file mode 100644 index 0000000000000000000000000000000000000000..d27f26ab25807ce685fa8aaae50f2bec0e2cadf5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@list.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale new file mode 100644 index 0000000000000000000000000000000000000000..ae83586d6682b2fd6b51c621e774aaf2d4e67b15 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale @@ -0,0 +1,46 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 22.1 Locales +// + +/** @file include/locale + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_LOCALE +#define _GLIBCXX_LOCALE 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#if __cplusplus >= 201103L +# include +#endif + +#endif /* _GLIBCXX_LOCALE */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale.blob new file mode 100644 index 0000000000000000000000000000000000000000..64e1fcbf9b2dd1027f7092a9aa3e47a530b07d64 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@locale.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map new file mode 100644 index 0000000000000000000000000000000000000000..93c956af916654d68b5df98d7a989c62138cef45 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map @@ -0,0 +1,117 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/map + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MAP +#define _GLIBCXX_MAP 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template> + using map + = std::map<_Key, _Tp, _Cmp, + polymorphic_allocator>>; + template> + using multimap + = std::multimap<_Key, _Tp, _Cmp, + polymorphic_allocator>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline typename map<_Key, _Tp, _Compare, _Alloc>::size_type + erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) + { + const _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } + + template + inline typename multimap<_Key, _Tp, _Compare, _Alloc>::size_type + erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) + { + const _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_MAP */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map.blob new file mode 100644 index 0000000000000000000000000000000000000000..cf80687a026edacbffec9f1e3ef0c65d2daaac77 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@map.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory new file mode 100644 index 0000000000000000000000000000000000000000..481fa42a6188e40a6daf88d5fd53f56feb7e3c50 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory @@ -0,0 +1,151 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file include/memory + * This is a Standard C++ Library header. + * @ingroup memory + */ + +#ifndef _GLIBCXX_MEMORY +#define _GLIBCXX_MEMORY 1 + +#pragma GCC system_header + +/** + * @defgroup memory Memory + * @ingroup utilities + * + * Components for memory allocation, deallocation, and management. + */ + +/** + * @defgroup pointer_abstractions Pointer Abstractions + * @ingroup memory + * + * Smart pointers, etc. + */ + +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +#if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED +# include +#endif + +#if __cplusplus > 201703L +# include +# include +#endif + +#if __cplusplus >= 201103L && __cplusplus <= 202002L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** @defgroup ptr_safety Pointer Safety and Garbage Collection + * @ingroup memory + * + * Utilities to assist with garbage collection in an implementation + * that supports strict pointer safety. + * This implementation only supports relaxed pointer safety + * and so these functions have no effect. + * + * C++11 20.6.4 [util.dynamic.safety], Pointer safety + * + * @{ + */ + +/// Constants representing the different types of pointer safety. +enum class pointer_safety { relaxed, preferred, strict }; + +/// Inform a garbage collector that an object is still in use. +inline void +declare_reachable(void*) { } + +/// Unregister an object previously registered with declare_reachable. +template + inline _Tp* + undeclare_reachable(_Tp* __p) { return __p; } + +/// Inform a garbage collector that a region of memory need not be traced. +inline void +declare_no_pointers(char*, size_t) { } + +/// Unregister a range previously registered with declare_no_pointers. +inline void +undeclare_no_pointers(char*, size_t) { } + +/// The type of pointer safety supported by the implementation. +inline pointer_safety +get_pointer_safety() noexcept { return pointer_safety::relaxed; } +/// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 to C++20 + +#if __cplusplus >= 201703L +// Parallel STL algorithms +# if _PSTL_EXECUTION_POLICIES_DEFINED +// If has already been included, pull in implementations +# include +# else +// Otherwise just pull in forward declarations +# include +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +#endif // C++17 + +#endif /* _GLIBCXX_MEMORY */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory.blob new file mode 100644 index 0000000000000000000000000000000000000000..bd4e83e01d6f0e39f571e8bbb80ea2711f93f623 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@memory.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex new file mode 100644 index 0000000000000000000000000000000000000000..f500818d9c9ea1d1657ccd895d69825886bb0d9f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex @@ -0,0 +1,969 @@ +// -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/mutex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_MUTEX +#define _GLIBCXX_MUTEX 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include +#if ! _GTHREAD_USE_MUTEX_TIMEDLOCK +# include +# include +#endif +#include // __gnu_cxx::__is_single_threaded + +#if defined _GLIBCXX_HAS_GTHREADS && ! defined _GLIBCXX_HAVE_TLS +# include // std::function +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup mutexes + * @{ + */ + +#ifdef _GLIBCXX_HAS_GTHREADS + + // Common base class for std::recursive_mutex and std::recursive_timed_mutex + class __recursive_mutex_base + { + protected: + typedef __gthread_recursive_mutex_t __native_type; + + __recursive_mutex_base(const __recursive_mutex_base&) = delete; + __recursive_mutex_base& operator=(const __recursive_mutex_base&) = delete; + +#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT + __native_type _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT; + + __recursive_mutex_base() = default; +#else + __native_type _M_mutex; + + __recursive_mutex_base() + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); + } + + ~__recursive_mutex_base() + { __gthread_recursive_mutex_destroy(&_M_mutex); } +#endif + }; + + /// The standard recursive mutex type. + class recursive_mutex : private __recursive_mutex_base + { + public: + typedef __native_type* native_handle_type; + + recursive_mutex() = default; + ~recursive_mutex() = default; + + recursive_mutex(const recursive_mutex&) = delete; + recursive_mutex& operator=(const recursive_mutex&) = delete; + + void + lock() + { + int __e = __gthread_recursive_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() noexcept + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_recursive_mutex_trylock(&_M_mutex); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_recursive_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() noexcept + { return &_M_mutex; } + }; + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK + template + class __timed_mutex_impl + { + protected: + template + bool + _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { +#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK + using __clock = chrono::steady_clock; +#else + using __clock = chrono::system_clock; +#endif + + auto __rt = chrono::duration_cast<__clock::duration>(__rtime); + if (ratio_greater<__clock::period, _Period>()) + ++__rt; + return _M_try_lock_until(__clock::now() + __rt); + } + + template + bool + _M_try_lock_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + return static_cast<_Derived*>(this)->_M_timedlock(__ts); + } + +#ifdef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK + template + bool + _M_try_lock_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + return static_cast<_Derived*>(this)->_M_clocklock(CLOCK_MONOTONIC, + __ts); + } +#endif + + template + bool + _M_try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + // The user-supplied clock may not tick at the same rate as + // steady_clock, so we must loop in order to guarantee that + // the timeout has expired before returning false. + auto __now = _Clock::now(); + do { + auto __rtime = __atime - __now; + if (_M_try_lock_for(__rtime)) + return true; + __now = _Clock::now(); + } while (__atime > __now); + return false; + } + }; + + /// The standard timed mutex type. + class timed_mutex + : private __mutex_base, public __timed_mutex_impl + { + public: + typedef __native_type* native_handle_type; + + timed_mutex() = default; + ~timed_mutex() = default; + + timed_mutex(const timed_mutex&) = delete; + timed_mutex& operator=(const timed_mutex&) = delete; + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() noexcept + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { return _M_try_lock_for(__rtime); } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { return _M_try_lock_until(__atime); } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() noexcept + { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } + +#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK + bool + _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts) + { return !pthread_mutex_clocklock(&_M_mutex, clockid, &__ts); } +#endif + }; + + /// recursive_timed_mutex + class recursive_timed_mutex + : private __recursive_mutex_base, + public __timed_mutex_impl + { + public: + typedef __native_type* native_handle_type; + + recursive_timed_mutex() = default; + ~recursive_timed_mutex() = default; + + recursive_timed_mutex(const recursive_timed_mutex&) = delete; + recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; + + void + lock() + { + int __e = __gthread_recursive_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() noexcept + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_recursive_mutex_trylock(&_M_mutex); + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { return _M_try_lock_for(__rtime); } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { return _M_try_lock_until(__atime); } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EBUSY + __gthread_recursive_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() noexcept + { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } + +#ifdef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK + bool + _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts) + { return !pthread_mutex_clocklock(&_M_mutex, clockid, &__ts); } +#endif + }; + +#else // !_GTHREAD_USE_MUTEX_TIMEDLOCK + + /// timed_mutex + class timed_mutex + { + mutex _M_mut; + condition_variable _M_cv; + bool _M_locked = false; + + public: + + timed_mutex() = default; + ~timed_mutex() { __glibcxx_assert( !_M_locked ); } + + timed_mutex(const timed_mutex&) = delete; + timed_mutex& operator=(const timed_mutex&) = delete; + + void + lock() + { + unique_lock __lk(_M_mut); + _M_cv.wait(__lk, [&]{ return !_M_locked; }); + _M_locked = true; + } + + bool + try_lock() + { + lock_guard __lk(_M_mut); + if (_M_locked) + return false; + _M_locked = true; + return true; + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + unique_lock __lk(_M_mut); + if (!_M_cv.wait_for(__lk, __rtime, [&]{ return !_M_locked; })) + return false; + _M_locked = true; + return true; + } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + unique_lock __lk(_M_mut); + if (!_M_cv.wait_until(__lk, __atime, [&]{ return !_M_locked; })) + return false; + _M_locked = true; + return true; + } + + void + unlock() + { + lock_guard __lk(_M_mut); + __glibcxx_assert( _M_locked ); + _M_locked = false; + _M_cv.notify_one(); + } + }; + + /// recursive_timed_mutex + class recursive_timed_mutex + { + mutex _M_mut; + condition_variable _M_cv; + thread::id _M_owner; + unsigned _M_count = 0; + + // Predicate type that tests whether the current thread can lock a mutex. + struct _Can_lock + { + // Returns true if the mutex is unlocked or is locked by _M_caller. + bool + operator()() const noexcept + { return _M_mx->_M_count == 0 || _M_mx->_M_owner == _M_caller; } + + const recursive_timed_mutex* _M_mx; + thread::id _M_caller; + }; + + public: + + recursive_timed_mutex() = default; + ~recursive_timed_mutex() { __glibcxx_assert( _M_count == 0 ); } + + recursive_timed_mutex(const recursive_timed_mutex&) = delete; + recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; + + void + lock() + { + auto __id = this_thread::get_id(); + _Can_lock __can_lock{this, __id}; + unique_lock __lk(_M_mut); + _M_cv.wait(__lk, __can_lock); + if (_M_count == -1u) + __throw_system_error(EAGAIN); // [thread.timedmutex.recursive]/3 + _M_owner = __id; + ++_M_count; + } + + bool + try_lock() + { + auto __id = this_thread::get_id(); + _Can_lock __can_lock{this, __id}; + lock_guard __lk(_M_mut); + if (!__can_lock()) + return false; + if (_M_count == -1u) + return false; + _M_owner = __id; + ++_M_count; + return true; + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + auto __id = this_thread::get_id(); + _Can_lock __can_lock{this, __id}; + unique_lock __lk(_M_mut); + if (!_M_cv.wait_for(__lk, __rtime, __can_lock)) + return false; + if (_M_count == -1u) + return false; + _M_owner = __id; + ++_M_count; + return true; + } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + auto __id = this_thread::get_id(); + _Can_lock __can_lock{this, __id}; + unique_lock __lk(_M_mut); + if (!_M_cv.wait_until(__lk, __atime, __can_lock)) + return false; + if (_M_count == -1u) + return false; + _M_owner = __id; + ++_M_count; + return true; + } + + void + unlock() + { + lock_guard __lk(_M_mut); + __glibcxx_assert( _M_owner == this_thread::get_id() ); + __glibcxx_assert( _M_count > 0 ); + if (--_M_count == 0) + { + _M_owner = {}; + _M_cv.notify_one(); + } + } + }; + +#endif +#endif // _GLIBCXX_HAS_GTHREADS + + /// @cond undocumented + namespace __detail + { + // Lock the last lockable, after all previous ones are locked. + template + inline int + __try_lock_impl(_Lockable& __l) + { + if (unique_lock<_Lockable> __lock{__l, try_to_lock}) + { + __lock.release(); + return -1; + } + else + return 0; + } + + // Lock each lockable in turn. + // Use iteration if all lockables are the same type, recursion otherwise. + template + inline int + __try_lock_impl(_L0& __l0, _Lockables&... __lockables) + { +#if __cplusplus >= 201703L + if constexpr ((is_same_v<_L0, _Lockables> && ...)) + { + constexpr int _Np = 1 + sizeof...(_Lockables); + unique_lock<_L0> __locks[_Np] = { + {__l0, defer_lock}, {__lockables, defer_lock}... + }; + for (int __i = 0; __i < _Np; ++__i) + { + if (!__locks[__i].try_lock()) + { + const int __failed = __i; + while (__i--) + __locks[__i].unlock(); + return __failed; + } + } + for (auto& __l : __locks) + __l.release(); + return -1; + } + else +#endif + if (unique_lock<_L0> __lock{__l0, try_to_lock}) + { + int __idx = __detail::__try_lock_impl(__lockables...); + if (__idx == -1) + { + __lock.release(); + return -1; + } + return __idx + 1; + } + else + return 0; + } + + } // namespace __detail + /// @endcond + + /** @brief Generic try_lock. + * @param __l1 Meets Lockable requirements (try_lock() may throw). + * @param __l2 Meets Lockable requirements (try_lock() may throw). + * @param __l3 Meets Lockable requirements (try_lock() may throw). + * @return Returns -1 if all try_lock() calls return true. Otherwise returns + * a 0-based index corresponding to the argument that returned false. + * @post Either all arguments are locked, or none will be. + * + * Sequentially calls try_lock() on each argument. + */ + template + inline int + try_lock(_L1& __l1, _L2& __l2, _L3&... __l3) + { + return __detail::__try_lock_impl(__l1, __l2, __l3...); + } + + /// @cond undocumented + namespace __detail + { + // This function can recurse up to N levels deep, for N = 1+sizeof...(L1). + // On each recursion the lockables are rotated left one position, + // e.g. depth 0: l0, l1, l2; depth 1: l1, l2, l0; depth 2: l2, l0, l1. + // When a call to l_i.try_lock() fails it recurses/returns to depth=i + // so that l_i is the first argument, and then blocks until l_i is locked. + template + void + __lock_impl(int& __i, int __depth, _L0& __l0, _L1&... __l1) + { + while (__i >= __depth) + { + if (__i == __depth) + { + int __failed = 1; // index that couldn't be locked + { + unique_lock<_L0> __first(__l0); + __failed += __detail::__try_lock_impl(__l1...); + if (!__failed) + { + __i = -1; // finished + __first.release(); + return; + } + } +#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD + __gthread_yield(); +#endif + constexpr auto __n = 1 + sizeof...(_L1); + __i = (__depth + __failed) % __n; + } + else // rotate left until l_i is first. + __detail::__lock_impl(__i, __depth + 1, __l1..., __l0); + } + } + + } // namespace __detail + /// @endcond + + /** @brief Generic lock. + * @param __l1 Meets Lockable requirements (try_lock() may throw). + * @param __l2 Meets Lockable requirements (try_lock() may throw). + * @param __l3 Meets Lockable requirements (try_lock() may throw). + * @throw An exception thrown by an argument's lock() or try_lock() member. + * @post All arguments are locked. + * + * All arguments are locked via a sequence of calls to lock(), try_lock() + * and unlock(). If this function exits via an exception any locks that + * were obtained will be released. + */ + template + void + lock(_L1& __l1, _L2& __l2, _L3&... __l3) + { +#if __cplusplus >= 201703L + if constexpr (is_same_v<_L1, _L2> && (is_same_v<_L1, _L3> && ...)) + { + constexpr int _Np = 2 + sizeof...(_L3); + unique_lock<_L1> __locks[] = { + {__l1, defer_lock}, {__l2, defer_lock}, {__l3, defer_lock}... + }; + int __first = 0; + do { + __locks[__first].lock(); + for (int __j = 1; __j < _Np; ++__j) + { + const int __idx = (__first + __j) % _Np; + if (!__locks[__idx].try_lock()) + { + for (int __k = __j; __k != 0; --__k) + __locks[(__first + __k - 1) % _Np].unlock(); + __first = __idx; + break; + } + } + } while (!__locks[__first].owns_lock()); + + for (auto& __l : __locks) + __l.release(); + } + else +#endif + { + int __i = 0; + __detail::__lock_impl(__i, 0, __l1, __l2, __l3...); + } + } + +#if __cplusplus >= 201703L +#define __cpp_lib_scoped_lock 201703L + /** @brief A scoped lock type for multiple lockable objects. + * + * A scoped_lock controls mutex ownership within a scope, releasing + * ownership in the destructor. + */ + template + class scoped_lock + { + public: + explicit scoped_lock(_MutexTypes&... __m) : _M_devices(std::tie(__m...)) + { std::lock(__m...); } + + explicit scoped_lock(adopt_lock_t, _MutexTypes&... __m) noexcept + : _M_devices(std::tie(__m...)) + { } // calling thread owns mutex + + ~scoped_lock() + { std::apply([](auto&... __m) { (__m.unlock(), ...); }, _M_devices); } + + scoped_lock(const scoped_lock&) = delete; + scoped_lock& operator=(const scoped_lock&) = delete; + + private: + tuple<_MutexTypes&...> _M_devices; + }; + + template<> + class scoped_lock<> + { + public: + explicit scoped_lock() = default; + explicit scoped_lock(adopt_lock_t) noexcept { } + ~scoped_lock() = default; + + scoped_lock(const scoped_lock&) = delete; + scoped_lock& operator=(const scoped_lock&) = delete; + }; + + template + class scoped_lock<_Mutex> + { + public: + using mutex_type = _Mutex; + + explicit scoped_lock(mutex_type& __m) : _M_device(__m) + { _M_device.lock(); } + + explicit scoped_lock(adopt_lock_t, mutex_type& __m) noexcept + : _M_device(__m) + { } // calling thread owns mutex + + ~scoped_lock() + { _M_device.unlock(); } + + scoped_lock(const scoped_lock&) = delete; + scoped_lock& operator=(const scoped_lock&) = delete; + + private: + mutex_type& _M_device; + }; +#endif // C++17 + +#ifdef _GLIBCXX_HAS_GTHREADS + /// Flag type used by std::call_once + struct once_flag + { + constexpr once_flag() noexcept = default; + + /// Deleted copy constructor + once_flag(const once_flag&) = delete; + /// Deleted assignment operator + once_flag& operator=(const once_flag&) = delete; + + private: + // For gthreads targets a pthread_once_t is used with pthread_once, but + // for most targets this doesn't work correctly for exceptional executions. + __gthread_once_t _M_once = __GTHREAD_ONCE_INIT; + + struct _Prepare_execution; + + template + friend void + call_once(once_flag& __once, _Callable&& __f, _Args&&... __args); + }; + + /// @cond undocumented +# ifdef _GLIBCXX_HAVE_TLS + // If TLS is available use thread-local state for the type-erased callable + // that is being run by std::call_once in the current thread. + extern __thread void* __once_callable; + extern __thread void (*__once_call)(); + + // RAII type to set up state for pthread_once call. + struct once_flag::_Prepare_execution + { + template + explicit + _Prepare_execution(_Callable& __c) + { + // Store address in thread-local pointer: + __once_callable = std::__addressof(__c); + // Trampoline function to invoke the closure via thread-local pointer: + __once_call = [] { (*static_cast<_Callable*>(__once_callable))(); }; + } + + ~_Prepare_execution() + { + // PR libstdc++/82481 + __once_callable = nullptr; + __once_call = nullptr; + } + + _Prepare_execution(const _Prepare_execution&) = delete; + _Prepare_execution& operator=(const _Prepare_execution&) = delete; + }; + +# else + // Without TLS use a global std::mutex and store the callable in a + // global std::function. + extern function __once_functor; + + extern void + __set_once_functor_lock_ptr(unique_lock*); + + extern mutex& + __get_once_mutex(); + + // RAII type to set up state for pthread_once call. + struct once_flag::_Prepare_execution + { + template + explicit + _Prepare_execution(_Callable& __c) + { + // Store the callable in the global std::function + __once_functor = __c; + __set_once_functor_lock_ptr(&_M_functor_lock); + } + + ~_Prepare_execution() + { + if (_M_functor_lock) + __set_once_functor_lock_ptr(nullptr); + } + + private: + // XXX This deadlocks if used recursively (PR 97949) + unique_lock _M_functor_lock{__get_once_mutex()}; + + _Prepare_execution(const _Prepare_execution&) = delete; + _Prepare_execution& operator=(const _Prepare_execution&) = delete; + }; +# endif + /// @endcond + + // This function is passed to pthread_once by std::call_once. + // It runs __once_call() or __once_functor(). + extern "C" void __once_proxy(void); + + /// Invoke a callable and synchronize with other calls using the same flag + template + void + call_once(once_flag& __once, _Callable&& __f, _Args&&... __args) + { + // Closure type that runs the function + auto __callable = [&] { + std::__invoke(std::forward<_Callable>(__f), + std::forward<_Args>(__args)...); + }; + + once_flag::_Prepare_execution __exec(__callable); + + // XXX pthread_once does not reset the flag if an exception is thrown. + if (int __e = __gthread_once(&__once._M_once, &__once_proxy)) + __throw_system_error(__e); + } + +#else // _GLIBCXX_HAS_GTHREADS + + /// Flag type used by std::call_once + struct once_flag + { + constexpr once_flag() noexcept = default; + + /// Deleted copy constructor + once_flag(const once_flag&) = delete; + /// Deleted assignment operator + once_flag& operator=(const once_flag&) = delete; + + private: + // There are two different std::once_flag interfaces, abstracting four + // different implementations. + // The single-threaded interface uses the _M_activate() and _M_finish(bool) + // functions, which start and finish an active execution respectively. + // See [thread.once.callonce] in C++11 for the definition of + // active/passive/returning/exceptional executions. + enum _Bits : int { _Init = 0, _Active = 1, _Done = 2 }; + + int _M_once = _Bits::_Init; + + // Check to see if all executions will be passive now. + bool + _M_passive() const noexcept; + + // Attempts to begin an active execution. + bool _M_activate(); + + // Must be called to complete an active execution. + // The argument is true if the active execution was a returning execution, + // false if it was an exceptional execution. + void _M_finish(bool __returning) noexcept; + + // RAII helper to call _M_finish. + struct _Active_execution + { + explicit _Active_execution(once_flag& __flag) : _M_flag(__flag) { } + + ~_Active_execution() { _M_flag._M_finish(_M_returning); } + + _Active_execution(const _Active_execution&) = delete; + _Active_execution& operator=(const _Active_execution&) = delete; + + once_flag& _M_flag; + bool _M_returning = false; + }; + + template + friend void + call_once(once_flag& __once, _Callable&& __f, _Args&&... __args); + }; + + // Inline definitions of std::once_flag members for single-threaded targets. + + inline bool + once_flag::_M_passive() const noexcept + { return _M_once == _Bits::_Done; } + + inline bool + once_flag::_M_activate() + { + if (_M_once == _Bits::_Init) [[__likely__]] + { + _M_once = _Bits::_Active; + return true; + } + else if (_M_passive()) // Caller should have checked this already. + return false; + else + __throw_system_error(EDEADLK); + } + + inline void + once_flag::_M_finish(bool __returning) noexcept + { _M_once = __returning ? _Bits::_Done : _Bits::_Init; } + + /// Invoke a callable and synchronize with other calls using the same flag + template + inline void + call_once(once_flag& __once, _Callable&& __f, _Args&&... __args) + { + if (__once._M_passive()) + return; + else if (__once._M_activate()) + { + once_flag::_Active_execution __exec(__once); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2442. call_once() shouldn't DECAY_COPY() + std::__invoke(std::forward<_Callable>(__f), + std::forward<_Args>(__args)...); + + // __f(__args...) did not throw + __exec._M_returning = true; + } + } +#endif // _GLIBCXX_HAS_GTHREADS + + /// @} group mutexes +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_MUTEX diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex.blob new file mode 100644 index 0000000000000000000000000000000000000000..a5118a2f8c9ecd9e3c506b0c73d4ea5af31fdd33 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@mutex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new new file mode 100644 index 0000000000000000000000000000000000000000..ecd82f6b2544ed265d18955c1518fd1494b6d912 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new @@ -0,0 +1,238 @@ +// The -*- C++ -*- dynamic memory management header. + +// Copyright (C) 1994-2022 Free Software Foundation, Inc. + +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file new + * This is a Standard C++ Library header. + * + * The header @c new defines several functions to manage dynamic memory and + * handling memory allocation errors; see + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/dynamic_memory.html + * for more. + */ + +#ifndef _NEW +#define _NEW + +#pragma GCC system_header + +#include +#include + +#pragma GCC visibility push(default) + +extern "C++" { + +namespace std +{ + /** + * @brief Exception possibly thrown by @c new. + * @ingroup exceptions + * + * @c bad_alloc (or classes derived from it) is used to report allocation + * errors from the throwing forms of @c new. */ + class bad_alloc : public exception + { + public: + bad_alloc() throw() { } + +#if __cplusplus >= 201103L + bad_alloc(const bad_alloc&) = default; + bad_alloc& operator=(const bad_alloc&) = default; +#endif + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_alloc() throw(); + + // See comment in eh_exception.cc. + virtual const char* what() const throw(); + }; + +#if __cplusplus >= 201103L + class bad_array_new_length : public bad_alloc + { + public: + bad_array_new_length() throw() { } + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_array_new_length() throw(); + + // See comment in eh_exception.cc. + virtual const char* what() const throw(); + }; +#endif + +#if __cpp_aligned_new + enum class align_val_t: size_t {}; +#endif + + struct nothrow_t + { +#if __cplusplus >= 201103L + explicit nothrow_t() = default; +#endif + }; + + extern const nothrow_t nothrow; + + /** If you write your own error handler to be called by @c new, it must + * be of this type. */ + typedef void (*new_handler)(); + + /// Takes a replacement handler as the argument, returns the + /// previous handler. + new_handler set_new_handler(new_handler) throw(); + +#if __cplusplus >= 201103L + /// Return the current new handler. + new_handler get_new_handler() noexcept; +#endif +} // namespace std + +//@{ +/** These are replaceable signatures: + * - normal single new and delete (no arguments, throw @c bad_alloc on error) + * - normal array new and delete (same) + * - @c nothrow single new and delete (take a @c nothrow argument, return + * @c NULL on error) + * - @c nothrow array new and delete (same) + * + * Placement new and delete signatures (take a memory address argument, + * does nothing) may not be replaced by a user's program. +*/ +_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) + __attribute__((__externally_visible__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) + __attribute__((__externally_visible__)); +void operator delete(void*) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +#if __cpp_sized_deallocation +void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +#endif +_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__)); +#if __cpp_aligned_new +_GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) + __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +_GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +void operator delete(void*, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete(void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) + __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); +void operator delete[](void*, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete[](void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +#if __cpp_sized_deallocation +void operator delete(void*, std::size_t, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete[](void*, std::size_t, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +#endif // __cpp_sized_deallocation +#endif // __cpp_aligned_new + +// Default placement versions of operator new. +_GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +{ return __p; } +_GLIBCXX_NODISCARD inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +{ return __p; } + +// Default placement versions of operator delete. +inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } +inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } +//@} +} // extern "C++" + +#if __cplusplus >= 201703L +namespace std +{ +#ifdef _GLIBCXX_HAVE_BUILTIN_LAUNDER +#define __cpp_lib_launder 201606L + /// Pointer optimization barrier [ptr.launder] + template + [[nodiscard]] constexpr _Tp* + launder(_Tp* __p) noexcept + { return __builtin_launder(__p); } + + // The program is ill-formed if T is a function type or + // (possibly cv-qualified) void. + + template + void launder(_Ret (*)(_Args...) _GLIBCXX_NOEXCEPT_QUAL) = delete; + template + void launder(_Ret (*)(_Args......) _GLIBCXX_NOEXCEPT_QUAL) = delete; + + void launder(void*) = delete; + void launder(const void*) = delete; + void launder(volatile void*) = delete; + void launder(const volatile void*) = delete; +#endif // _GLIBCXX_HAVE_BUILTIN_LAUNDER + +#ifdef __GCC_DESTRUCTIVE_SIZE +# define __cpp_lib_hardware_interference_size 201703L + inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; + inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; +#endif // __GCC_DESTRUCTIVE_SIZE +} +#endif // C++17 + +#if __cplusplus > 201703L +namespace std +{ + /// Tag type used to declare a class-specific operator delete that can + /// invoke the destructor before deallocating the memory. + struct destroying_delete_t + { + explicit destroying_delete_t() = default; + }; + /// Tag variable of type destroying_delete_t. + inline constexpr destroying_delete_t destroying_delete{}; +} +// Only define the feature test macro if the compiler supports the feature: +#if __cpp_impl_destroying_delete +# define __cpp_lib_destroying_delete 201806L +#endif +#endif // C++20 + +#pragma GCC visibility pop + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new.blob new file mode 100644 index 0000000000000000000000000000000000000000..256425f8feb3219b8c30291fa164b97917231a8b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@new.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric new file mode 100644 index 0000000000000000000000000000000000000000..60a99d18ffd5c1a38d0a3a6e9d148ec70bbe4751 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric @@ -0,0 +1,747 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/numeric + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_NUMERIC +#define _GLIBCXX_NUMERIC 1 + +#pragma GCC system_header + +#include +#include +#include + +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#if __cplusplus >= 201402L +# include +# include +# include +#endif + +#if __cplusplus >= 201703L +# include +#endif + +#if __cplusplus > 201703L +# include +#endif + +/** + * @defgroup numerics Numerics + * + * Components for performing numeric operations. Includes support for + * complex number types, random number generation, numeric (n-at-a-time) + * arrays, generalized numeric algorithms, and mathematical special functions. + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201402L +namespace __detail +{ + // Like std::abs, but supports unsigned types and returns the specified type, + // so |std::numeric_limits<_Tp>::min()| is OK if representable in _Res. + template + constexpr _Res + __abs_r(_Tp __val) + { + static_assert(sizeof(_Res) >= sizeof(_Tp), + "result type must be at least as wide as the input type"); + + if (__val >= 0) + return __val; +#ifdef _GLIBCXX_ASSERTIONS + if (!__is_constant_evaluated()) // overflow already detected in constexpr + __glibcxx_assert(__val != __gnu_cxx::__int_traits<_Res>::__min); +#endif + return -static_cast<_Res>(__val); + } + + template void __abs_r(bool) = delete; + + // GCD implementation, using Stein's algorithm + template + constexpr _Tp + __gcd(_Tp __m, _Tp __n) + { + static_assert(is_unsigned<_Tp>::value, "type must be unsigned"); + + if (__m == 0) + return __n; + if (__n == 0) + return __m; + + const int __i = std::__countr_zero(__m); + __m >>= __i; + const int __j = std::__countr_zero(__n); + __n >>= __j; + const int __k = __i < __j ? __i : __j; // min(i, j) + + while (true) + { + if (__m > __n) + { + _Tp __tmp = __m; + __m = __n; + __n = __tmp; + } + + __n -= __m; + + if (__n == 0) + return __m << __k; + + __n >>= std::__countr_zero(__n); + } + } +} // namespace __detail + +#if __cplusplus >= 201703L + +#define __cpp_lib_gcd_lcm 201606L +// These were used in drafts of SD-6: +#define __cpp_lib_gcd 201606L +#define __cpp_lib_lcm 201606L + + /// Greatest common divisor + template + constexpr common_type_t<_Mn, _Nn> + gcd(_Mn __m, _Nn __n) noexcept + { + static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>, + "std::gcd arguments must be integers"); + static_assert(_Mn(2) == 2 && _Nn(2) == 2, + "std::gcd arguments must not be bool"); + using _Ct = common_type_t<_Mn, _Nn>; + const _Ct __m2 = __detail::__abs_r<_Ct>(__m); + const _Ct __n2 = __detail::__abs_r<_Ct>(__n); + return __detail::__gcd>(__m2, __n2); + } + + /// Least common multiple + template + constexpr common_type_t<_Mn, _Nn> + lcm(_Mn __m, _Nn __n) noexcept + { + static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>, + "std::lcm arguments must be integers"); + static_assert(_Mn(2) == 2 && _Nn(2) == 2, + "std::lcm arguments must not be bool"); + using _Ct = common_type_t<_Mn, _Nn>; + const _Ct __m2 = __detail::__abs_r<_Ct>(__m); + const _Ct __n2 = __detail::__abs_r<_Ct>(__n); + if (__m2 == 0 || __n2 == 0) + return 0; + _Ct __r = __m2 / __detail::__gcd>(__m2, __n2); + + if constexpr (is_signed_v<_Ct>) + if (__is_constant_evaluated()) + return __r * __n2; // constant evaluation can detect overflow here. + + bool __overflow = __builtin_mul_overflow(__r, __n2, &__r); + __glibcxx_assert(!__overflow); + return __r; + } + +#endif // C++17 +#endif // C++14 + +#if __cplusplus > 201703L + + // midpoint +# define __cpp_lib_interpolate 201902L + + template + constexpr + enable_if_t<__and_v, is_same, _Tp>, + __not_>>, + _Tp> + midpoint(_Tp __a, _Tp __b) noexcept + { + if constexpr (is_integral_v<_Tp>) + { + using _Up = make_unsigned_t<_Tp>; + + int __k = 1; + _Up __m = __a; + _Up __M = __b; + if (__a > __b) + { + __k = -1; + __m = __b; + __M = __a; + } + return __a + __k * _Tp(_Up(__M - __m) / 2); + } + else // is_floating + { + constexpr _Tp __lo = numeric_limits<_Tp>::min() * 2; + constexpr _Tp __hi = numeric_limits<_Tp>::max() / 2; + const _Tp __abs_a = __a < 0 ? -__a : __a; + const _Tp __abs_b = __b < 0 ? -__b : __b; + if (__abs_a <= __hi && __abs_b <= __hi) [[likely]] + return (__a + __b) / 2; // always correctly rounded + if (__abs_a < __lo) // not safe to halve __a + return __a + __b/2; + if (__abs_b < __lo) // not safe to halve __b + return __a/2 + __b; + return __a/2 + __b/2; // otherwise correctly rounded + } + } + + template + constexpr enable_if_t, _Tp*> + midpoint(_Tp* __a, _Tp* __b) noexcept + { + static_assert( sizeof(_Tp) != 0, "type must be complete" ); + return __a + (__b - __a) / 2; + } +#endif // C++20 + +#if __cplusplus >= 201703L + +#if __cplusplus > 201703L +#define __cpp_lib_constexpr_numeric 201911L +#endif + + /// @addtogroup numeric_ops + /// @{ + + /** + * @brief Calculate reduction of values in a range. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @param __binary_op A binary function object. + * @return The final sum. + * + * Reduce the values in the range `[first,last)` using a binary operation. + * The initial value is `init`. The values are not necessarily processed + * in order. + * + * This algorithm is similar to `std::accumulate` but is not required to + * perform the operations in order from first to last. For operations + * that are commutative and associative the result will be the same as + * for `std::accumulate`, but for other operations (such as floating point + * arithmetic) the result can be different. + */ + template + _GLIBCXX20_CONSTEXPR + _Tp + reduce(_InputIterator __first, _InputIterator __last, _Tp __init, + _BinaryOperation __binary_op) + { + using __ref = typename iterator_traits<_InputIterator>::reference; + static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, __ref>); + static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, __ref, _Tp&>); + static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, _Tp&>); + static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, __ref, __ref>); + if constexpr (__is_random_access_iter<_InputIterator>::value) + { + while ((__last - __first) >= 4) + { + _Tp __v1 = __binary_op(__first[0], __first[1]); + _Tp __v2 = __binary_op(__first[2], __first[3]); + _Tp __v3 = __binary_op(__v1, __v2); + __init = __binary_op(__init, __v3); + __first += 4; + } + } + for (; __first != __last; ++__first) + __init = __binary_op(__init, *__first); + return __init; + } + + /** + * @brief Calculate reduction of values in a range. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @return The final sum. + * + * Reduce the values in the range `[first,last)` using addition. + * Equivalent to calling `std::reduce(first, last, init, std::plus<>())`. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + reduce(_InputIterator __first, _InputIterator __last, _Tp __init) + { return std::reduce(__first, __last, std::move(__init), plus<>()); } + + /** + * @brief Calculate reduction of values in a range. + * + * @param __first Start of range. + * @param __last End of range. + * @return The final sum. + * + * Reduce the values in the range `[first,last)` using addition, with + * an initial value of `T{}`, where `T` is the iterator's value type. + * Equivalent to calling `std::reduce(first, last, T{}, std::plus<>())`. + */ + template + _GLIBCXX20_CONSTEXPR + inline typename iterator_traits<_InputIterator>::value_type + reduce(_InputIterator __first, _InputIterator __last) + { + using value_type = typename iterator_traits<_InputIterator>::value_type; + return std::reduce(__first, __last, value_type{}, plus<>()); + } + + /** + * @brief Combine elements from two ranges and reduce + * + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __init Starting value to add other values to. + * @param __binary_op1 The function used to perform reduction. + * @param __binary_op2 The function used to combine values from the ranges. + * @return The final sum. + * + * Call `binary_op2(first1[n],first2[n])` for each `n` in `[0,last1-first1)` + * and then use `binary_op1` to reduce the values returned by `binary_op2` + * to a single value of type `T`. + * + * The range beginning at `first2` must contain at least `last1-first1` + * elements. + */ + template + _GLIBCXX20_CONSTEXPR + _Tp + transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init, + _BinaryOperation1 __binary_op1, + _BinaryOperation2 __binary_op2) + { + if constexpr (__and_v<__is_random_access_iter<_InputIterator1>, + __is_random_access_iter<_InputIterator2>>) + { + while ((__last1 - __first1) >= 4) + { + _Tp __v1 = __binary_op1(__binary_op2(__first1[0], __first2[0]), + __binary_op2(__first1[1], __first2[1])); + _Tp __v2 = __binary_op1(__binary_op2(__first1[2], __first2[2]), + __binary_op2(__first1[3], __first2[3])); + _Tp __v3 = __binary_op1(__v1, __v2); + __init = __binary_op1(__init, __v3); + __first1 += 4; + __first2 += 4; + } + } + for (; __first1 != __last1; ++__first1, (void) ++__first2) + __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); + return __init; + } + + /** + * @brief Combine elements from two ranges and reduce + * + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __init Starting value to add other values to. + * @return The final sum. + * + * Call `first1[n]*first2[n]` for each `n` in `[0,last1-first1)` and then + * use addition to sum those products to a single value of type `T`. + * + * The range beginning at `first2` must contain at least `last1-first1` + * elements. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init) + { + return std::transform_reduce(__first1, __last1, __first2, + std::move(__init), + plus<>(), multiplies<>()); + } + + /** + * @brief Transform the elements of a range and reduce + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @param __binary_op The function used to perform reduction. + * @param __unary_op The function used to transform values from the range. + * @return The final sum. + * + * Call `unary_op(first[n])` for each `n` in `[0,last-first)` and then + * use `binary_op` to reduce the values returned by `unary_op` + * to a single value of type `T`. + */ + template + _GLIBCXX20_CONSTEXPR + _Tp + transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init, + _BinaryOperation __binary_op, _UnaryOperation __unary_op) + { + if constexpr (__is_random_access_iter<_InputIterator>::value) + { + while ((__last - __first) >= 4) + { + _Tp __v1 = __binary_op(__unary_op(__first[0]), + __unary_op(__first[1])); + _Tp __v2 = __binary_op(__unary_op(__first[2]), + __unary_op(__first[3])); + _Tp __v3 = __binary_op(__v1, __v2); + __init = __binary_op(__init, __v3); + __first += 4; + } + } + for (; __first != __last; ++__first) + __init = __binary_op(__init, __unary_op(*__first)); + return __init; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __init Initial value. + * @param __binary_op Function to perform summation. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements (and the initial value), + * using `binary_op` for summation. + * + * This function generates an "exclusive" scan, meaning the Nth element + * of the output range is the sum of the first N-1 input elements, + * so the Nth input element is not included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init, + _BinaryOperation __binary_op) + { + while (__first != __last) + { + auto __v = __init; + __init = __binary_op(__init, *__first); + ++__first; + *__result++ = std::move(__v); + } + return __result; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __init Initial value. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements (and the initial value), + * using `std::plus<>` for summation. + * + * This function generates an "exclusive" scan, meaning the Nth element + * of the output range is the sum of the first N-1 input elements, + * so the Nth input element is not included. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init) + { + return std::exclusive_scan(__first, __last, __result, std::move(__init), + plus<>()); + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __binary_op Function to perform summation. + * @param __init Initial value. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements (and the initial value), + * using `binary_op` for summation. + * + * This function generates an "inclusive" scan, meaning the Nth element + * of the output range is the sum of the first N input elements, + * so the Nth input element is included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op, + _Tp __init) + { + for (; __first != __last; ++__first) + *__result++ = __init = __binary_op(__init, *__first); + return __result; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __binary_op Function to perform summation. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements, using `binary_op` for summation. + * + * This function generates an "inclusive" scan, meaning the Nth element + * of the output range is the sum of the first N input elements, + * so the Nth input element is included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) + { + if (__first != __last) + { + auto __init = *__first; + *__result++ = __init; + ++__first; + if (__first != __last) + __result = std::inclusive_scan(__first, __last, __result, + __binary_op, std::move(__init)); + } + return __result; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements, using `std::plus<>` for summation. + * + * This function generates an "inclusive" scan, meaning the Nth element + * of the output range is the sum of the first N input elements, + * so the Nth input element is included. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) + { return std::inclusive_scan(__first, __last, __result, plus<>()); } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __init Initial value. + * @param __binary_op Function to perform summation. + * @param __unary_op Function to transform elements of the input range. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements (and the initial value), + * using `__unary_op` to transform the input elements + * and using `__binary_op` for summation. + * + * This function generates an "exclusive" scan, meaning the Nth element + * of the output range is the sum of the first N-1 input elements, + * so the Nth input element is not included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform_exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init, + _BinaryOperation __binary_op, + _UnaryOperation __unary_op) + { + while (__first != __last) + { + auto __v = __init; + __init = __binary_op(__init, __unary_op(*__first)); + ++__first; + *__result++ = std::move(__v); + } + return __result; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __binary_op Function to perform summation. + * @param __unary_op Function to transform elements of the input range. + * @param __init Initial value. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements (and the initial value), + * using `__unary_op` to transform the input elements + * and using `__binary_op` for summation. + * + * This function generates an "inclusive" scan, meaning the Nth element + * of the output range is the sum of the first N input elements, + * so the Nth input element is included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform_inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _BinaryOperation __binary_op, + _UnaryOperation __unary_op, + _Tp __init) + { + for (; __first != __last; ++__first) + *__result++ = __init = __binary_op(__init, __unary_op(*__first)); + return __result; + } + + /** @brief Output the cumulative sum of one range to a second range + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Start of output range. + * @param __binary_op Function to perform summation. + * @param __unary_op Function to transform elements of the input range. + * @return The end of the output range. + * + * Write the cumulative sum (aka prefix sum, aka scan) of the input range + * to the output range. Each element of the output range contains the + * running total of all earlier elements, + * using `__unary_op` to transform the input elements + * and using `__binary_op` for summation. + * + * This function generates an "inclusive" scan, meaning the Nth element + * of the output range is the sum of the first N input elements, + * so the Nth input element is included. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform_inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _BinaryOperation __binary_op, + _UnaryOperation __unary_op) + { + if (__first != __last) + { + auto __init = __unary_op(*__first); + *__result++ = __init; + ++__first; + if (__first != __last) + __result = std::transform_inclusive_scan(__first, __last, __result, + __binary_op, __unary_op, + std::move(__init)); + } + return __result; + } + + /// @} group numeric_ops +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#if __cplusplus >= 201703L +// Parallel STL algorithms +# if _PSTL_EXECUTION_POLICIES_DEFINED +// If has already been included, pull in implementations +# include +# else +// Otherwise just pull in forward declarations +# include +# define _PSTL_NUMERIC_FORWARD_DECLARED 1 +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +#endif // C++17 + +#endif /* _GLIBCXX_NUMERIC */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric.blob new file mode 100644 index 0000000000000000000000000000000000000000..f3494f48cf05a51851481dfae443a3068426261c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@numeric.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream new file mode 100644 index 0000000000000000000000000000000000000000..291ea40b35521de664789d4557416daadb11dc53 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream @@ -0,0 +1,835 @@ +// Output streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ostream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.6.2 Output streams +// + +#ifndef _GLIBCXX_OSTREAM +#define _GLIBCXX_OSTREAM 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Template class basic_ostream. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This is the base class for all output streams. It provides text + * formatting of all builtin types, and communicates with any class + * derived from basic_streambuf to do the actual output. + */ + template + class basic_ostream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // Non-standard Types: + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef basic_ios<_CharT, _Traits> __ios_type; + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > + __num_put_type; + typedef ctype<_CharT> __ctype_type; + + /** + * @brief Base constructor. + * + * This ctor is almost never called by the user directly, rather from + * derived classes' initialization lists, which pass a pointer to + * their own stream buffer. + */ + explicit + basic_ostream(__streambuf_type* __sb) + { this->init(__sb); } + + /** + * @brief Base destructor. + * + * This does very little apart from providing a virtual base dtor. + */ + virtual + ~basic_ostream() { } + + /// Safe prefix/suffix operations. + class sentry; + friend class sentry; + + ///@{ + /** + * @brief Interface for manipulators. + * + * Manipulators such as @c std::endl and @c std::hex use these + * functions in constructs like "std::cout << std::endl". For more + * information, see the iomanip header. + */ + __ostream_type& + operator<<(__ostream_type& (*__pf)(__ostream_type&)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + return __pf(*this); + } + + __ostream_type& + operator<<(__ios_type& (*__pf)(__ios_type&)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + __pf(*this); + return *this; + } + + __ostream_type& + operator<<(ios_base& (*__pf) (ios_base&)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // The inserters for manipulators are *not* formatted output functions. + __pf(*this); + return *this; + } + ///@} + + ///@{ + /** + * @name Inserters + * + * All the @c operator<< functions (aka formatted output + * functions) have some common behavior. Each starts by + * constructing a temporary object of type std::basic_ostream::sentry. + * This can have several effects, concluding with the setting of a + * status flag; see the sentry documentation for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state without causing an + * ios_base::failure to be thrown. The original exception will then + * be rethrown. + */ + + ///@{ + /** + * @brief Integer arithmetic inserters + * @param __n A variable of builtin integral type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to perform numeric formatting. + */ + __ostream_type& + operator<<(long __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(unsigned long __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(bool __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(short __n); + + __ostream_type& + operator<<(unsigned short __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + return _M_insert(static_cast(__n)); + } + + __ostream_type& + operator<<(int __n); + + __ostream_type& + operator<<(unsigned int __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + return _M_insert(static_cast(__n)); + } + +#ifdef _GLIBCXX_USE_LONG_LONG + __ostream_type& + operator<<(long long __n) + { return _M_insert(__n); } + + __ostream_type& + operator<<(unsigned long long __n) + { return _M_insert(__n); } +#endif + ///@} + + ///@{ + /** + * @brief Floating point arithmetic inserters + * @param __f A variable of builtin floating point type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to perform numeric formatting. + */ + __ostream_type& + operator<<(double __f) + { return _M_insert(__f); } + + __ostream_type& + operator<<(float __f) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + return _M_insert(static_cast(__f)); + } + + __ostream_type& + operator<<(long double __f) + { return _M_insert(__f); } + ///@} + + /** + * @brief Pointer arithmetic inserters + * @param __p A variable of pointer type. + * @return @c *this if successful + * + * These functions use the stream's current locale (specifically, the + * @c num_get facet) to perform numeric formatting. + */ + __ostream_type& + operator<<(const void* __p) + { return _M_insert(__p); } + +#if __cplusplus >= 201703L + __ostream_type& + operator<<(nullptr_t) + { return *this << "nullptr"; } +#endif + +#if __cplusplus > 202002L + __attribute__((__always_inline__)) + __ostream_type& + operator<<(const volatile void* __p) + { return _M_insert(const_cast(__p)); } +#endif + + /** + * @brief Extracting from another streambuf. + * @param __sb A pointer to a streambuf + * + * This function behaves like one of the basic arithmetic extractors, + * in that it also constructs a sentry object and has the same error + * handling behavior. + * + * If @p __sb is NULL, the stream will set failbit in its error state. + * + * Characters are extracted from @p __sb and inserted into @c *this + * until one of the following occurs: + * + * - the input stream reaches end-of-file, + * - insertion into the output sequence fails (in this case, the + * character that would have been inserted is not extracted), or + * - an exception occurs while getting a character from @p __sb, which + * sets failbit in the error state + * + * If the function inserts no characters, failbit is set. + */ + __ostream_type& + operator<<(__streambuf_type* __sb); + ///@} + + ///@{ + /** + * @name Unformatted Output Functions + * + * All the unformatted output functions have some common behavior. + * Each starts by constructing a temporary object of type + * std::basic_ostream::sentry. This has several effects, concluding + * with the setting of a status flag; see the sentry documentation + * for more. + * + * If the sentry status is good, the function tries to generate + * whatever data is appropriate for the type of the argument. + * + * If an exception is thrown during insertion, ios_base::badbit + * will be turned on in the stream's error state. If badbit is on in + * the stream's exceptions mask, the exception will be rethrown + * without completing its actions. + */ + + /** + * @brief Simple insertion. + * @param __c The character to insert. + * @return *this + * + * Tries to insert @p __c. + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __ostream_type& + put(char_type __c); + + /** + * @brief Character string insertion. + * @param __s The array to insert. + * @param __n Maximum number of characters to insert. + * @return *this + * + * Characters are copied from @p __s and inserted into the stream until + * one of the following happens: + * + * - @p __n characters are inserted + * - inserting into the output sequence fails (in this case, badbit + * will be set in the stream's error state) + * + * @note This function is not overloaded on signed char and + * unsigned char. + */ + __ostream_type& + write(const char_type* __s, streamsize __n); + ///@} + + /** + * @brief Synchronizing the stream buffer. + * @return *this + * + * If @c rdbuf() is a null pointer, changes nothing. + * + * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, + * sets badbit. + */ + __ostream_type& + flush(); + + /** + * @brief Getting the current write position. + * @return A file position object. + * + * If @c fail() is not false, returns @c pos_type(-1) to indicate + * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out). + */ + pos_type + tellp(); + + /** + * @brief Changing the current write position. + * @param __pos A file position object. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If + * that function fails, sets failbit. + */ + __ostream_type& + seekp(pos_type); + + /** + * @brief Changing the current write position. + * @param __off A file offset object. + * @param __dir The direction in which to seek. + * @return *this + * + * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). + * If that function fails, sets failbit. + */ + __ostream_type& + seekp(off_type, ios_base::seekdir); + + protected: + basic_ostream() + { this->init(0); } + +#if __cplusplus >= 201103L + // Non-standard constructor that does not call init() + basic_ostream(basic_iostream<_CharT, _Traits>&) { } + + basic_ostream(const basic_ostream&) = delete; + + basic_ostream(basic_ostream&& __rhs) + : __ios_type() + { __ios_type::move(__rhs); } + + // 27.7.3.3 Assign/swap + + basic_ostream& operator=(const basic_ostream&) = delete; + + basic_ostream& + operator=(basic_ostream&& __rhs) + { + swap(__rhs); + return *this; + } + + void + swap(basic_ostream& __rhs) + { __ios_type::swap(__rhs); } +#endif + + template + __ostream_type& + _M_insert(_ValueT __v); + + private: +#if !_GLIBCXX_INLINE_VERSION + void + _M_write(const char_type* __s, streamsize __n) + { std::__ostream_insert(*this, __s, __n); } +#endif + }; + + /** + * @brief Performs setup work for output streams. + * + * Objects of this class are created before all of the standard + * inserters are run. It is responsible for exception-safe prefix and + * suffix operations. + */ + template + class basic_ostream<_CharT, _Traits>::sentry + { + // Data Members. + bool _M_ok; + basic_ostream<_CharT, _Traits>& _M_os; + + public: + /** + * @brief The constructor performs preparatory work. + * @param __os The output stream to guard. + * + * If the stream state is good (@a __os.good() is true), then if the + * stream is tied to another output stream, @c is.tie()->flush() + * is called to synchronize the output sequences. + * + * If the stream state is still good, then the sentry state becomes + * true (@a okay). + */ + explicit + sentry(basic_ostream<_CharT, _Traits>& __os); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /** + * @brief Possibly flushes the stream. + * + * If @c ios_base::unitbuf is set in @c os.flags(), and + * @c std::uncaught_exception() is true, the sentry destructor calls + * @c flush() on the output stream. + */ + ~sentry() + { + // XXX MT + if (bool(_M_os.flags() & ios_base::unitbuf) && !uncaught_exception()) + { + // Can't call flush directly or else will get into recursive lock. + if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1) + _M_os.setstate(ios_base::badbit); + } + } +#pragma GCC diagnostic pop + + /** + * @brief Quick status checking. + * @return The sentry state. + * + * For ease of use, sentries may be converted to booleans. The + * return value is that of the sentry state (true == okay). + */ +#if __cplusplus >= 201103L + explicit +#endif + operator bool() const + { return _M_ok; } + }; + + ///@{ + /** + * @brief Character inserters + * @param __out An output stream. + * @param __c A character. + * @return out + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts a single character and any required + * padding (as determined by [22.2.2.2.2]). @c __out.width(0) is then + * called. + * + * If @p __c is of type @c char and the character type of the stream is not + * @c char, the character is widened before insertion. + */ + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) + { + if (__out.width() != 0) + return __ostream_insert(__out, &__c, 1); + __out.put(__c); + return __out; + } + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) + { return (__out << __out.widen(__c)); } + + // Specialization + template + inline basic_ostream& + operator<<(basic_ostream& __out, char __c) + { + if (__out.width() != 0) + return __ostream_insert(__out, &__c, 1); + __out.put(__c); + return __out; + } + + // Signed and unsigned + template + inline basic_ostream& + operator<<(basic_ostream& __out, signed char __c) + { return (__out << static_cast(__c)); } + + template + inline basic_ostream& + operator<<(basic_ostream& __out, unsigned char __c) + { return (__out << static_cast(__c)); } + +#if __cplusplus > 201703L + // The following deleted overloads prevent formatting character values as + // numeric values. + + template + basic_ostream& + operator<<(basic_ostream&, wchar_t) = delete; + +#ifdef _GLIBCXX_USE_CHAR8_T + template + basic_ostream& + operator<<(basic_ostream&, char8_t) = delete; +#endif + + template + basic_ostream& + operator<<(basic_ostream&, char16_t) = delete; + + template + basic_ostream& + operator<<(basic_ostream&, char32_t) = delete; + +#ifdef _GLIBCXX_USE_WCHAR_T +#ifdef _GLIBCXX_USE_CHAR8_T + template + basic_ostream& + operator<<(basic_ostream&, char8_t) = delete; +#endif // _GLIBCXX_USE_CHAR8_T + + template + basic_ostream& + operator<<(basic_ostream&, char16_t) = delete; + + template + basic_ostream& + operator<<(basic_ostream&, char32_t) = delete; +#endif // _GLIBCXX_USE_WCHAR_T +#endif // C++20 + ///@} + + ///@{ + /** + * @brief String inserters + * @param __out An output stream. + * @param __s A character string. + * @return out + * @pre @p __s must be a non-NULL pointer + * + * Behaves like one of the formatted arithmetic inserters described in + * std::basic_ostream. After constructing a sentry object with good + * status, this function inserts @c traits::length(__s) characters starting + * at @p __s, widened if necessary, followed by any required padding (as + * determined by [22.2.2.2.2]). @c __out.width(0) is then called. + */ + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) + { + if (!__s) + __out.setstate(ios_base::badbit); + else + __ostream_insert(__out, __s, + static_cast(_Traits::length(__s))); + return __out; + } + + template + basic_ostream<_CharT, _Traits> & + operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s); + + // Partial specializations + template + inline basic_ostream& + operator<<(basic_ostream& __out, const char* __s) + { + if (!__s) + __out.setstate(ios_base::badbit); + else + __ostream_insert(__out, __s, + static_cast(_Traits::length(__s))); + return __out; + } + + // Signed and unsigned + template + inline basic_ostream& + operator<<(basic_ostream& __out, const signed char* __s) + { return (__out << reinterpret_cast(__s)); } + + template + inline basic_ostream & + operator<<(basic_ostream& __out, const unsigned char* __s) + { return (__out << reinterpret_cast(__s)); } + +#if __cplusplus > 201703L + // The following deleted overloads prevent formatting strings as + // pointer values. + + template + basic_ostream& + operator<<(basic_ostream&, const wchar_t*) = delete; + +#ifdef _GLIBCXX_USE_CHAR8_T + template + basic_ostream& + operator<<(basic_ostream&, const char8_t*) = delete; +#endif // _GLIBCXX_USE_CHAR8_T + + template + basic_ostream& + operator<<(basic_ostream&, const char16_t*) = delete; + + template + basic_ostream& + operator<<(basic_ostream&, const char32_t*) = delete; + +#ifdef _GLIBCXX_USE_WCHAR_T +#ifdef _GLIBCXX_USE_CHAR8_T + template + basic_ostream& + operator<<(basic_ostream&, const char8_t*) = delete; +#endif + + template + basic_ostream& + operator<<(basic_ostream&, const char16_t*) = delete; + + template + basic_ostream& + operator<<(basic_ostream&, const char32_t*) = delete; +#endif // _GLIBCXX_USE_WCHAR_T +#endif // C++20 + ///@} + + // Standard basic_ostream manipulators + + /** + * @brief Write a newline and flush the stream. + * + * This manipulator is often mistakenly used when a simple newline is + * desired, leading to poor buffering performance. See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering + * for more on this subject. + */ + template + inline basic_ostream<_CharT, _Traits>& + endl(basic_ostream<_CharT, _Traits>& __os) + { return flush(__os.put(__os.widen('\n'))); } + + /** + * @brief Write a null character into the output sequence. + * + * Null character is @c CharT() by definition. For CharT + * of @c char, this correctly writes the ASCII @c NUL character + * string terminator. + */ + template + inline basic_ostream<_CharT, _Traits>& + ends(basic_ostream<_CharT, _Traits>& __os) + { return __os.put(_CharT()); } + + /** + * @brief Flushes the output stream. + * + * This manipulator simply calls the stream's @c flush() member function. + */ + template + inline basic_ostream<_CharT, _Traits>& + flush(basic_ostream<_CharT, _Traits>& __os) + { return __os.flush(); } + +#if __cplusplus >= 201103L + // C++11 27.7.3.9 Rvalue stream insertion [ostream.rvalue] + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 1203. More useful rvalue stream insertion + +#if __cpp_lib_concepts + // Use concepts if possible because they're cheaper to evaluate. + template + concept __derived_from_ios_base = is_class_v<_Tp> + && (!is_same_v<_Tp, ios_base>) + && requires (_Tp* __t, ios_base* __b) { __b = __t; }; + + template + requires __derived_from_ios_base<_Os> + && requires (_Os& __os, const _Tp& __t) { __os << __t; } + using __rvalue_stream_insertion_t = _Os&&; +#else + template + using _Require_derived_from_ios_base + = _Require, __not_>, + is_convertible::type, ios_base*>>; + + template, + typename + = decltype(std::declval<_Os&>() << std::declval())> + using __rvalue_stream_insertion_t = _Os&&; +#endif + + /** + * @brief Generic inserter for rvalue stream + * @param __os An input stream. + * @param __x A reference to the object being inserted. + * @return __os + * + * This is just a forwarding function to allow insertion to + * rvalue streams since they won't bind to the inserter functions + * that take an lvalue reference. + */ + template + inline __rvalue_stream_insertion_t<_Ostream, _Tp> + operator<<(_Ostream&& __os, const _Tp& __x) + { + __os << __x; + return std::move(__os); + } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + template + class __syncbuf_base : public basic_streambuf<_CharT, _Traits> + { + public: + static bool* + _S_get(basic_streambuf<_CharT, _Traits>* __buf [[maybe_unused]]) noexcept + { +#if __cpp_rtti + if (auto __p = dynamic_cast<__syncbuf_base*>(__buf)) + return &__p->_M_emit_on_sync; +#endif + return nullptr; + } + + protected: + __syncbuf_base(basic_streambuf<_CharT, _Traits>* __w = nullptr) + : _M_wrapped(__w) + { } + + basic_streambuf<_CharT, _Traits>* _M_wrapped = nullptr; + bool _M_emit_on_sync = false; + bool _M_needs_sync = false; + }; + + template + inline basic_ostream<_CharT, _Traits>& + emit_on_flush(basic_ostream<_CharT, _Traits>& __os) + { + if (bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf())) + *__flag = true; + return __os; + } + + template + inline basic_ostream<_CharT, _Traits>& + noemit_on_flush(basic_ostream<_CharT, _Traits>& __os) + { + if (bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf())) + *__flag = false; + return __os; + } + + template + inline basic_ostream<_CharT, _Traits>& + flush_emit(basic_ostream<_CharT, _Traits>& __os) + { + struct _Restore + { + ~_Restore() { *_M_flag = _M_prev; } + + bool _M_prev = false; + bool* _M_flag = &_M_prev; + } __restore; + + if (bool* __flag = __syncbuf_base<_CharT, _Traits>::_S_get(__os.rdbuf())) + { + __restore._M_prev = *__flag; + __restore._M_flag = __flag; + *__flag = true; + } + + __os.flush(); + return __os; + } + +#endif // C++20 + +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include + +#endif /* _GLIBCXX_OSTREAM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream.blob new file mode 100644 index 0000000000000000000000000000000000000000..954cdf557563a3f5ec59efa953854f807bb86738 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ostream.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue new file mode 100644 index 0000000000000000000000000000000000000000..db81ef1e6c7661104f12ed402db1d2c2424ad8b8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue @@ -0,0 +1,66 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/queue + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_QUEUE +#define _GLIBCXX_QUEUE 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +#endif /* _GLIBCXX_QUEUE */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue.blob new file mode 100644 index 0000000000000000000000000000000000000000..4787684d1553eb61e9badd2e9bc76dda1faa4943 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@queue.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random new file mode 100644 index 0000000000000000000000000000000000000000..89a2f16c9217b502ed24a31ca831c4938814d36c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random @@ -0,0 +1,57 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/random + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_RANDOM +#define _GLIBCXX_RANDOM 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +#include // For uint_fast32_t, uint_fast64_t, uint_least32_t +#include +#include +#include + +#endif // _GLIBCXX_USE_C99_STDINT_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_RANDOM diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random.blob new file mode 100644 index 0000000000000000000000000000000000000000..eff1de7065d815718133b52e8d973bf754a4feea Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@random.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio new file mode 100644 index 0000000000000000000000000000000000000000..5a5643d2999b2dae40a48be8210d484bd7f86516 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio @@ -0,0 +1,586 @@ +// ratio -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ratio + * This is a Standard C++ Library header. + * @ingroup ratio + */ + +#ifndef _GLIBCXX_RATIO +#define _GLIBCXX_RATIO 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include // intmax_t, uintmax_t + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup ratio Rational Arithmetic + * @ingroup utilities + * + * Compile time representation of finite rational numbers. + * @{ + */ + + /// @cond undocumented + + template + struct __static_sign + : integral_constant + { }; + + template + struct __static_abs + : integral_constant::value> + { }; + + template + struct __static_gcd + : __static_gcd<_Qn, (_Pn % _Qn)> + { }; + + template + struct __static_gcd<_Pn, 0> + : integral_constant::value> + { }; + + template + struct __static_gcd<0, _Qn> + : integral_constant::value> + { }; + + // Let c = 2^(half # of bits in an intmax_t) + // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0 + // The multiplication of N and M becomes, + // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0 + // Multiplication is safe if each term and the sum of the terms + // is representable by intmax_t. + template + struct __safe_multiply + { + private: + static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); + + static const uintmax_t __a0 = __static_abs<_Pn>::value % __c; + static const uintmax_t __a1 = __static_abs<_Pn>::value / __c; + static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; + static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; + + static_assert(__a1 == 0 || __b1 == 0, + "overflow in multiplication"); + static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), + "overflow in multiplication"); + static_assert(__b0 * __a0 <= __INTMAX_MAX__, + "overflow in multiplication"); + static_assert((__a0 * __b1 + __b0 * __a1) * __c + <= __INTMAX_MAX__ - __b0 * __a0, + "overflow in multiplication"); + + public: + static const intmax_t value = _Pn * _Qn; + }; + + // Some double-precision utilities, where numbers are represented as + // __hi*2^(8*sizeof(uintmax_t)) + __lo. + template + struct __big_less + : integral_constant + { }; + + template + struct __big_add + { + static constexpr uintmax_t __lo = __lo1 + __lo2; + static constexpr uintmax_t __hi = (__hi1 + __hi2 + + (__lo1 + __lo2 < __lo1)); // carry + }; + + // Subtract a number from a bigger one. + template + struct __big_sub + { + static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value, + "Internal library error"); + static constexpr uintmax_t __lo = __lo1 - __lo2; + static constexpr uintmax_t __hi = (__hi1 - __hi2 - + (__lo1 < __lo2)); // carry + }; + + // Same principle as __safe_multiply. + template + struct __big_mul + { + private: + static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); + static constexpr uintmax_t __x0 = __x % __c; + static constexpr uintmax_t __x1 = __x / __c; + static constexpr uintmax_t __y0 = __y % __c; + static constexpr uintmax_t __y1 = __y / __c; + static constexpr uintmax_t __x0y0 = __x0 * __y0; + static constexpr uintmax_t __x0y1 = __x0 * __y1; + static constexpr uintmax_t __x1y0 = __x1 * __y0; + static constexpr uintmax_t __x1y1 = __x1 * __y1; + static constexpr uintmax_t __mix = __x0y1 + __x1y0; // possible carry... + static constexpr uintmax_t __mix_lo = __mix * __c; + static constexpr uintmax_t __mix_hi + = __mix / __c + ((__mix < __x0y1) ? __c : 0); // ... added here + typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res; + public: + static constexpr uintmax_t __hi = _Res::__hi; + static constexpr uintmax_t __lo = _Res::__lo; + }; + + // Adapted from __udiv_qrnnd_c in longlong.h + // This version assumes that the high bit of __d is 1. + template + struct __big_div_impl + { + private: + static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)), + "Internal library error"); + static_assert(__n1 < __d, "Internal library error"); + static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); + static constexpr uintmax_t __d1 = __d / __c; + static constexpr uintmax_t __d0 = __d % __c; + + static constexpr uintmax_t __q1x = __n1 / __d1; + static constexpr uintmax_t __r1x = __n1 % __d1; + static constexpr uintmax_t __m = __q1x * __d0; + static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c; + static constexpr uintmax_t __r1z = __r1y + __d; + static constexpr uintmax_t __r1 + = ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m)) + ? (__r1z + __d) : __r1z : __r1y) - __m; + static constexpr uintmax_t __q1 + = __q1x - ((__r1y < __m) + ? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0); + static constexpr uintmax_t __q0x = __r1 / __d1; + static constexpr uintmax_t __r0x = __r1 % __d1; + static constexpr uintmax_t __n = __q0x * __d0; + static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c; + static constexpr uintmax_t __r0z = __r0y + __d; + static constexpr uintmax_t __r0 + = ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n)) + ? (__r0z + __d) : __r0z : __r0y) - __n; + static constexpr uintmax_t __q0 + = __q0x - ((__r0y < __n) ? ((__r0z >= __d) + && (__r0z < __n)) ? 2 : 1 : 0); + + public: + static constexpr uintmax_t __quot = __q1 * __c + __q0; + static constexpr uintmax_t __rem = __r0; + + private: + typedef __big_mul<__quot, __d> _Prod; + typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum; + static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, + "Internal library error"); + }; + + template + struct __big_div + { + private: + static_assert(__d != 0, "Internal library error"); + static_assert(sizeof (uintmax_t) == sizeof (unsigned long long), + "This library calls __builtin_clzll on uintmax_t, which " + "is unsafe on your platform. Please complain to " + "http://gcc.gnu.org/bugzilla/"); + static constexpr int __shift = __builtin_clzll(__d); + static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift; + static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0; + static constexpr uintmax_t __c1 = uintmax_t(1) << __shift; + static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift; + static constexpr uintmax_t __new_d = __d * __c1; + static constexpr uintmax_t __new_n0 = __n0 * __c1; + static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1; + static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0; + static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top; + typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res; + + public: + static constexpr uintmax_t __quot_hi = __n1 / __d; + static constexpr uintmax_t __quot_lo = _Res::__quot; + static constexpr uintmax_t __rem = _Res::__rem / __c1; + + private: + typedef __big_mul<__quot_lo, __d> _P0; + typedef __big_mul<__quot_hi, __d> _P1; + typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum; + // No overflow. + static_assert(_P1::__hi == 0, "Internal library error"); + static_assert(_Sum::__hi >= _P0::__hi, "Internal library error"); + // Matches the input data. + static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, + "Internal library error"); + static_assert(__rem < __d, "Internal library error"); + }; + + /// @endcond + + /** + * @brief Provides compile-time rational arithmetic. + * + * This class template represents any finite rational number with a + * numerator and denominator representable by compile-time constants of + * type intmax_t. The ratio is simplified when instantiated. + * + * For example: + * @code + * std::ratio<7,-21>::num == -1; + * std::ratio<7,-21>::den == 3; + * @endcode + * + */ + template + struct ratio + { + static_assert(_Den != 0, "denominator cannot be zero"); + static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__, + "out of range"); + + // Note: sign(N) * abs(N) == N + static constexpr intmax_t num = + _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value; + + static constexpr intmax_t den = + __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value; + + typedef ratio type; + }; + +#if ! __cpp_inline_variables + template + constexpr intmax_t ratio<_Num, _Den>::num; + + template + constexpr intmax_t ratio<_Num, _Den>::den; +#endif + + /// @cond undocumented + + template + struct __ratio_multiply + { + private: + static const intmax_t __gcd1 = + __static_gcd<_R1::num, _R2::den>::value; + static const intmax_t __gcd2 = + __static_gcd<_R2::num, _R1::den>::value; + + public: + typedef ratio< + __safe_multiply<(_R1::num / __gcd1), + (_R2::num / __gcd2)>::value, + __safe_multiply<(_R1::den / __gcd2), + (_R2::den / __gcd1)>::value> type; + + static constexpr intmax_t num = type::num; + static constexpr intmax_t den = type::den; + }; + +#if ! __cpp_inline_variables + template + constexpr intmax_t __ratio_multiply<_R1, _R2>::num; + + template + constexpr intmax_t __ratio_multiply<_R1, _R2>::den; +#endif + + /// @endcond + + /// ratio_multiply + template + using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; + + /// @cond undocumented + + template + struct __ratio_divide + { + static_assert(_R2::num != 0, "division by 0"); + + typedef typename __ratio_multiply< + _R1, + ratio<_R2::den, _R2::num>>::type type; + + static constexpr intmax_t num = type::num; + static constexpr intmax_t den = type::den; + }; + +#if ! __cpp_inline_variables + template + constexpr intmax_t __ratio_divide<_R1, _R2>::num; + + template + constexpr intmax_t __ratio_divide<_R1, _R2>::den; +#endif + + /// @endcond + + /// ratio_divide + template + using ratio_divide = typename __ratio_divide<_R1, _R2>::type; + + /// ratio_equal + template + struct ratio_equal + : integral_constant + { }; + + /// ratio_not_equal + template + struct ratio_not_equal + : integral_constant::value> + { }; + + /// @cond undocumented + + // Both numbers are positive. + template, + typename _Right = __big_mul<_R2::num,_R1::den> > + struct __ratio_less_impl_1 + : integral_constant::value> + { }; + + template::value + != __static_sign<_R2::num>::value)), + bool = (__static_sign<_R1::num>::value == -1 + && __static_sign<_R2::num>::value == -1)> + struct __ratio_less_impl + : __ratio_less_impl_1<_R1, _R2>::type + { }; + + template + struct __ratio_less_impl<_R1, _R2, true, false> + : integral_constant + { }; + + template + struct __ratio_less_impl<_R1, _R2, false, true> + : __ratio_less_impl_1, + ratio<-_R1::num, _R1::den> >::type + { }; + + /// @endcond + + /// ratio_less + template + struct ratio_less + : __ratio_less_impl<_R1, _R2>::type + { }; + + /// ratio_less_equal + template + struct ratio_less_equal + : integral_constant::value> + { }; + + /// ratio_greater + template + struct ratio_greater + : integral_constant::value> + { }; + + /// ratio_greater_equal + template + struct ratio_greater_equal + : integral_constant::value> + { }; + +#if __cplusplus > 201402L + template + inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; + template + inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value; + template + inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value; + template + inline constexpr bool ratio_less_equal_v = + ratio_less_equal<_R1, _R2>::value; + template + inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; + template + inline constexpr bool ratio_greater_equal_v + = ratio_greater_equal<_R1, _R2>::value; +#endif // C++17 + + /// @cond undocumented + + template= 0), + bool = (_R2::num >= 0), + bool = ratio_less::value, _R1::den>, + ratio<__static_abs<_R2::num>::value, _R2::den> >::value> + struct __ratio_add_impl + { + private: + typedef typename __ratio_add_impl< + ratio<-_R1::num, _R1::den>, + ratio<-_R2::num, _R2::den> >::type __t; + public: + typedef ratio<-__t::num, __t::den> type; + }; + + // True addition of nonnegative numbers. + template + struct __ratio_add_impl<_R1, _R2, true, true, __b> + { + private: + static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; + static constexpr uintmax_t __d2 = _R2::den / __g; + typedef __big_mul<_R1::den, __d2> __d; + typedef __big_mul<_R1::num, _R2::den / __g> __x; + typedef __big_mul<_R2::num, _R1::den / __g> __y; + typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; + static_assert(__n::__hi >= __x::__hi, "Internal library error"); + typedef __big_div<__n::__hi, __n::__lo, __g> __ng; + static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; + typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; + static_assert(__n_final::__rem == 0, "Internal library error"); + static_assert(__n_final::__quot_hi == 0 && + __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition"); + typedef __big_mul<_R1::den / __g2, __d2> __d_final; + static_assert(__d_final::__hi == 0 && + __d_final::__lo <= __INTMAX_MAX__, "overflow in addition"); + public: + typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; + }; + + template + struct __ratio_add_impl<_R1, _R2, false, true, true> + : __ratio_add_impl<_R2, _R1> + { }; + + // True subtraction of nonnegative numbers yielding a nonnegative result. + template + struct __ratio_add_impl<_R1, _R2, true, false, false> + { + private: + static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; + static constexpr uintmax_t __d2 = _R2::den / __g; + typedef __big_mul<_R1::den, __d2> __d; + typedef __big_mul<_R1::num, _R2::den / __g> __x; + typedef __big_mul<-_R2::num, _R1::den / __g> __y; + typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; + typedef __big_div<__n::__hi, __n::__lo, __g> __ng; + static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; + typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; + static_assert(__n_final::__rem == 0, "Internal library error"); + static_assert(__n_final::__quot_hi == 0 && + __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition"); + typedef __big_mul<_R1::den / __g2, __d2> __d_final; + static_assert(__d_final::__hi == 0 && + __d_final::__lo <= __INTMAX_MAX__, "overflow in addition"); + public: + typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; + }; + + template + struct __ratio_add + { + typedef typename __ratio_add_impl<_R1, _R2>::type type; + static constexpr intmax_t num = type::num; + static constexpr intmax_t den = type::den; + }; + +#if ! __cpp_inline_variables + template + constexpr intmax_t __ratio_add<_R1, _R2>::num; + + template + constexpr intmax_t __ratio_add<_R1, _R2>::den; +#endif + + /// @endcond + + /// ratio_add + template + using ratio_add = typename __ratio_add<_R1, _R2>::type; + + /// @cond undocumented + + template + struct __ratio_subtract + { + typedef typename __ratio_add< + _R1, + ratio<-_R2::num, _R2::den>>::type type; + + static constexpr intmax_t num = type::num; + static constexpr intmax_t den = type::den; + }; + +#if ! __cpp_inline_variables + template + constexpr intmax_t __ratio_subtract<_R1, _R2>::num; + + template + constexpr intmax_t __ratio_subtract<_R1, _R2>::den; +#endif + + /// @endcond + + /// ratio_subtract + template + using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; + + + typedef ratio<1, 1000000000000000000> atto; + typedef ratio<1, 1000000000000000> femto; + typedef ratio<1, 1000000000000> pico; + typedef ratio<1, 1000000000> nano; + typedef ratio<1, 1000000> micro; + typedef ratio<1, 1000> milli; + typedef ratio<1, 100> centi; + typedef ratio<1, 10> deci; + typedef ratio< 10, 1> deca; + typedef ratio< 100, 1> hecto; + typedef ratio< 1000, 1> kilo; + typedef ratio< 1000000, 1> mega; + typedef ratio< 1000000000, 1> giga; + typedef ratio< 1000000000000, 1> tera; + typedef ratio< 1000000000000000, 1> peta; + typedef ratio< 1000000000000000000, 1> exa; + + /// @} group ratio +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif //_GLIBCXX_RATIO diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio.blob new file mode 100644 index 0000000000000000000000000000000000000000..e427808065a67b8fa561ef528b73bf2aba7131fb Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@ratio.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex new file mode 100644 index 0000000000000000000000000000000000000000..d1b6a6c68c362c058cd770b1802aad30a460f3d7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex @@ -0,0 +1,96 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/regex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_REGEX +#define _GLIBCXX_REGEX 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include // std::copy, std::fill_n +#include // std::sort, std::unique +#include // std::iterator_traits +#include +#include +#include +#include +#include +#include +#ifdef _GLIBCXX_DEBUG +# include +#endif +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template + using match_results + = std::match_results<_BidirectionalIterator, polymorphic_allocator< + sub_match<_BidirectionalIterator>>>; + using cmatch = match_results; + // Use __normal_iterator directly, because pmr::string::const_iterator + // would require pmr::polymorphic_allocator to be complete. + using smatch + = match_results<__gnu_cxx::__normal_iterator>; +#ifdef _GLIBCXX_USE_WCHAR_T + using wcmatch = match_results; + using wsmatch + = match_results<__gnu_cxx::__normal_iterator>; +#endif + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 +#endif // C++11 + +#endif // _GLIBCXX_REGEX diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex.blob new file mode 100644 index 0000000000000000000000000000000000000000..36f2b79f6ca30bcefa7736c3748ba4c695fc8ab3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@regex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator new file mode 100644 index 0000000000000000000000000000000000000000..f2e3ed9f7833b80a72e0c0c6761dfece62baaf22 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator @@ -0,0 +1,522 @@ +// -*- C++ -*- + +// Copyright (C) 2011-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/scoped_allocator + * This is a Standard C++ Library header. + * @ingroup allocators + */ + +#ifndef _SCOPED_ALLOCATOR +#define _SCOPED_ALLOCATOR 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup allocators + * @{ + */ + + template + class scoped_allocator_adaptor; + + /// @cond undocumented + + template + using __outer_allocator_t + = decltype(std::declval<_Alloc>().outer_allocator()); + + template + struct __outermost_type + { + using type = _Alloc; + static type& _S_outermost(_Alloc& __a) { return __a; } + }; + + template + struct __outermost_type<_Alloc, __void_t<__outer_allocator_t<_Alloc>>> + : __outermost_type< + typename remove_reference<__outer_allocator_t<_Alloc>>::type + > + { + using __base = __outermost_type< + typename remove_reference<__outer_allocator_t<_Alloc>>::type + >; + + static typename __base::type& + _S_outermost(_Alloc& __a) + { return __base::_S_outermost(__a.outer_allocator()); } + }; + + // Implementation of the OUTERMOST pseudofunction + template + inline typename __outermost_type<_Alloc>::type& + __outermost(_Alloc& __a) + { return __outermost_type<_Alloc>::_S_outermost(__a); } + + template + struct __inner_type_impl; + + template + struct __inner_type_impl<_Outer> + { + typedef scoped_allocator_adaptor<_Outer> __type; + + __inner_type_impl() = default; + __inner_type_impl(const __inner_type_impl&) = default; + __inner_type_impl(__inner_type_impl&&) = default; + __inner_type_impl& operator=(const __inner_type_impl&) = default; + __inner_type_impl& operator=(__inner_type_impl&&) = default; + + template + __inner_type_impl(const __inner_type_impl<_Alloc>& __other) + { } + + template + __inner_type_impl(__inner_type_impl<_Alloc>&& __other) + { } + + __type& + _M_get(__type* __p) noexcept { return *__p; } + + const __type& + _M_get(const __type* __p) const noexcept { return *__p; } + + tuple<> + _M_tie() const noexcept { return tuple<>(); } + + bool + operator==(const __inner_type_impl&) const noexcept + { return true; } + }; + + template + struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...> + { + typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type; + + __inner_type_impl() = default; + __inner_type_impl(const __inner_type_impl&) = default; + __inner_type_impl(__inner_type_impl&&) = default; + __inner_type_impl& operator=(const __inner_type_impl&) = default; + __inner_type_impl& operator=(__inner_type_impl&&) = default; + + template + __inner_type_impl(const __inner_type_impl<_Allocs...>& __other) + : _M_inner(__other._M_inner) { } + + template + __inner_type_impl(__inner_type_impl<_Allocs...>&& __other) + : _M_inner(std::move(__other._M_inner)) { } + + template + explicit + __inner_type_impl(_Args&&... __args) + : _M_inner(std::forward<_Args>(__args)...) { } + + __type& + _M_get(void*) noexcept { return _M_inner; } + + const __type& + _M_get(const void*) const noexcept { return _M_inner; } + + tuple + _M_tie() const noexcept + { return _M_inner._M_tie(); } + + bool + operator==(const __inner_type_impl& __other) const noexcept + { return _M_inner == __other._M_inner; } + + private: + template friend class __inner_type_impl; + template friend class scoped_allocator_adaptor; + + __type _M_inner; + }; + + /// @endcond + + /// An adaptor to recursively pass an allocator to the objects it constructs + template + class scoped_allocator_adaptor + : public _OuterAlloc + { + typedef allocator_traits<_OuterAlloc> __traits; + + typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type; + __inner_type _M_inner; + + template + friend class scoped_allocator_adaptor; + + template + friend class __inner_type_impl; + + tuple + _M_tie() const noexcept + { return std::tuple_cat(std::tie(outer_allocator()), _M_inner._M_tie()); } + + template + using __outermost_alloc_traits + = allocator_traits::type>; + +#if ! __cpp_lib_make_obj_using_allocator + template + void + _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args) + { + typedef __outermost_alloc_traits _O_traits; + _O_traits::construct(__outermost(*this), __p, + std::forward<_Args>(__args)...); + } + + typedef __uses_alloc1 __uses_alloc1_; + typedef __uses_alloc2 __uses_alloc2_; + + template + void + _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args) + { + typedef __outermost_alloc_traits _O_traits; + _O_traits::construct(__outermost(*this), __p, + allocator_arg, inner_allocator(), + std::forward<_Args>(__args)...); + } + + template + void + _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args) + { + typedef __outermost_alloc_traits _O_traits; + _O_traits::construct(__outermost(*this), __p, + std::forward<_Args>(__args)..., + inner_allocator()); + } +#endif // ! make_obj_using_allocator + + template + static _Alloc + _S_select_on_copy(const _Alloc& __a) + { + typedef allocator_traits<_Alloc> __a_traits; + return __a_traits::select_on_container_copy_construction(__a); + } + + template + scoped_allocator_adaptor(tuple __refs, + _Index_tuple<_Indices...>) + : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))), + _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...) + { } + + // Used to constrain constructors to disallow invalid conversions. + template + using _Constructible = typename enable_if< + is_constructible<_OuterAlloc, _Alloc>::value + >::type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2975. Missing case for pair construction in scoped [...] allocators + template + struct __not_pair { using type = void; }; + + template + struct __not_pair> { }; + + public: + typedef _OuterAlloc outer_allocator_type; + typedef typename __inner_type::__type inner_allocator_type; + + typedef typename __traits::value_type value_type; + typedef typename __traits::size_type size_type; + typedef typename __traits::difference_type difference_type; + typedef typename __traits::pointer pointer; + typedef typename __traits::const_pointer const_pointer; + typedef typename __traits::void_pointer void_pointer; + typedef typename __traits::const_void_pointer const_void_pointer; + + typedef typename __or_< + typename __traits::propagate_on_container_copy_assignment, + typename allocator_traits<_InnerAllocs>:: + propagate_on_container_copy_assignment...>::type + propagate_on_container_copy_assignment; + + typedef typename __or_< + typename __traits::propagate_on_container_move_assignment, + typename allocator_traits<_InnerAllocs>:: + propagate_on_container_move_assignment...>::type + propagate_on_container_move_assignment; + + typedef typename __or_< + typename __traits::propagate_on_container_swap, + typename allocator_traits<_InnerAllocs>:: + propagate_on_container_swap...>::type + propagate_on_container_swap; + + typedef typename __and_< + typename __traits::is_always_equal, + typename allocator_traits<_InnerAllocs>::is_always_equal...>::type + is_always_equal; + + template + struct rebind + { + typedef scoped_allocator_adaptor< + typename __traits::template rebind_alloc<_Tp>, + _InnerAllocs...> other; + }; + + scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { } + + template> + scoped_allocator_adaptor(_Outer2&& __outer, + const _InnerAllocs&... __inner) + : _OuterAlloc(std::forward<_Outer2>(__outer)), + _M_inner(__inner...) + { } + + scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) + : _OuterAlloc(__other.outer_allocator()), + _M_inner(__other._M_inner) + { } + + scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) + : _OuterAlloc(std::move(__other.outer_allocator())), + _M_inner(std::move(__other._M_inner)) + { } + + template> + scoped_allocator_adaptor( + const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other) + : _OuterAlloc(__other.outer_allocator()), + _M_inner(__other._M_inner) + { } + + template> + scoped_allocator_adaptor( + scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) + : _OuterAlloc(std::move(__other.outer_allocator())), + _M_inner(std::move(__other._M_inner)) + { } + + scoped_allocator_adaptor& + operator=(const scoped_allocator_adaptor&) = default; + + scoped_allocator_adaptor& + operator=(scoped_allocator_adaptor&&) = default; + + inner_allocator_type& inner_allocator() noexcept + { return _M_inner._M_get(this); } + + const inner_allocator_type& inner_allocator() const noexcept + { return _M_inner._M_get(this); } + + outer_allocator_type& outer_allocator() noexcept + { return static_cast<_OuterAlloc&>(*this); } + + const outer_allocator_type& outer_allocator() const noexcept + { return static_cast(*this); } + + _GLIBCXX_NODISCARD pointer allocate(size_type __n) + { return __traits::allocate(outer_allocator(), __n); } + + _GLIBCXX_NODISCARD pointer allocate(size_type __n, const_void_pointer __hint) + { return __traits::allocate(outer_allocator(), __n, __hint); } + + void deallocate(pointer __p, size_type __n) + { return __traits::deallocate(outer_allocator(), __p, __n); } + + size_type max_size() const + { return __traits::max_size(outer_allocator()); } + +#if ! __cpp_lib_make_obj_using_allocator + template + typename __not_pair<_Tp>::type + construct(_Tp* __p, _Args&&... __args) + { + auto& __inner = inner_allocator(); + auto __use_tag + = std::__use_alloc<_Tp, inner_allocator_type, _Args...>(__inner); + _M_construct(__use_tag, __p, std::forward<_Args>(__args)...); + } + + template + void + construct(pair<_T1, _T2>* __p, piecewise_construct_t, + tuple<_Args1...> __x, tuple<_Args2...> __y) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2203. wrong argument types for piecewise construction + auto& __inner = inner_allocator(); + auto __x_use_tag + = std::__use_alloc<_T1, inner_allocator_type, _Args1...>(__inner); + auto __y_use_tag + = std::__use_alloc<_T2, inner_allocator_type, _Args2...>(__inner); + typename _Build_index_tuple::__type __x_indices; + typename _Build_index_tuple::__type __y_indices; + typedef __outermost_alloc_traits _O_traits; + _O_traits::construct(__outermost(*this), __p, piecewise_construct, + _M_construct_p(__x_use_tag, __x_indices, __x), + _M_construct_p(__y_use_tag, __y_indices, __y)); + } + + template + void + construct(pair<_T1, _T2>* __p) + { construct(__p, piecewise_construct, tuple<>(), tuple<>()); } + + template + void + construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v) + { + construct(__p, piecewise_construct, + std::forward_as_tuple(std::forward<_Up>(__u)), + std::forward_as_tuple(std::forward<_Vp>(__v))); + } + + template + void + construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) + { + construct(__p, piecewise_construct, + std::forward_as_tuple(__x.first), + std::forward_as_tuple(__x.second)); + } + + template + void + construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) + { + construct(__p, piecewise_construct, + std::forward_as_tuple(std::forward<_Up>(__x.first)), + std::forward_as_tuple(std::forward<_Vp>(__x.second))); + } +#else // make_obj_using_allocator + template + __attribute__((__nonnull__)) + void + construct(_Tp* __p, _Args&&... __args) + { + typedef __outermost_alloc_traits _O_traits; + std::apply([__p, this](auto&&... __newargs) { + _O_traits::construct(__outermost(*this), __p, + std::forward(__newargs)...); + }, + uses_allocator_construction_args<_Tp>(inner_allocator(), + std::forward<_Args>(__args)...)); + } +#endif + + template + void destroy(_Tp* __p) + { + typedef __outermost_alloc_traits _O_traits; + _O_traits::destroy(__outermost(*this), __p); + } + + scoped_allocator_adaptor + select_on_container_copy_construction() const + { + typedef typename _Build_index_tuple::__type + _Indices; + return scoped_allocator_adaptor(_M_tie(), _Indices()); + } + + template + friend bool + operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept; + + private: +#if ! __cpp_lib_make_obj_using_allocator + template + tuple<_Args&&...> + _M_construct_p(__uses_alloc0, _Ind, tuple<_Args...>& __t) + { return std::move(__t); } + + template + tuple + _M_construct_p(__uses_alloc1_, _Index_tuple<_Ind...>, + tuple<_Args...>& __t) + { + return { allocator_arg, inner_allocator(), + std::get<_Ind>(std::move(__t))... + }; + } + + template + tuple<_Args&&..., inner_allocator_type&> + _M_construct_p(__uses_alloc2_, _Index_tuple<_Ind...>, + tuple<_Args...>& __t) + { + return { std::get<_Ind>(std::move(__t))..., inner_allocator() }; + } +#endif // ! make_obj_using_allocator + }; + + /// @related std::scoped_allocator_adaptor + template + inline bool + operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept + { + return __a.outer_allocator() == __b.outer_allocator() + && __a._M_inner == __b._M_inner; + } + +#if __cpp_impl_three_way_comparison < 201907L + /// @related std::scoped_allocator_adaptor + template + inline bool + operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a, + const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept + { return !(__a == __b); } +#endif + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _SCOPED_ALLOCATOR diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator.blob new file mode 100644 index 0000000000000000000000000000000000000000..51d47bd7df48b46bd34d810069a441845e851e85 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@scoped_allocator.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set new file mode 100644 index 0000000000000000000000000000000000000000..45fed14c51e30e95878de793c165d79a69a40af8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set @@ -0,0 +1,111 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/set + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_SET +#define _GLIBCXX_SET 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template> + using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>; + template> + using multiset = std::multiset<_Key, _Cmp, polymorphic_allocator<_Key>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline typename set<_Key, _Compare, _Alloc>::size_type + erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) + { + const _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } + + template + inline typename multiset<_Key, _Compare, _Alloc>::size_type + erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) + { + const _GLIBCXX_STD_C::multiset<_Key, _Compare, _Alloc>& __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_SET */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set.blob new file mode 100644 index 0000000000000000000000000000000000000000..86452e23e6c69867663b1741b981ab5aa2758fef Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@set.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex new file mode 100644 index 0000000000000000000000000000000000000000..817a9587d87790aeca380a8961fb49d276948454 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex @@ -0,0 +1,860 @@ +// -*- C++ -*- + +// Copyright (C) 2013-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/shared_mutex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_SHARED_MUTEX +#define _GLIBCXX_SHARED_MUTEX 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include +#include +#include // move, __exchange +#include // defer_lock_t + +#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK) +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup mutexes + * @{ + */ + +#ifdef _GLIBCXX_HAS_GTHREADS + +#if __cplusplus >= 201703L +#define __cpp_lib_shared_mutex 201505L + class shared_mutex; +#endif + +#define __cpp_lib_shared_timed_mutex 201402L + class shared_timed_mutex; + + /// @cond undocumented + +#if _GLIBCXX_USE_PTHREAD_RWLOCK_T +#ifdef __gthrw +#define _GLIBCXX_GTHRW(name) \ + __gthrw(pthread_ ## name); \ + static inline int \ + __glibcxx_ ## name (pthread_rwlock_t *__rwlock) \ + { \ + if (__gthread_active_p ()) \ + return __gthrw_(pthread_ ## name) (__rwlock); \ + else \ + return 0; \ + } + _GLIBCXX_GTHRW(rwlock_rdlock) + _GLIBCXX_GTHRW(rwlock_tryrdlock) + _GLIBCXX_GTHRW(rwlock_wrlock) + _GLIBCXX_GTHRW(rwlock_trywrlock) + _GLIBCXX_GTHRW(rwlock_unlock) +# ifndef PTHREAD_RWLOCK_INITIALIZER + _GLIBCXX_GTHRW(rwlock_destroy) + __gthrw(pthread_rwlock_init); + static inline int + __glibcxx_rwlock_init (pthread_rwlock_t *__rwlock) + { + if (__gthread_active_p ()) + return __gthrw_(pthread_rwlock_init) (__rwlock, NULL); + else + return 0; + } +# endif +# if _GTHREAD_USE_MUTEX_TIMEDLOCK + __gthrw(pthread_rwlock_timedrdlock); + static inline int + __glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock, + const timespec *__ts) + { + if (__gthread_active_p ()) + return __gthrw_(pthread_rwlock_timedrdlock) (__rwlock, __ts); + else + return 0; + } + __gthrw(pthread_rwlock_timedwrlock); + static inline int + __glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock, + const timespec *__ts) + { + if (__gthread_active_p ()) + return __gthrw_(pthread_rwlock_timedwrlock) (__rwlock, __ts); + else + return 0; + } +# endif +#else + static inline int + __glibcxx_rwlock_rdlock (pthread_rwlock_t *__rwlock) + { return pthread_rwlock_rdlock (__rwlock); } + static inline int + __glibcxx_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) + { return pthread_rwlock_tryrdlock (__rwlock); } + static inline int + __glibcxx_rwlock_wrlock (pthread_rwlock_t *__rwlock) + { return pthread_rwlock_wrlock (__rwlock); } + static inline int + __glibcxx_rwlock_trywrlock (pthread_rwlock_t *__rwlock) + { return pthread_rwlock_trywrlock (__rwlock); } + static inline int + __glibcxx_rwlock_unlock (pthread_rwlock_t *__rwlock) + { return pthread_rwlock_unlock (__rwlock); } + static inline int + __glibcxx_rwlock_destroy(pthread_rwlock_t *__rwlock) + { return pthread_rwlock_destroy (__rwlock); } + static inline int + __glibcxx_rwlock_init(pthread_rwlock_t *__rwlock) + { return pthread_rwlock_init (__rwlock, NULL); } +# if _GTHREAD_USE_MUTEX_TIMEDLOCK + static inline int + __glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock, + const timespec *__ts) + { return pthread_rwlock_timedrdlock (__rwlock, __ts); } + static inline int + __glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock, + const timespec *__ts) + { return pthread_rwlock_timedwrlock (__rwlock, __ts); } +# endif +#endif + + /// A shared mutex type implemented using pthread_rwlock_t. + class __shared_mutex_pthread + { + friend class shared_timed_mutex; + +#ifdef PTHREAD_RWLOCK_INITIALIZER + pthread_rwlock_t _M_rwlock = PTHREAD_RWLOCK_INITIALIZER; + + public: + __shared_mutex_pthread() = default; + ~__shared_mutex_pthread() = default; +#else + pthread_rwlock_t _M_rwlock; + + public: + __shared_mutex_pthread() + { + int __ret = __glibcxx_rwlock_init(&_M_rwlock); + if (__ret == ENOMEM) + __throw_bad_alloc(); + else if (__ret == EAGAIN) + __throw_system_error(int(errc::resource_unavailable_try_again)); + else if (__ret == EPERM) + __throw_system_error(int(errc::operation_not_permitted)); + // Errors not handled: EBUSY, EINVAL + __glibcxx_assert(__ret == 0); + } + + ~__shared_mutex_pthread() + { + int __ret __attribute((__unused__)) = __glibcxx_rwlock_destroy(&_M_rwlock); + // Errors not handled: EBUSY, EINVAL + __glibcxx_assert(__ret == 0); + } +#endif + + __shared_mutex_pthread(const __shared_mutex_pthread&) = delete; + __shared_mutex_pthread& operator=(const __shared_mutex_pthread&) = delete; + + void + lock() + { + int __ret = __glibcxx_rwlock_wrlock(&_M_rwlock); + if (__ret == EDEADLK) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + } + + bool + try_lock() + { + int __ret = __glibcxx_rwlock_trywrlock(&_M_rwlock); + if (__ret == EBUSY) return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } + + void + unlock() + { + int __ret __attribute((__unused__)) = __glibcxx_rwlock_unlock(&_M_rwlock); + // Errors not handled: EPERM, EBUSY, EINVAL + __glibcxx_assert(__ret == 0); + } + + // Shared ownership + + void + lock_shared() + { + int __ret; + // We retry if we exceeded the maximum number of read locks supported by + // the POSIX implementation; this can result in busy-waiting, but this + // is okay based on the current specification of forward progress + // guarantees by the standard. + do + __ret = __glibcxx_rwlock_rdlock(&_M_rwlock); + while (__ret == EAGAIN); + if (__ret == EDEADLK) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + } + + bool + try_lock_shared() + { + int __ret = __glibcxx_rwlock_tryrdlock(&_M_rwlock); + // If the maximum number of read locks has been exceeded, we just fail + // to acquire the lock. Unlike for lock(), we are not allowed to throw + // an exception. + if (__ret == EBUSY || __ret == EAGAIN) return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } + + void + unlock_shared() + { + unlock(); + } + + void* native_handle() { return &_M_rwlock; } + }; +#endif + +#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK) + /// A shared mutex type implemented using std::condition_variable. + class __shared_mutex_cv + { + friend class shared_timed_mutex; + + // Based on Howard Hinnant's reference implementation from N2406. + + // The high bit of _M_state is the write-entered flag which is set to + // indicate a writer has taken the lock or is queuing to take the lock. + // The remaining bits are the count of reader locks. + // + // To take a reader lock, block on gate1 while the write-entered flag is + // set or the maximum number of reader locks is held, then increment the + // reader lock count. + // To release, decrement the count, then if the write-entered flag is set + // and the count is zero then signal gate2 to wake a queued writer, + // otherwise if the maximum number of reader locks was held signal gate1 + // to wake a reader. + // + // To take a writer lock, block on gate1 while the write-entered flag is + // set, then set the write-entered flag to start queueing, then block on + // gate2 while the number of reader locks is non-zero. + // To release, unset the write-entered flag and signal gate1 to wake all + // blocked readers and writers. + // + // This means that when no reader locks are held readers and writers get + // equal priority. When one or more reader locks is held a writer gets + // priority and no more reader locks can be taken while the writer is + // queued. + + // Only locked when accessing _M_state or waiting on condition variables. + mutex _M_mut; + // Used to block while write-entered is set or reader count at maximum. + condition_variable _M_gate1; + // Used to block queued writers while reader count is non-zero. + condition_variable _M_gate2; + // The write-entered flag and reader count. + unsigned _M_state; + + static constexpr unsigned _S_write_entered + = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1); + static constexpr unsigned _S_max_readers = ~_S_write_entered; + + // Test whether the write-entered flag is set. _M_mut must be locked. + bool _M_write_entered() const { return _M_state & _S_write_entered; } + + // The number of reader locks currently held. _M_mut must be locked. + unsigned _M_readers() const { return _M_state & _S_max_readers; } + + public: + __shared_mutex_cv() : _M_state(0) {} + + ~__shared_mutex_cv() + { + __glibcxx_assert( _M_state == 0 ); + } + + __shared_mutex_cv(const __shared_mutex_cv&) = delete; + __shared_mutex_cv& operator=(const __shared_mutex_cv&) = delete; + + // Exclusive ownership + + void + lock() + { + unique_lock __lk(_M_mut); + // Wait until we can set the write-entered flag. + _M_gate1.wait(__lk, [=]{ return !_M_write_entered(); }); + _M_state |= _S_write_entered; + // Then wait until there are no more readers. + _M_gate2.wait(__lk, [=]{ return _M_readers() == 0; }); + } + + bool + try_lock() + { + unique_lock __lk(_M_mut, try_to_lock); + if (__lk.owns_lock() && _M_state == 0) + { + _M_state = _S_write_entered; + return true; + } + return false; + } + + void + unlock() + { + lock_guard __lk(_M_mut); + __glibcxx_assert( _M_write_entered() ); + _M_state = 0; + // call notify_all() while mutex is held so that another thread can't + // lock and unlock the mutex then destroy *this before we make the call. + _M_gate1.notify_all(); + } + + // Shared ownership + + void + lock_shared() + { + unique_lock __lk(_M_mut); + _M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; }); + ++_M_state; + } + + bool + try_lock_shared() + { + unique_lock __lk(_M_mut, try_to_lock); + if (!__lk.owns_lock()) + return false; + if (_M_state < _S_max_readers) + { + ++_M_state; + return true; + } + return false; + } + + void + unlock_shared() + { + lock_guard __lk(_M_mut); + __glibcxx_assert( _M_readers() > 0 ); + auto __prev = _M_state--; + if (_M_write_entered()) + { + // Wake the queued writer if there are no more readers. + if (_M_readers() == 0) + _M_gate2.notify_one(); + // No need to notify gate1 because we give priority to the queued + // writer, and that writer will eventually notify gate1 after it + // clears the write-entered flag. + } + else + { + // Wake any thread that was blocked on reader overflow. + if (__prev == _S_max_readers) + _M_gate1.notify_one(); + } + } + }; +#endif + /// @endcond + +#if __cplusplus >= 201703L + /// The standard shared mutex type. + class shared_mutex + { + public: + shared_mutex() = default; + ~shared_mutex() = default; + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + + void lock() { _M_impl.lock(); } + bool try_lock() { return _M_impl.try_lock(); } + void unlock() { _M_impl.unlock(); } + + // Shared ownership + + void lock_shared() { _M_impl.lock_shared(); } + bool try_lock_shared() { return _M_impl.try_lock_shared(); } + void unlock_shared() { _M_impl.unlock_shared(); } + +#if _GLIBCXX_USE_PTHREAD_RWLOCK_T + typedef void* native_handle_type; + native_handle_type native_handle() { return _M_impl.native_handle(); } + + private: + __shared_mutex_pthread _M_impl; +#else + private: + __shared_mutex_cv _M_impl; +#endif + }; +#endif // C++17 + + /// @cond undocumented +#if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK + using __shared_timed_mutex_base = __shared_mutex_pthread; +#else + using __shared_timed_mutex_base = __shared_mutex_cv; +#endif + /// @endcond + + /// The standard shared timed mutex type. + class shared_timed_mutex + : private __shared_timed_mutex_base + { + using _Base = __shared_timed_mutex_base; + + // Must use the same clock as condition_variable for __shared_mutex_cv. +#ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK + using __clock_t = chrono::steady_clock; +#else + using __clock_t = chrono::system_clock; +#endif + + public: + shared_timed_mutex() = default; + ~shared_timed_mutex() = default; + + shared_timed_mutex(const shared_timed_mutex&) = delete; + shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; + + // Exclusive ownership + + void lock() { _Base::lock(); } + bool try_lock() { return _Base::try_lock(); } + void unlock() { _Base::unlock(); } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime); + if (ratio_greater<__clock_t::period, _Period>()) + ++__rt; + return try_lock_until(__clock_t::now() + __rt); + } + + // Shared ownership + + void lock_shared() { _Base::lock_shared(); } + bool try_lock_shared() { return _Base::try_lock_shared(); } + void unlock_shared() { _Base::unlock_shared(); } + + template + bool + try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rtime) + { + auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime); + if (ratio_greater<__clock_t::period, _Period>()) + ++__rt; + return try_lock_shared_until(__clock_t::now() + __rt); + } + +#if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK + + // Exclusive ownership + + template + bool + try_lock_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + int __ret = __glibcxx_rwlock_timedwrlock(&_M_rwlock, &__ts); + // On self-deadlock, we just fail to acquire the lock. Technically, + // the program violated the precondition. + if (__ret == ETIMEDOUT || __ret == EDEADLK) + return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } + +#ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK + template + bool + try_lock_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + int __ret = pthread_rwlock_clockwrlock(&_M_rwlock, CLOCK_MONOTONIC, + &__ts); + // On self-deadlock, we just fail to acquire the lock. Technically, + // the program violated the precondition. + if (__ret == ETIMEDOUT || __ret == EDEADLK) + return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } +#endif + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + // The user-supplied clock may not tick at the same rate as + // steady_clock, so we must loop in order to guarantee that + // the timeout has expired before returning false. + typename _Clock::time_point __now = _Clock::now(); + do { + auto __rtime = __atime - __now; + if (try_lock_for(__rtime)) + return true; + __now = _Clock::now(); + } while (__atime > __now); + return false; + } + + // Shared ownership + + template + bool + try_lock_shared_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + int __ret; + // Unlike for lock(), we are not allowed to throw an exception so if + // the maximum number of read locks has been exceeded, or we would + // deadlock, we just try to acquire the lock again (and will time out + // eventually). + // In cases where we would exceed the maximum number of read locks + // throughout the whole time until the timeout, we will fail to + // acquire the lock even if it would be logically free; however, this + // is allowed by the standard, and we made a "strong effort" + // (see C++14 30.4.1.4p26). + // For cases where the implementation detects a deadlock we + // intentionally block and timeout so that an early return isn't + // mistaken for a spurious failure, which might help users realise + // there is a deadlock. + do + __ret = __glibcxx_rwlock_timedrdlock(&_M_rwlock, &__ts); + while (__ret == EAGAIN || __ret == EDEADLK); + if (__ret == ETIMEDOUT) + return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } + +#ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK + template + bool + try_lock_shared_until(const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + int __ret = pthread_rwlock_clockrdlock(&_M_rwlock, CLOCK_MONOTONIC, + &__ts); + // On self-deadlock, we just fail to acquire the lock. Technically, + // the program violated the precondition. + if (__ret == ETIMEDOUT || __ret == EDEADLK) + return false; + // Errors not handled: EINVAL + __glibcxx_assert(__ret == 0); + return true; + } +#endif + + template + bool + try_lock_shared_until(const chrono::time_point<_Clock, + _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + // The user-supplied clock may not tick at the same rate as + // steady_clock, so we must loop in order to guarantee that + // the timeout has expired before returning false. + typename _Clock::time_point __now = _Clock::now(); + do { + auto __rtime = __atime - __now; + if (try_lock_shared_for(__rtime)) + return true; + __now = _Clock::now(); + } while (__atime > __now); + return false; + } + +#else // ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK) + + // Exclusive ownership + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) + { + unique_lock __lk(_M_mut); + if (!_M_gate1.wait_until(__lk, __abs_time, + [=]{ return !_M_write_entered(); })) + { + return false; + } + _M_state |= _S_write_entered; + if (!_M_gate2.wait_until(__lk, __abs_time, + [=]{ return _M_readers() == 0; })) + { + _M_state ^= _S_write_entered; + // Wake all threads blocked while the write-entered flag was set. + _M_gate1.notify_all(); + return false; + } + return true; + } + + // Shared ownership + + template + bool + try_lock_shared_until(const chrono::time_point<_Clock, + _Duration>& __abs_time) + { + unique_lock __lk(_M_mut); + if (!_M_gate1.wait_until(__lk, __abs_time, + [=]{ return _M_state < _S_max_readers; })) + { + return false; + } + ++_M_state; + return true; + } + +#endif // _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK + }; +#endif // _GLIBCXX_HAS_GTHREADS + + /// shared_lock + template + class shared_lock + { + public: + typedef _Mutex mutex_type; + + // Shared locking + + shared_lock() noexcept : _M_pm(nullptr), _M_owns(false) { } + + explicit + shared_lock(mutex_type& __m) + : _M_pm(std::__addressof(__m)), _M_owns(true) + { __m.lock_shared(); } + + shared_lock(mutex_type& __m, defer_lock_t) noexcept + : _M_pm(std::__addressof(__m)), _M_owns(false) { } + + shared_lock(mutex_type& __m, try_to_lock_t) + : _M_pm(std::__addressof(__m)), _M_owns(__m.try_lock_shared()) { } + + shared_lock(mutex_type& __m, adopt_lock_t) + : _M_pm(std::__addressof(__m)), _M_owns(true) { } + + template + shared_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __abs_time) + : _M_pm(std::__addressof(__m)), + _M_owns(__m.try_lock_shared_until(__abs_time)) { } + + template + shared_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rel_time) + : _M_pm(std::__addressof(__m)), + _M_owns(__m.try_lock_shared_for(__rel_time)) { } + + ~shared_lock() + { + if (_M_owns) + _M_pm->unlock_shared(); + } + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + shared_lock(shared_lock&& __sl) noexcept : shared_lock() + { swap(__sl); } + + shared_lock& + operator=(shared_lock&& __sl) noexcept + { + shared_lock(std::move(__sl)).swap(*this); + return *this; + } + + void + lock() + { + _M_lockable(); + _M_pm->lock_shared(); + _M_owns = true; + } + + bool + try_lock() + { + _M_lockable(); + return _M_owns = _M_pm->try_lock_shared(); + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + _M_lockable(); + return _M_owns = _M_pm->try_lock_shared_for(__rel_time); + } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) + { + _M_lockable(); + return _M_owns = _M_pm->try_lock_shared_until(__abs_time); + } + + void + unlock() + { + if (!_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + _M_pm->unlock_shared(); + _M_owns = false; + } + + // Setters + + void + swap(shared_lock& __u) noexcept + { + std::swap(_M_pm, __u._M_pm); + std::swap(_M_owns, __u._M_owns); + } + + mutex_type* + release() noexcept + { + _M_owns = false; + return std::__exchange(_M_pm, nullptr); + } + + // Getters + + bool owns_lock() const noexcept { return _M_owns; } + + explicit operator bool() const noexcept { return _M_owns; } + + mutex_type* mutex() const noexcept { return _M_pm; } + + private: + void + _M_lockable() const + { + if (_M_pm == nullptr) + __throw_system_error(int(errc::operation_not_permitted)); + if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + } + + mutex_type* _M_pm; + bool _M_owns; + }; + + /// Swap specialization for shared_lock + /// @relates shared_mutex + template + void + swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept + { __x.swap(__y); } + + /// @} group mutexes +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++14 + +#endif // _GLIBCXX_SHARED_MUTEX diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex.blob new file mode 100644 index 0000000000000000000000000000000000000000..1c069d8d5669ea2a35fd7e7c3b2cf1fe7d21e61a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@shared_mutex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream new file mode 100644 index 0000000000000000000000000000000000000000..bc7d636e702ea4352a182cc521fd32a06ca31b6f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream @@ -0,0 +1,1220 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/sstream + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.7 String-based streams +// + +#ifndef _GLIBCXX_SSTREAM +#define _GLIBCXX_SSTREAM 1 + +#pragma GCC system_header + +#include +#include +#include // allocator_traits, __allocator_like + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +# define _GLIBCXX_LVAL_REF_QUAL & +#else +# define _GLIBCXX_LVAL_REF_QUAL +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + // [27.7.1] template class basic_stringbuf + /** + * @brief The actual work of input and output (for std::string). + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * This class associates either or both of its input and output sequences + * with a sequence of characters, which can be initialized from, or made + * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.) + * + * For this class, open modes (of type @c ios_base::openmode) have + * @c in set if the input sequence can be read, and @c out set if the + * output sequence can be written. + */ + template + class basic_stringbuf : public basic_streambuf<_CharT, _Traits> + { + struct __xfer_bufptrs; + +#if __cplusplus >= 201103L + using allocator_traits = std::allocator_traits<_Alloc>; + using _Noexcept_swap + = __or_; +#endif + + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + typedef basic_streambuf __streambuf_type; + typedef basic_string __string_type; + typedef typename __string_type::size_type __size_type; + + protected: + /// Place to stash in || out || in | out settings for current stringbuf. + ios_base::openmode _M_mode; + + // Data Members: + __string_type _M_string; + + public: + // Constructors: + + /** + * @brief Starts with an empty string buffer. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ + basic_stringbuf() + : __streambuf_type(), _M_mode(ios_base::in | ios_base::out), _M_string() + { } + + /** + * @brief Starts with an empty string buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * The default constructor initializes the parent class using its + * own default ctor. + */ + explicit + basic_stringbuf(ios_base::openmode __mode) + : __streambuf_type(), _M_mode(__mode), _M_string() + { } + + /** + * @brief Starts with an existing string buffer. + * @param __str A string to copy as a starting buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * This constructor initializes the parent class using its + * own default ctor. + */ + explicit + basic_stringbuf(const __string_type& __str, + ios_base::openmode __mode = ios_base::in | ios_base::out) + : __streambuf_type(), _M_mode(), + _M_string(__str.data(), __str.size(), __str.get_allocator()) + { _M_stringbuf_init(__mode); } + +#if __cplusplus >= 201103L + basic_stringbuf(const basic_stringbuf&) = delete; + + basic_stringbuf(basic_stringbuf&& __rhs) + : basic_stringbuf(std::move(__rhs), __xfer_bufptrs(__rhs, this)) + { __rhs._M_sync(const_cast(__rhs._M_string.data()), 0, 0); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + explicit + basic_stringbuf(const allocator_type& __a) + : basic_stringbuf(ios_base::in | std::ios_base::out, __a) + { } + + basic_stringbuf(ios_base::openmode __mode, + const allocator_type& __a) + : __streambuf_type(), _M_mode(__mode), _M_string(__a) + { } + + explicit + basic_stringbuf(__string_type&& __s, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : __streambuf_type(), _M_mode(__mode), _M_string(std::move(__s)) + { _M_stringbuf_init(__mode); } + + template + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + const allocator_type& __a) + : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a) + { } + + template + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + ios_base::openmode __mode, + const allocator_type& __a) + : __streambuf_type(), _M_mode(__mode), + _M_string(__s.data(), __s.size(), __a) + { _M_stringbuf_init(__mode); } + + template + explicit + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : basic_stringbuf(__s, __mode, allocator_type{}) + { } + + basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) + : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this)) + { __rhs._M_sync(const_cast(__rhs._M_string.data()), 0, 0); } + + allocator_type get_allocator() const noexcept + { return _M_string.get_allocator(); } +#endif // C++20 + + // 27.8.2.2 Assign and swap: + + basic_stringbuf& + operator=(const basic_stringbuf&) = delete; + + basic_stringbuf& + operator=(basic_stringbuf&& __rhs) + { + __xfer_bufptrs __st{__rhs, this}; + const __streambuf_type& __base = __rhs; + __streambuf_type::operator=(__base); + this->pubimbue(__rhs.getloc()); + _M_mode = __rhs._M_mode; + _M_string = std::move(__rhs._M_string); + __rhs._M_sync(const_cast(__rhs._M_string.data()), 0, 0); + return *this; + } + + void + swap(basic_stringbuf& __rhs) noexcept(_Noexcept_swap::value) + { + __xfer_bufptrs __l_st{*this, std::__addressof(__rhs)}; + __xfer_bufptrs __r_st{__rhs, this}; + __streambuf_type& __base = __rhs; + __streambuf_type::swap(__base); + __rhs.pubimbue(this->pubimbue(__rhs.getloc())); + std::swap(_M_mode, __rhs._M_mode); + std::swap(_M_string, __rhs._M_string); // XXX not exception safe + } +#endif // C++11 + + // Getters and setters: + + /** + * @brief Copying out the string buffer. + * @return A copy of one of the underlying sequences. + * + * If the buffer is only created in input mode, the underlying + * character sequence is equal to the input sequence; otherwise, it + * is equal to the output sequence. [27.7.1.2]/1 + */ + __string_type + str() const _GLIBCXX_LVAL_REF_QUAL + { + __string_type __ret(_M_string.get_allocator()); + if (char_type* __hi = _M_high_mark()) + __ret.assign(this->pbase(), __hi); + else + __ret = _M_string; + return __ret; + } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + basic_string<_CharT, _Traits, _SAlloc> + str(const _SAlloc& __sa) const + { + auto __sv = view(); + return { __sv.data(), __sv.size(), __sa }; + } +#endif + + __string_type + str() && + { + if (char_type* __hi = _M_high_mark()) + { + // Set length to end of character sequence and add null terminator. + _M_string._M_set_length(_M_high_mark() - this->pbase()); + } + auto __str = std::move(_M_string); + _M_string.clear(); + _M_sync(_M_string.data(), 0, 0); + return __str; + } + + basic_string_view + view() const noexcept + { + if (char_type* __hi = _M_high_mark()) + return { this->pbase(), __hi }; + else + return _M_string; + } +#endif // C++20 + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Deallocates any previous stored sequence, then copies @a s to + * use as a new one. + */ + void + str(const __string_type& __s) + { + // Cannot use _M_string = __s, since v3 strings are COW + // (not always true now but assign() always works). + _M_string.assign(__s.data(), __s.size()); + _M_stringbuf_init(_M_mode); + } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + requires (!is_same_v<_SAlloc, _Alloc>) + void + str(const basic_string<_CharT, _Traits, _SAlloc>& __s) + { + _M_string.assign(__s.data(), __s.size()); + _M_stringbuf_init(_M_mode); + } +#endif + + void + str(__string_type&& __s) + { + _M_string = std::move(__s); + _M_stringbuf_init(_M_mode); + } +#endif + + protected: + // Common initialization code goes here. + void + _M_stringbuf_init(ios_base::openmode __mode) + { + _M_mode = __mode; + __size_type __len = 0; + if (_M_mode & (ios_base::ate | ios_base::app)) + __len = _M_string.size(); + _M_sync(const_cast(_M_string.data()), 0, __len); + } + + virtual streamsize + showmanyc() + { + streamsize __ret = -1; + if (_M_mode & ios_base::in) + { + _M_update_egptr(); + __ret = this->egptr() - this->gptr(); + } + return __ret; + } + + virtual int_type + underflow(); + + virtual int_type + pbackfail(int_type __c = traits_type::eof()); + + virtual int_type + overflow(int_type __c = traits_type::eof()); + + /** + * @brief Manipulates the buffer. + * @param __s Pointer to a buffer area. + * @param __n Size of @a __s. + * @return @c this + * + * If no buffer has already been created, and both @a __s and @a __n are + * non-zero, then @c __s is used as a buffer; see + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering + * for more. + */ + virtual __streambuf_type* + setbuf(char_type* __s, streamsize __n) + { + if (__s && __n >= 0) + { + // This is implementation-defined behavior, and assumes + // that an external char_type array of length __n exists + // and has been pre-allocated. If this is not the case, + // things will quickly blow up. + + // Step 1: Destroy the current internal array. + _M_string.clear(); + + // Step 2: Use the external array. + _M_sync(__s, __n, 0); + } + return this; + } + + virtual pos_type + seekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + virtual pos_type + seekpos(pos_type __sp, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + // Internal function for correctly updating the internal buffer + // for a particular _M_string, due to initialization or re-sizing + // of an existing _M_string. + void + _M_sync(char_type* __base, __size_type __i, __size_type __o); + + // Internal function for correctly updating egptr() to the actual + // string end. + void + _M_update_egptr() + { + if (char_type* __pptr = this->pptr()) + { + char_type* __egptr = this->egptr(); + if (!__egptr || __pptr > __egptr) + { + if (_M_mode & ios_base::in) + this->setg(this->eback(), this->gptr(), __pptr); + else + this->setg(__pptr, __pptr, __pptr); + } + } + } + + // Works around the issue with pbump, part of the protected + // interface of basic_streambuf, taking just an int. + void + _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off); + + private: + // Return a pointer to the end of the underlying character sequence. + // This might not be the same character as _M_string.end() because + // basic_stringbuf::overflow might have written to unused capacity + // in _M_string without updating its length. + __attribute__((__always_inline__)) + char_type* + _M_high_mark() const _GLIBCXX_NOEXCEPT + { + if (char_type* __pptr = this->pptr()) + { + char_type* __egptr = this->egptr(); + if (!__egptr || __pptr > __egptr) + return __pptr; // Underlying sequence is [pbase, pptr). + else + return __egptr; // Underlying sequence is [pbase, egptr). + } + return 0; // Underlying character sequence is just _M_string. + } + +#if __cplusplus >= 201103L +#if _GLIBCXX_USE_CXX11_ABI + // This type captures the state of the gptr / pptr pointers as offsets + // so they can be restored in another object after moving the string. + struct __xfer_bufptrs + { + __xfer_bufptrs(const basic_stringbuf& __from, basic_stringbuf* __to) + : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1} + { + const _CharT* const __str = __from._M_string.data(); + const _CharT* __end = nullptr; + if (__from.eback()) + { + _M_goff[0] = __from.eback() - __str; + _M_goff[1] = __from.gptr() - __str; + _M_goff[2] = __from.egptr() - __str; + __end = __from.egptr(); + } + if (__from.pbase()) + { + _M_poff[0] = __from.pbase() - __str; + _M_poff[1] = __from.pptr() - __from.pbase(); + _M_poff[2] = __from.epptr() - __str; + if (!__end || __from.pptr() > __end) + __end = __from.pptr(); + } + + // Set _M_string length to the greater of the get and put areas. + if (__end) + { + // The const_cast avoids changing this constructor's signature, + // because it is exported from the dynamic library. + auto& __mut_from = const_cast(__from); + __mut_from._M_string._M_length(__end - __str); + } + } + + ~__xfer_bufptrs() + { + char_type* __str = const_cast(_M_to->_M_string.data()); + if (_M_goff[0] != -1) + _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]); + if (_M_poff[0] != -1) + _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]); + } + + basic_stringbuf* _M_to; + off_type _M_goff[3]; + off_type _M_poff[3]; + }; +#else + // This type does nothing when using Copy-On-Write strings. + struct __xfer_bufptrs + { + __xfer_bufptrs(const basic_stringbuf&, basic_stringbuf*) { } + }; +#endif + + // The move constructor initializes an __xfer_bufptrs temporary then + // delegates to this constructor to performs moves during its lifetime. + basic_stringbuf(basic_stringbuf&& __rhs, __xfer_bufptrs&&) + : __streambuf_type(static_cast(__rhs)), + _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string)) + { } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + // The move constructor initializes an __xfer_bufptrs temporary then + // delegates to this constructor to performs moves during its lifetime. + basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a, + __xfer_bufptrs&&) + : __streambuf_type(static_cast(__rhs)), + _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a) + { } +#endif +#endif // C++11 + }; + + + // [27.7.2] Template class basic_istringstream + /** + * @brief Controlling input for std::string. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * This class supports reading from objects of type std::basic_string, + * using the inherited functions from std::basic_istream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ + template + class basic_istringstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_istream __istream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors: + + /** + * @brief Default constructor starts with an empty string buffer. + * + * Initializes @c sb using @c in, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + basic_istringstream() + : __istream_type(), _M_stringbuf(ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an empty string buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a __mode. + * + * Initializes @c sb using @c __mode|in, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_istringstream(ios_base::openmode __mode) + : __istream_type(), _M_stringbuf(__mode | ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param __str A string to copy as a starting buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * @c ios_base::in is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|in, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_istringstream(const __string_type& __str, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_istringstream() + { } + +#if __cplusplus >= 201103L + basic_istringstream(const basic_istringstream&) = delete; + + basic_istringstream(basic_istringstream&& __rhs) + : __istream_type(std::move(__rhs)), + _M_stringbuf(std::move(__rhs._M_stringbuf)) + { __istream_type::set_rdbuf(&_M_stringbuf); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + basic_istringstream(ios_base::openmode __mode, const allocator_type& __a) + : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a) + { this->init(std::__addressof(_M_stringbuf)); } + + explicit + basic_istringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::in) + : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in) + { this->init(std::__addressof(_M_stringbuf)); } + + template + basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_istringstream(__str, ios_base::in, __a) + { } + + template + basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, + const allocator_type& __a) + : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in, __a) + { this->init(std::__addressof(_M_stringbuf)); } + + template + explicit + basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::in) + : basic_istringstream(__str, __mode, allocator_type()) + { } +#endif // C++20 + + // 27.8.3.2 Assign and swap: + + basic_istringstream& + operator=(const basic_istringstream&) = delete; + + basic_istringstream& + operator=(basic_istringstream&& __rhs) + { + __istream_type::operator=(std::move(__rhs)); + _M_stringbuf = std::move(__rhs._M_stringbuf); + return *this; + } + + void + swap(basic_istringstream& __rhs) + { + __istream_type::swap(__rhs); + _M_stringbuf.swap(__rhs._M_stringbuf); + } +#endif // C++11 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const _GLIBCXX_LVAL_REF_QUAL + { return _M_stringbuf.str(); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + basic_string<_CharT, _Traits, _SAlloc> + str(const _SAlloc& __sa) const + { return _M_stringbuf.str(__sa); } +#endif + + __string_type + str() && + { return std::move(_M_stringbuf).str(); } + + basic_string_view + view() const noexcept + { return _M_stringbuf.view(); } +#endif + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + requires (!is_same_v<_SAlloc, _Alloc>) + void + str(const basic_string<_CharT, _Traits, _SAlloc>& __s) + { _M_stringbuf.str(__s); } +#endif + + void + str(__string_type&& __s) + { _M_stringbuf.str(std::move(__s)); } +#endif + }; + + + // [27.7.3] Template class basic_ostringstream + /** + * @brief Controlling output for std::string. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * This class supports writing to objects of type std::basic_string, + * using the inherited functions from std::basic_ostream. To control + * the associated sequence, an instance of std::basic_stringbuf is used, + * which this page refers to as @c sb. + */ + template + class basic_ostringstream : public basic_ostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_ostream __ostream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors/destructor: + + /** + * @brief Default constructor starts with an empty string buffer. + * + * Initializes @c sb using @c mode|out, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + basic_ostringstream() + : __ostream_type(), _M_stringbuf(ios_base::out) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an empty string buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @c mode|out, and passes @c &sb to the base + * class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_ostringstream(ios_base::openmode __mode) + : __ostream_type(), _M_stringbuf(__mode | ios_base::out) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param __str A string to copy as a starting buffer. + * @param __mode Whether the buffer can read, or write, or both. + * + * @c ios_base::out is automatically included in @a mode. + * + * Initializes @c sb using @a str and @c mode|out, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_ostringstream(const __string_type& __str, + ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_ostringstream() + { } + +#if __cplusplus >= 201103L + basic_ostringstream(const basic_ostringstream&) = delete; + + basic_ostringstream(basic_ostringstream&& __rhs) + : __ostream_type(std::move(__rhs)), + _M_stringbuf(std::move(__rhs._M_stringbuf)) + { __ostream_type::set_rdbuf(&_M_stringbuf); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a) + : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a) + { this->init(std::__addressof(_M_stringbuf)); } + + explicit + basic_ostringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::out) + : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out) + { this->init(std::__addressof(_M_stringbuf)); } + + template + basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_ostringstream(__str, ios_base::out, __a) + { } + + template + basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, + const allocator_type& __a) + : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out, __a) + { this->init(std::__addressof(_M_stringbuf)); } + + template + explicit + basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::out) + : basic_ostringstream(__str, __mode, allocator_type()) + { } +#endif // C++20 + + // 27.8.3.2 Assign and swap: + + basic_ostringstream& + operator=(const basic_ostringstream&) = delete; + + basic_ostringstream& + operator=(basic_ostringstream&& __rhs) + { + __ostream_type::operator=(std::move(__rhs)); + _M_stringbuf = std::move(__rhs._M_stringbuf); + return *this; + } + + void + swap(basic_ostringstream& __rhs) + { + __ostream_type::swap(__rhs); + _M_stringbuf.swap(__rhs._M_stringbuf); + } +#endif // C++11 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const _GLIBCXX_LVAL_REF_QUAL + { return _M_stringbuf.str(); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + basic_string<_CharT, _Traits, _SAlloc> + str(const _SAlloc& __sa) const + { return _M_stringbuf.str(__sa); } +#endif + + __string_type + str() && + { return std::move(_M_stringbuf).str(); } + + basic_string_view + view() const noexcept + { return _M_stringbuf.view(); } +#endif + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + requires (!is_same_v<_SAlloc, _Alloc>) + void + str(const basic_string<_CharT, _Traits, _SAlloc>& __s) + { _M_stringbuf.str(__s); } +#endif + + void + str(__string_type&& __s) + { _M_stringbuf.str(std::move(__s)); } +#endif + }; + + + // [27.7.4] Template class basic_stringstream + /** + * @brief Controlling input and output for std::string. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * This class supports reading from and writing to objects of type + * std::basic_string, using the inherited functions from + * std::basic_iostream. To control the associated sequence, an instance + * of std::basic_stringbuf is used, which this page refers to as @c sb. + */ + template + class basic_stringstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + // Non-standard Types: + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; + typedef basic_iostream __iostream_type; + + private: + __stringbuf_type _M_stringbuf; + + public: + // Constructors/destructors + + /** + * @brief Default constructor starts with an empty string buffer. + * + * Initializes @c sb using the mode @c in|out, and passes @c &sb + * to the base class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + basic_stringstream() + : __iostream_type(), _M_stringbuf(ios_base::out | ios_base::in) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an empty string buffer. + * @param __m Whether the buffer can read, or write, or both. + * + * Initializes @c sb using the mode from @c __m, and passes @c &sb + * to the base class initializer. Does not allocate any buffer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_stringstream(ios_base::openmode __m) + : __iostream_type(), _M_stringbuf(__m) + { this->init(&_M_stringbuf); } + + /** + * @brief Starts with an existing string buffer. + * @param __str A string to copy as a starting buffer. + * @param __m Whether the buffer can read, or write, or both. + * + * Initializes @c sb using @a __str and @c __m, and passes @c &sb + * to the base class initializer. + * + * That's a lie. We initialize the base class with NULL, because the + * string class does its own memory management. + */ + explicit + basic_stringstream(const __string_type& __str, + ios_base::openmode __m = ios_base::out | ios_base::in) + : __iostream_type(), _M_stringbuf(__str, __m) + { this->init(&_M_stringbuf); } + + /** + * @brief The destructor does nothing. + * + * The buffer is deallocated by the stringbuf object, not the + * formatting stream. + */ + ~basic_stringstream() + { } + +#if __cplusplus >= 201103L + basic_stringstream(const basic_stringstream&) = delete; + + basic_stringstream(basic_stringstream&& __rhs) + : __iostream_type(std::move(__rhs)), + _M_stringbuf(std::move(__rhs._M_stringbuf)) + { __iostream_type::set_rdbuf(&_M_stringbuf); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI + basic_stringstream(ios_base::openmode __mode, const allocator_type& __a) + : __iostream_type(), _M_stringbuf(__mode, __a) + { this->init(&_M_stringbuf); } + + explicit + basic_stringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : __iostream_type(), _M_stringbuf(std::move(__str), __mode) + { this->init(std::__addressof(_M_stringbuf)); } + + template + basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_stringstream(__str, ios_base::in | ios_base::out, __a) + { } + + template + basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, + const allocator_type& __a) + : __iostream_type(), _M_stringbuf(__str, __mode, __a) + { this->init(std::__addressof(_M_stringbuf)); } + + template + explicit + basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : basic_stringstream(__str, __mode, allocator_type()) + { } +#endif // C++20 + + // 27.8.3.2 Assign and swap: + + basic_stringstream& + operator=(const basic_stringstream&) = delete; + + basic_stringstream& + operator=(basic_stringstream&& __rhs) + { + __iostream_type::operator=(std::move(__rhs)); + _M_stringbuf = std::move(__rhs._M_stringbuf); + return *this; + } + + void + swap(basic_stringstream& __rhs) + { + __iostream_type::swap(__rhs); + _M_stringbuf.swap(__rhs._M_stringbuf); + } +#endif // C++11 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const _GLIBCXX_LVAL_REF_QUAL + { return _M_stringbuf.str(); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + basic_string<_CharT, _Traits, _SAlloc> + str(const _SAlloc& __sa) const + { return _M_stringbuf.str(__sa); } +#endif + + __string_type + str() && + { return std::move(_M_stringbuf).str(); } + + basic_string_view + view() const noexcept + { return _M_stringbuf.view(); } +#endif + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cpp_concepts + template<__allocator_like _SAlloc> + requires (!is_same_v<_SAlloc, _Alloc>) + void + str(const basic_string<_CharT, _Traits, _SAlloc>& __s) + { _M_stringbuf.str(__s); } +#endif + + void + str(__string_type&& __s) + { _M_stringbuf.str(std::move(__s)); } +#endif + }; + +#if __cplusplus >= 201103L + /// Swap specialization for stringbufs. + template + inline void + swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, + basic_stringbuf<_CharT, _Traits, _Allocator>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + /// Swap specialization for istringstreams. + template + inline void + swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, + basic_istringstream<_CharT, _Traits, _Allocator>& __y) + { __x.swap(__y); } + + /// Swap specialization for ostringstreams. + template + inline void + swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, + basic_ostringstream<_CharT, _Traits, _Allocator>& __y) + { __x.swap(__y); } + + /// Swap specialization for stringstreams. + template + inline void + swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, + basic_stringstream<_CharT, _Traits, _Allocator>& __y) + { __x.swap(__y); } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#undef _GLIBCXX_LVAL_REF_QUAL + +#include + +#endif /* _GLIBCXX_SSTREAM */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream.blob new file mode 100644 index 0000000000000000000000000000000000000000..8ac3cf97189ca6c3530a1c303c716bb6eea1bb63 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@sstream.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack new file mode 100644 index 0000000000000000000000000000000000000000..fc14e2edc2e4cab900c600fab8ebb5ce30689f84 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack @@ -0,0 +1,63 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/stack + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_STACK +#define _GLIBCXX_STACK 1 + +#pragma GCC system_header + +#include +#include + +#endif /* _GLIBCXX_STACK */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack.blob new file mode 100644 index 0000000000000000000000000000000000000000..561cea6839b16420cadb82ac104fe17183f5b88f Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stack.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept new file mode 100644 index 0000000000000000000000000000000000000000..7655681b72f28cb3ff3411e30ae0297060b22c54 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept @@ -0,0 +1,307 @@ +// Standard exception classes -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/stdexcept + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 19.1 Exception classes +// + +#ifndef _GLIBCXX_STDEXCEPT +#define _GLIBCXX_STDEXCEPT 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_DUAL_ABI +#if _GLIBCXX_USE_CXX11_ABI + // Emulates an old COW string when the new std::string is in use. + struct __cow_string + { + union { + const char* _M_p; + char _M_bytes[sizeof(const char*)]; + }; + + __cow_string(); + __cow_string(const std::string&); + __cow_string(const char*, size_t); + __cow_string(const __cow_string&) _GLIBCXX_NOTHROW; + __cow_string& operator=(const __cow_string&) _GLIBCXX_NOTHROW; + ~__cow_string(); +#if __cplusplus >= 201103L + __cow_string(__cow_string&&) noexcept; + __cow_string& operator=(__cow_string&&) noexcept; +#endif + }; + + typedef basic_string __sso_string; +#else // _GLIBCXX_USE_CXX11_ABI + typedef basic_string __cow_string; + + // Emulates a new SSO string when the old std::string is in use. + struct __sso_string + { + struct __str + { + const char* _M_p; + size_t _M_string_length; + char _M_local_buf[16]; + }; + + union { + __str _M_s; + char _M_bytes[sizeof(__str)]; + }; + + __sso_string() _GLIBCXX_NOTHROW; + __sso_string(const std::string&); + __sso_string(const char*, size_t); + __sso_string(const __sso_string&); + __sso_string& operator=(const __sso_string&); + ~__sso_string(); +#if __cplusplus >= 201103L + __sso_string(__sso_string&&) noexcept; + __sso_string& operator=(__sso_string&&) noexcept; +#endif + }; +#endif // _GLIBCXX_USE_CXX11_ABI +#else // _GLIBCXX_USE_DUAL_ABI + typedef basic_string __sso_string; + typedef basic_string __cow_string; +#endif + + /** + * @addtogroup exceptions + * @{ + */ + + /** Logic errors represent problems in the internal logic of a program; + * in theory, these are preventable, and even detectable before the + * program runs (e.g., violations of class invariants). + * @brief One of two subclasses of exception. + */ + class logic_error : public exception + { + __cow_string _M_msg; + + public: + /** Takes a character string describing the error. */ + explicit + logic_error(const string& __arg) _GLIBCXX_TXN_SAFE; + +#if __cplusplus >= 201103L + explicit + logic_error(const char*) _GLIBCXX_TXN_SAFE; + + logic_error(logic_error&&) noexcept; + logic_error& operator=(logic_error&&) noexcept; +#endif + +#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS + logic_error(const logic_error&) _GLIBCXX_NOTHROW; + logic_error& operator=(const logic_error&) _GLIBCXX_NOTHROW; +#elif __cplusplus >= 201103L + logic_error(const logic_error&) = default; + logic_error& operator=(const logic_error&) = default; +#endif + + virtual ~logic_error() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + + /** Returns a C-style character string describing the general cause of + * the current error (the same string passed to the ctor). */ + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + +# ifdef _GLIBCXX_TM_TS_INTERNAL + friend void* + ::_txnal_logic_error_get_msg(void* e); +# endif + }; + + /** Thrown by the library, or by you, to report domain errors (domain in + * the mathematical sense). */ + class domain_error : public logic_error + { + public: + explicit domain_error(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit domain_error(const char*) _GLIBCXX_TXN_SAFE; + domain_error(const domain_error&) = default; + domain_error& operator=(const domain_error&) = default; + domain_error(domain_error&&) = default; + domain_error& operator=(domain_error&&) = default; +#endif + virtual ~domain_error() _GLIBCXX_NOTHROW; + }; + + /** Thrown to report invalid arguments to functions. */ + class invalid_argument : public logic_error + { + public: + explicit invalid_argument(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit invalid_argument(const char*) _GLIBCXX_TXN_SAFE; + invalid_argument(const invalid_argument&) = default; + invalid_argument& operator=(const invalid_argument&) = default; + invalid_argument(invalid_argument&&) = default; + invalid_argument& operator=(invalid_argument&&) = default; +#endif + virtual ~invalid_argument() _GLIBCXX_NOTHROW; + }; + + /** Thrown when an object is constructed that would exceed its maximum + * permitted size (e.g., a basic_string instance). */ + class length_error : public logic_error + { + public: + explicit length_error(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit length_error(const char*) _GLIBCXX_TXN_SAFE; + length_error(const length_error&) = default; + length_error& operator=(const length_error&) = default; + length_error(length_error&&) = default; + length_error& operator=(length_error&&) = default; +#endif + virtual ~length_error() _GLIBCXX_NOTHROW; + }; + + /** This represents an argument whose value is not within the expected + * range (e.g., boundary checks in basic_string). */ + class out_of_range : public logic_error + { + public: + explicit out_of_range(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit out_of_range(const char*) _GLIBCXX_TXN_SAFE; + out_of_range(const out_of_range&) = default; + out_of_range& operator=(const out_of_range&) = default; + out_of_range(out_of_range&&) = default; + out_of_range& operator=(out_of_range&&) = default; +#endif + virtual ~out_of_range() _GLIBCXX_NOTHROW; + }; + + /** Runtime errors represent problems outside the scope of a program; + * they cannot be easily predicted and can generally only be caught as + * the program executes. + * @brief One of two subclasses of exception. + */ + class runtime_error : public exception + { + __cow_string _M_msg; + + public: + /** Takes a character string describing the error. */ + explicit + runtime_error(const string& __arg) _GLIBCXX_TXN_SAFE; + +#if __cplusplus >= 201103L + explicit + runtime_error(const char*) _GLIBCXX_TXN_SAFE; + + runtime_error(runtime_error&&) noexcept; + runtime_error& operator=(runtime_error&&) noexcept; +#endif + +#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS + runtime_error(const runtime_error&) _GLIBCXX_NOTHROW; + runtime_error& operator=(const runtime_error&) _GLIBCXX_NOTHROW; +#elif __cplusplus >= 201103L + runtime_error(const runtime_error&) = default; + runtime_error& operator=(const runtime_error&) = default; +#endif + + virtual ~runtime_error() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + + /** Returns a C-style character string describing the general cause of + * the current error (the same string passed to the ctor). */ + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + +# ifdef _GLIBCXX_TM_TS_INTERNAL + friend void* + ::_txnal_runtime_error_get_msg(void* e); +# endif + }; + + /** Thrown to indicate range errors in internal computations. */ + class range_error : public runtime_error + { + public: + explicit range_error(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit range_error(const char*) _GLIBCXX_TXN_SAFE; + range_error(const range_error&) = default; + range_error& operator=(const range_error&) = default; + range_error(range_error&&) = default; + range_error& operator=(range_error&&) = default; +#endif + virtual ~range_error() _GLIBCXX_NOTHROW; + }; + + /** Thrown to indicate arithmetic overflow. */ + class overflow_error : public runtime_error + { + public: + explicit overflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit overflow_error(const char*) _GLIBCXX_TXN_SAFE; + overflow_error(const overflow_error&) = default; + overflow_error& operator=(const overflow_error&) = default; + overflow_error(overflow_error&&) = default; + overflow_error& operator=(overflow_error&&) = default; +#endif + virtual ~overflow_error() _GLIBCXX_NOTHROW; + }; + + /** Thrown to indicate arithmetic underflow. */ + class underflow_error : public runtime_error + { + public: + explicit underflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; +#if __cplusplus >= 201103L + explicit underflow_error(const char*) _GLIBCXX_TXN_SAFE; + underflow_error(const underflow_error&) = default; + underflow_error& operator=(const underflow_error&) = default; + underflow_error(underflow_error&&) = default; + underflow_error& operator=(underflow_error&&) = default; +#endif + virtual ~underflow_error() _GLIBCXX_NOTHROW; + }; + + /// @} group exceptions + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_STDEXCEPT */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept.blob new file mode 100644 index 0000000000000000000000000000000000000000..525735a06614c74011332d5b06278f48d39bf338 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@stdexcept.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf new file mode 100644 index 0000000000000000000000000000000000000000..888611d12aaf7b7a54d7cab3b76d2dafd2612533 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf @@ -0,0 +1,860 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/streambuf + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 27.5 Stream buffers +// + +#ifndef _GLIBXX_STREAMBUF +#define _GLIBXX_STREAMBUF 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define _IsUnused __attribute__ ((__unused__)) + + template + streamsize + __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*, + basic_streambuf<_CharT, _Traits>*, bool&); + + /** + * @brief The actual work of input and output (interface). + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * This is a base class. Derived stream buffers each control a + * pair of character sequences: one for input, and one for output. + * + * Section [27.5.1] of the standard describes the requirements and + * behavior of stream buffer classes. That section (three paragraphs) + * is reproduced here, for simplicity and accuracy. + * + * -# Stream buffers can impose various constraints on the sequences + * they control. Some constraints are: + * - The controlled input sequence can be not readable. + * - The controlled output sequence can be not writable. + * - The controlled sequences can be associated with the contents of + * other representations for character sequences, such as external + * files. + * - The controlled sequences can support operations @e directly to or + * from associated sequences. + * - The controlled sequences can impose limitations on how the + * program can read characters from a sequence, write characters to + * a sequence, put characters back into an input sequence, or alter + * the stream position. + * . + * -# Each sequence is characterized by three pointers which, if non-null, + * all point into the same @c charT array object. The array object + * represents, at any moment, a (sub)sequence of characters from the + * sequence. Operations performed on a sequence alter the values + * stored in these pointers, perform reads and writes directly to or + * from associated sequences, and alter the stream position and + * conversion state as needed to maintain this subsequence relationship. + * The three pointers are: + * - the beginning pointer, or lowest element address in the + * array (called @e xbeg here); + * - the next pointer, or next element address that is a + * current candidate for reading or writing (called @e xnext here); + * - the end pointer, or first element address beyond the + * end of the array (called @e xend here). + * . + * -# The following semantic constraints shall always apply for any set + * of three pointers for a sequence, using the pointer names given + * immediately above: + * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall + * also be non-null pointers into the same @c charT array, as + * described above; otherwise, @e xbeg and @e xend shall also be null. + * - If @e xnext is not a null pointer and @e xnext < @e xend for an + * output sequence, then a write position is available. + * In this case, @e *xnext shall be assignable as the next element + * to write (to put, or to store a character value, into the sequence). + * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an + * input sequence, then a putback position is available. + * In this case, @e xnext[-1] shall have a defined value and is the + * next (preceding) element to store a character that is put back + * into the input sequence. + * - If @e xnext is not a null pointer and @e xnext< @e xend for an + * input sequence, then a read position is available. + * In this case, @e *xnext shall have a defined value and is the + * next element to read (to get, or to obtain a character value, + * from the sequence). + */ + template + class basic_streambuf + { + public: + ///@{ + /** + * These are standard types. They permit a standardized way of + * referring to names of (or names dependent on) the template + * parameters, which are specific to the implementation. + */ + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + ///@} + + ///@{ + /// This is a non-standard type. + typedef basic_streambuf __streambuf_type; + ///@} + + friend class basic_ios; + friend class basic_istream; + friend class basic_ostream; + friend class istreambuf_iterator; + friend class ostreambuf_iterator; + + friend streamsize + __copy_streambufs_eof<>(basic_streambuf*, basic_streambuf*, bool&); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_move_a2(istreambuf_iterator<_CharT2>, + istreambuf_iterator<_CharT2>, _CharT2*); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + istreambuf_iterator<_CharT2> >::__type + find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + const _CharT2&); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + void>::__type + advance(istreambuf_iterator<_CharT2>&, _Distance); + + friend void __istream_extract(istream&, char*, streamsize); + + template + friend basic_istream<_CharT2, _Traits2>& + operator>>(basic_istream<_CharT2, _Traits2>&, + basic_string<_CharT2, _Traits2, _Alloc>&); + + template + friend basic_istream<_CharT2, _Traits2>& + getline(basic_istream<_CharT2, _Traits2>&, + basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2); + + protected: + /* + * This is based on _IO_FILE, just reordered to be more consistent, + * and is intended to be the most minimal abstraction for an + * internal buffer. + * - get == input == read + * - put == output == write + */ + char_type* _M_in_beg; ///< Start of get area. + char_type* _M_in_cur; ///< Current read area. + char_type* _M_in_end; ///< End of get area. + char_type* _M_out_beg; ///< Start of put area. + char_type* _M_out_cur; ///< Current put area. + char_type* _M_out_end; ///< End of put area. + + /// Current locale setting. + locale _M_buf_locale; + + public: + /// Destructor deallocates no buffer space. + virtual + ~basic_streambuf() + { } + + // [27.5.2.2.1] locales + /** + * @brief Entry point for imbue(). + * @param __loc The new locale. + * @return The previous locale. + * + * Calls the derived imbue(__loc). + */ + locale + pubimbue(const locale& __loc) + { + locale __tmp(this->getloc()); + this->imbue(__loc); + _M_buf_locale = __loc; + return __tmp; + } + + /** + * @brief Locale access. + * @return The current locale in effect. + * + * If pubimbue(loc) has been called, then the most recent @c loc + * is returned. Otherwise the global locale in effect at the time + * of construction is returned. + */ + locale + getloc() const + { return _M_buf_locale; } + + // [27.5.2.2.2] buffer management and positioning + ///@{ + /** + * @brief Entry points for derived buffer functions. + * + * The public versions of @c pubfoo dispatch to the protected + * derived @c foo member functions, passing the arguments (if any) + * and returning the result unchanged. + */ + basic_streambuf* + pubsetbuf(char_type* __s, streamsize __n) + { return this->setbuf(__s, __n); } + + /** + * @brief Alters the stream position. + * @param __off Offset. + * @param __way Value for ios_base::seekdir. + * @param __mode Value for ios_base::openmode. + * + * Calls virtual seekoff function. + */ + pos_type + pubseekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { return this->seekoff(__off, __way, __mode); } + + /** + * @brief Alters the stream position. + * @param __sp Position + * @param __mode Value for ios_base::openmode. + * + * Calls virtual seekpos function. + */ + pos_type + pubseekpos(pos_type __sp, + ios_base::openmode __mode = ios_base::in | ios_base::out) + { return this->seekpos(__sp, __mode); } + + /** + * @brief Calls virtual sync function. + */ + int + pubsync() { return this->sync(); } + ///@} + + // [27.5.2.2.3] get area + /** + * @brief Looking ahead into the stream. + * @return The number of characters available. + * + * If a read position is available, returns the number of characters + * available for reading before the buffer must be refilled. + * Otherwise returns the derived @c showmanyc(). + */ + streamsize + in_avail() + { + const streamsize __ret = this->egptr() - this->gptr(); + return __ret ? __ret : this->showmanyc(); + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * Calls @c sbumpc(), and if that function returns + * @c traits::eof(), so does this function. Otherwise, @c sgetc(). + */ + int_type + snextc() + { + int_type __ret = traits_type::eof(); + if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(), + __ret), true)) + __ret = this->sgetc(); + return __ret; + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character + * and increments the read pointer, otherwise calls and returns + * @c uflow(). + */ + int_type + sbumpc() + { + int_type __ret; + if (__builtin_expect(this->gptr() < this->egptr(), true)) + { + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); + } + else + __ret = this->uflow(); + return __ret; + } + + /** + * @brief Getting the next character. + * @return The next character, or eof. + * + * If the input read position is available, returns that character, + * otherwise calls and returns @c underflow(). Does not move the + * read position after fetching the character. + */ + int_type + sgetc() + { + int_type __ret; + if (__builtin_expect(this->gptr() < this->egptr(), true)) + __ret = traits_type::to_int_type(*this->gptr()); + else + __ret = this->underflow(); + return __ret; + } + + /** + * @brief Entry point for xsgetn. + * @param __s A buffer area. + * @param __n A count. + * + * Returns xsgetn(__s,__n). The effect is to fill @a __s[0] through + * @a __s[__n-1] with characters from the input sequence, if possible. + */ + streamsize + sgetn(char_type* __s, streamsize __n) + { return this->xsgetn(__s, __n); } + + // [27.5.2.2.4] putback + /** + * @brief Pushing characters back into the input stream. + * @param __c The character to push back. + * @return The previous character, if possible. + * + * Similar to sungetc(), but @a __c is pushed onto the stream + * instead of the previous character. If successful, + * the next character fetched from the input stream will be @a + * __c. + */ + int_type + sputbackc(char_type __c) + { + int_type __ret; + const bool __testpos = this->eback() < this->gptr(); + if (__builtin_expect(!__testpos || + !traits_type::eq(__c, this->gptr()[-1]), false)) + __ret = this->pbackfail(traits_type::to_int_type(__c)); + else + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + return __ret; + } + + /** + * @brief Moving backwards in the input stream. + * @return The previous character, if possible. + * + * If a putback position is available, this function decrements + * the input pointer and returns that character. Otherwise, + * calls and returns pbackfail(). The effect is to @a unget + * the last character @a gotten. + */ + int_type + sungetc() + { + int_type __ret; + if (__builtin_expect(this->eback() < this->gptr(), true)) + { + this->gbump(-1); + __ret = traits_type::to_int_type(*this->gptr()); + } + else + __ret = this->pbackfail(); + return __ret; + } + + // [27.5.2.2.5] put area + /** + * @brief Entry point for all single-character output functions. + * @param __c A character to output. + * @return @a __c, if possible. + * + * One of two public output functions. + * + * If a write position is available for the output sequence (i.e., + * the buffer is not full), stores @a __c in that position, increments + * the position, and returns @c traits::to_int_type(__c). If a write + * position is not available, returns @c overflow(__c). + */ + int_type + sputc(char_type __c) + { + int_type __ret; + if (__builtin_expect(this->pptr() < this->epptr(), true)) + { + *this->pptr() = __c; + this->pbump(1); + __ret = traits_type::to_int_type(__c); + } + else + __ret = this->overflow(traits_type::to_int_type(__c)); + return __ret; + } + + /** + * @brief Entry point for all single-character output functions. + * @param __s A buffer read area. + * @param __n A count. + * + * One of two public output functions. + * + * + * Returns xsputn(__s,__n). The effect is to write @a __s[0] through + * @a __s[__n-1] to the output sequence, if possible. + */ + streamsize + sputn(const char_type* __s, streamsize __n) + { return this->xsputn(__s, __n); } + + protected: + /** + * @brief Base constructor. + * + * Only called from derived constructors, and sets up all the + * buffer data to zero, including the pointers described in the + * basic_streambuf class description. Note that, as a result, + * - the class starts with no read nor write positions available, + * - this is not an error + */ + basic_streambuf() + : _M_in_beg(0), _M_in_cur(0), _M_in_end(0), + _M_out_beg(0), _M_out_cur(0), _M_out_end(0), + _M_buf_locale(locale()) + { } + + // [27.5.2.3.1] get area access + ///@{ + /** + * @brief Access to the get area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - eback() returns the beginning pointer for the input sequence + * - gptr() returns the next pointer for the input sequence + * - egptr() returns the end pointer for the input sequence + */ + char_type* + eback() const { return _M_in_beg; } + + char_type* + gptr() const { return _M_in_cur; } + + char_type* + egptr() const { return _M_in_end; } + ///@} + + /** + * @brief Moving the read position. + * @param __n The delta by which to move. + * + * This just advances the read position without returning any data. + */ + void + gbump(int __n) { _M_in_cur += __n; } + + /** + * @brief Setting the three read area pointers. + * @param __gbeg A pointer. + * @param __gnext A pointer. + * @param __gend A pointer. + * @post @a __gbeg == @c eback(), @a __gnext == @c gptr(), and + * @a __gend == @c egptr() + */ + void + setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) + { + _M_in_beg = __gbeg; + _M_in_cur = __gnext; + _M_in_end = __gend; + } + + // [27.5.2.3.2] put area access + ///@{ + /** + * @brief Access to the put area. + * + * These functions are only available to other protected functions, + * including derived classes. + * + * - pbase() returns the beginning pointer for the output sequence + * - pptr() returns the next pointer for the output sequence + * - epptr() returns the end pointer for the output sequence + */ + char_type* + pbase() const { return _M_out_beg; } + + char_type* + pptr() const { return _M_out_cur; } + + char_type* + epptr() const { return _M_out_end; } + ///@} + + /** + * @brief Moving the write position. + * @param __n The delta by which to move. + * + * This just advances the write position without returning any data. + */ + void + pbump(int __n) { _M_out_cur += __n; } + + /** + * @brief Setting the three write area pointers. + * @param __pbeg A pointer. + * @param __pend A pointer. + * @post @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and + * @a __pend == @c epptr() + */ + void + setp(char_type* __pbeg, char_type* __pend) + { + _M_out_beg = _M_out_cur = __pbeg; + _M_out_end = __pend; + } + + // [27.5.2.4] virtual functions + // [27.5.2.4.1] locales + /** + * @brief Changes translations. + * @param __loc A new locale. + * + * Translations done during I/O which depend on the current + * locale are changed by this call. The standard adds, + * Between invocations of this function a class derived + * from streambuf can safely cache results of calls to locale + * functions and to members of facets so obtained. + * + * @note Base class version does nothing. + */ + virtual void + imbue(const locale& __loc _IsUnused) + { } + + // [27.5.2.4.2] buffer management and positioning + /** + * @brief Manipulates the buffer. + * + * Each derived class provides its own appropriate behavior. See + * the next-to-last paragraph of + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering + * for more on this function. + * + * @note Base class version does nothing, returns @c this. + */ + virtual basic_streambuf* + setbuf(char_type*, streamsize) + { return this; } + + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ + virtual pos_type + seekoff(off_type, ios_base::seekdir, + ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) + { return pos_type(off_type(-1)); } + + /** + * @brief Alters the stream positions. + * + * Each derived class provides its own appropriate behavior. + * @note Base class version does nothing, returns a @c pos_type + * that represents an invalid stream position. + */ + virtual pos_type + seekpos(pos_type, + ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) + { return pos_type(off_type(-1)); } + + /** + * @brief Synchronizes the buffer arrays with the controlled sequences. + * @return -1 on failure. + * + * Each derived class provides its own appropriate behavior, + * including the definition of @a failure. + * @note Base class version does nothing, returns zero. + */ + virtual int + sync() { return 0; } + + // [27.5.2.4.3] get area + /** + * @brief Investigating the data available. + * @return An estimate of the number of characters available in the + * input sequence, or -1. + * + * If it returns a positive value, then successive calls to + * @c underflow() will not return @c traits::eof() until at + * least that number of characters have been supplied. If @c + * showmanyc() returns -1, then calls to @c underflow() or @c + * uflow() will fail. [27.5.2.4.3]/1 + * + * @note Base class version does nothing, returns zero. + * @note The standard adds that the intention is not only that the + * calls [to underflow or uflow] will not return @c eof() but + * that they will return immediately. + * @note The standard adds that the morphemes of @c showmanyc are + * @b es-how-many-see, not @b show-manic. + */ + virtual streamsize + showmanyc() { return 0; } + + /** + * @brief Multiple character extraction. + * @param __s A buffer area. + * @param __n Maximum number of characters to assign. + * @return The number of characters assigned. + * + * Fills @a __s[0] through @a __s[__n-1] with characters from the input + * sequence, as if by @c sbumpc(). Stops when either @a __n characters + * have been copied, or when @c traits::eof() would be copied. + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ + virtual streamsize + xsgetn(char_type* __s, streamsize __n); + + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the pending sequence. + * + * Informally, this function is called when the input buffer is + * exhausted (or does not exist, as buffering need not actually be + * done). If a buffer exists, it is @a refilled. In either case, the + * next available character is returned, or @c traits::eof() to + * indicate a null pending sequence. + * + * For a formal definition of the pending sequence, see a good text + * such as Langer & Kreft, or [27.5.2.4.3]/7-14. + * + * A functioning input streambuf can be created by overriding only + * this function (no buffer area will be used). For an example, see + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + underflow() + { return traits_type::eof(); } + + /** + * @brief Fetches more data from the controlled sequence. + * @return The first character from the pending sequence. + * + * Informally, this function does the same thing as @c underflow(), + * and in fact is required to call that function. It also returns + * the new character, like @c underflow() does. However, this + * function also moves the read position forward by one. + */ + virtual int_type + uflow() + { + int_type __ret = traits_type::eof(); + const bool __testeof = traits_type::eq_int_type(this->underflow(), + __ret); + if (!__testeof) + { + __ret = traits_type::to_int_type(*this->gptr()); + this->gbump(1); + } + return __ret; + } + + // [27.5.2.4.4] putback + /** + * @brief Tries to back up the input sequence. + * @param __c The character to be inserted back into the sequence. + * @return eof() on failure, some other value on success + * @post The constraints of @c gptr(), @c eback(), and @c pptr() + * are the same as for @c underflow(). + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + pbackfail(int_type __c _IsUnused = traits_type::eof()) + { return traits_type::eof(); } + + // Put area: + /** + * @brief Multiple character insertion. + * @param __s A buffer area. + * @param __n Maximum number of characters to write. + * @return The number of characters written. + * + * Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if + * by @c sputc(). Stops when either @a n characters have been + * copied, or when @c sputc() would return @c traits::eof(). + * + * It is expected that derived classes provide a more efficient + * implementation by overriding this definition. + */ + virtual streamsize + xsputn(const char_type* __s, streamsize __n); + + /** + * @brief Consumes data from the buffer; writes to the + * controlled sequence. + * @param __c An additional character to consume. + * @return eof() to indicate failure, something else (usually + * @a __c, or not_eof()) + * + * Informally, this function is called when the output buffer + * is full (or does not exist, as buffering need not actually + * be done). If a buffer exists, it is @a consumed, with + * some effect on the controlled sequence. + * (Typically, the buffer is written out to the sequence + * verbatim.) In either case, the character @a c is also + * written out, if @a __c is not @c eof(). + * + * For a formal definition of this function, see a good text + * such as Langer & Kreft, or [27.5.2.4.5]/3-7. + * + * A functioning output streambuf can be created by overriding only + * this function (no buffer area will be used). + * + * @note Base class version does nothing, returns eof(). + */ + virtual int_type + overflow(int_type __c _IsUnused = traits_type::eof()) + { return traits_type::eof(); } + +#if _GLIBCXX_USE_DEPRECATED && __cplusplus <= 201402L + // Annex D.6 (removed in C++17) + public: + /** + * @brief Tosses a character. + * + * Advances the read pointer, ignoring the character that would have + * been read. + * + * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html + */ + _GLIBCXX_DEPRECATED_SUGGEST("std::basic_streambuf::sbumpc") + void + stossc() + { + if (this->gptr() < this->egptr()) + this->gbump(1); + else + this->uflow(); + } +#endif + + // Also used by specializations for char and wchar_t in src. + void + __safe_gbump(streamsize __n) { _M_in_cur += __n; } + + void + __safe_pbump(streamsize __n) { _M_out_cur += __n; } + +#if __cplusplus < 201103L + private: +#else + protected: +#endif + basic_streambuf(const basic_streambuf&); + + basic_streambuf& + operator=(const basic_streambuf&); + +#if __cplusplus >= 201103L + void + swap(basic_streambuf& __sb) + { + std::swap(_M_in_beg, __sb._M_in_beg); + std::swap(_M_in_cur, __sb._M_in_cur); + std::swap(_M_in_end, __sb._M_in_end); + std::swap(_M_out_beg, __sb._M_out_beg); + std::swap(_M_out_cur, __sb._M_out_cur); + std::swap(_M_out_end, __sb._M_out_end); + std::swap(_M_buf_locale, __sb._M_buf_locale); + } +#endif + }; + +#if __cplusplus >= 201103L + template + std::basic_streambuf<_CharT, _Traits>:: + basic_streambuf(const basic_streambuf&) = default; + + template + std::basic_streambuf<_CharT, _Traits>& + std::basic_streambuf<_CharT, _Traits>:: + operator=(const basic_streambuf&) = default; +#endif + + // Explicit specialization declarations, defined in src/streambuf.cc. + template<> + streamsize + __copy_streambufs_eof(basic_streambuf* __sbin, + basic_streambuf* __sbout, bool& __ineof); +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + streamsize + __copy_streambufs_eof(basic_streambuf* __sbin, + basic_streambuf* __sbout, bool& __ineof); +#endif + +#undef _IsUnused + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _GLIBCXX_STREAMBUF */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf.blob new file mode 100644 index 0000000000000000000000000000000000000000..f4264510f482942cb62206a88eb616ebf75efeab Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@streambuf.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string new file mode 100644 index 0000000000000000000000000000000000000000..b1d8b6a34dd12cc34a6cc50dd3943f061d2af92c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string @@ -0,0 +1,149 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/string + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _GLIBCXX_STRING +#define _GLIBCXX_STRING 1 + +#pragma GCC system_header + +#include +#include +#include // NB: In turn includes stl_algobase.h +#include +#include +#include // For operators >>, <<, and getline. +#include +#include +#include +#include +#include // For less +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr { + template class polymorphic_allocator; + template> + using basic_string = std::basic_string<_CharT, _Traits, + polymorphic_allocator<_CharT>>; + using string = basic_string; +#ifdef _GLIBCXX_USE_CHAR8_T + using u8string = basic_string; +#endif + using u16string = basic_string; + using u32string = basic_string; + using wstring = basic_string; + } // namespace pmr + + template + struct __hash_string_base + : public __hash_base + { + size_t + operator()(const _Str& __s) const noexcept + { return hash>{}(__s); } + }; + + template<> + struct hash + : public __hash_string_base + { }; +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct hash + : public __hash_string_base + { }; +#endif + template<> + struct hash + : public __hash_string_base + { }; + template<> + struct hash + : public __hash_string_base + { }; + template<> + struct hash + : public __hash_string_base + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + _GLIBCXX20_CONSTEXPR + inline typename basic_string<_CharT, _Traits, _Alloc>::size_type + erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred) + { + using namespace __gnu_cxx; + const auto __osz = __cont.size(); + const auto __end = __cont.end(); + auto __removed = std::__remove_if(__cont.begin(), __end, + __ops::__pred_iter(std::ref(__pred))); + __cont.erase(__removed, __end); + return __osz - __cont.size(); + } + + template + _GLIBCXX20_CONSTEXPR + inline typename basic_string<_CharT, _Traits, _Alloc>::size_type + erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value) + { + using namespace __gnu_cxx; + const auto __osz = __cont.size(); + const auto __end = __cont.end(); + auto __removed = std::__remove_if(__cont.begin(), __end, + __ops::__iter_equals_val(__value)); + __cont.erase(__removed, __end); + return __osz - __cont.size(); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_STRING */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string.blob new file mode 100644 index 0000000000000000000000000000000000000000..0b0abd630fd2edf009f5ed2e2eebf1b86bf7387a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@string.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error new file mode 100644 index 0000000000000000000000000000000000000000..45a1d283556b0307bfcc6e9321da3bcd6f9a4f77 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error @@ -0,0 +1,531 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/system_error + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_SYSTEM_ERROR +#define _GLIBCXX_SYSTEM_ERROR 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup diagnostics + * @{ + */ + + class error_code; + class error_condition; + class system_error; + + /// is_error_code_enum + template + struct is_error_code_enum : public false_type { }; + + /// is_error_condition_enum + template + struct is_error_condition_enum : public false_type { }; + + template<> + struct is_error_condition_enum + : public true_type { }; + +#if __cplusplus > 201402L + template + inline constexpr bool is_error_code_enum_v = + is_error_code_enum<_Tp>::value; + template + inline constexpr bool is_error_condition_enum_v = + is_error_condition_enum<_Tp>::value; +#endif // C++17 + /// @} + + inline namespace _V2 { + + /** @addtogroup diagnostics + * @{ + */ + + /** Abstract base class for types defining a category of error codes. + * + * An error category defines a context that give meaning to the integer + * stored in an `error_code` or `error_condition` object. For example, + * the standard `errno` constants such a `EINVAL` and `ENOMEM` are + * associated with the "generic" category and other OS-specific error + * numbers are associated with the "system" category, but a user-defined + * category might give different meanings to the same numerical values. + * + * @since C++11 + */ + class error_category + { + public: + constexpr error_category() noexcept = default; + + virtual ~error_category(); + + error_category(const error_category&) = delete; + error_category& operator=(const error_category&) = delete; + + virtual const char* + name() const noexcept = 0; + + // We need two different virtual functions here, one returning a + // COW string and one returning an SSO string. Their positions in the + // vtable must be consistent for dynamic dispatch to work, but which one + // the name "message()" finds depends on which ABI the caller is using. +#if _GLIBCXX_USE_CXX11_ABI + private: + _GLIBCXX_DEFAULT_ABI_TAG + virtual __cow_string + _M_message(int) const; + + public: + _GLIBCXX_DEFAULT_ABI_TAG + virtual string + message(int) const = 0; +#else + virtual string + message(int) const = 0; + + private: + virtual __sso_string + _M_message(int) const; +#endif + + public: + virtual error_condition + default_error_condition(int __i) const noexcept; + + virtual bool + equivalent(int __i, const error_condition& __cond) const noexcept; + + virtual bool + equivalent(const error_code& __code, int __i) const noexcept; + + bool + operator==(const error_category& __other) const noexcept + { return this == &__other; } + +#if __cpp_lib_three_way_comparison + strong_ordering + operator<=>(const error_category& __rhs) const noexcept + { return std::compare_three_way()(this, &__rhs); } +#else + bool + operator!=(const error_category& __other) const noexcept + { return this != &__other; } + + bool + operator<(const error_category& __other) const noexcept + { return less()(this, &__other); } +#endif + }; + + // DR 890. + + /// Error category for `errno` error codes. + _GLIBCXX_CONST const error_category& generic_category() noexcept; + + /// Error category for other error codes defined by the OS. + _GLIBCXX_CONST const error_category& system_category() noexcept; + + /// @} + } // end inline namespace + + /** @addtogroup diagnostics + * @{ + */ + + error_code make_error_code(errc) noexcept; + + /** Class error_code + * + * This class is a value type storing an integer error number and a + * category that gives meaning to the error number. Typically this is done + * close the the point where the error happens, to capture the original + * error value. + * + * An `error_code` object can be used to store the original error value + * emitted by some subsystem, with a category relevant to the subsystem. + * For example, errors from POSIX library functions can be represented by + * an `errno` value and the "generic" category, but errors from an HTTP + * library might be represented by an HTTP response status code (e.g. 404) + * and a custom category defined by the library. + * + * @since C++11 + * @ingroup diagnostics + */ + class error_code + { + public: + error_code() noexcept + : _M_value(0), _M_cat(&system_category()) { } + + error_code(int __v, const error_category& __cat) noexcept + : _M_value(__v), _M_cat(&__cat) { } + + template::value>::type> + error_code(_ErrorCodeEnum __e) noexcept + { *this = make_error_code(__e); } + + void + assign(int __v, const error_category& __cat) noexcept + { + _M_value = __v; + _M_cat = &__cat; + } + + void + clear() noexcept + { assign(0, system_category()); } + + // DR 804. + template + typename enable_if::value, + error_code&>::type + operator=(_ErrorCodeEnum __e) noexcept + { return *this = make_error_code(__e); } + + int + value() const noexcept { return _M_value; } + + const error_category& + category() const noexcept { return *_M_cat; } + + error_condition + default_error_condition() const noexcept; + + _GLIBCXX_DEFAULT_ABI_TAG + string + message() const + { return category().message(value()); } + + explicit operator bool() const noexcept + { return _M_value != 0; } + + // DR 804. + private: + int _M_value; + const error_category* _M_cat; + }; + + // 19.4.2.6 non-member functions + + /// @relates error_code @{ + + inline error_code + make_error_code(errc __e) noexcept + { return error_code(static_cast(__e), generic_category()); } + +#if __cpp_lib_three_way_comparison + inline strong_ordering + operator<=>(const error_code& __lhs, const error_code& __rhs) noexcept + { + if (auto __c = __lhs.category() <=> __rhs.category(); __c != 0) + return __c; + return __lhs.value() <=> __rhs.value(); + } +#else + inline bool + operator<(const error_code& __lhs, const error_code& __rhs) noexcept + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } +#endif + + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) + { return (__os << __e.category().name() << ':' << __e.value()); } + + /// @} + + error_condition make_error_condition(errc) noexcept; + + /** Class error_condition + * + * This class represents error conditions that may be visible at an API + * boundary. Different `error_code` values that can occur within a library + * or module might map to the same `error_condition`. + * + * An `error_condition` represents something that the program can test for, + * and subsequently take appropriate action. + * + * @since C++11 + */ + class error_condition + { + public: + error_condition() noexcept + : _M_value(0), _M_cat(&generic_category()) { } + + error_condition(int __v, const error_category& __cat) noexcept + : _M_value(__v), _M_cat(&__cat) { } + + template::value>::type> + error_condition(_ErrorConditionEnum __e) noexcept + { *this = make_error_condition(__e); } + + void + assign(int __v, const error_category& __cat) noexcept + { + _M_value = __v; + _M_cat = &__cat; + } + + // DR 804. + template + typename enable_if::value, error_condition&>::type + operator=(_ErrorConditionEnum __e) noexcept + { return *this = make_error_condition(__e); } + + void + clear() noexcept + { assign(0, generic_category()); } + + // 19.4.3.4 observers + int + value() const noexcept { return _M_value; } + + const error_category& + category() const noexcept { return *_M_cat; } + + _GLIBCXX_DEFAULT_ABI_TAG + string + message() const + { return category().message(value()); } + + explicit operator bool() const noexcept + { return _M_value != 0; } + + // DR 804. + private: + int _M_value; + const error_category* _M_cat; + }; + + // 19.4.3.6 non-member functions + + /// Create an `error_condition` representing a standard `errc` condition. + /// @relates error_condition + inline error_condition + make_error_condition(errc __e) noexcept + { return error_condition(static_cast(__e), generic_category()); } + + // 19.4.4 Comparison operators + + /// @relates error_code + inline bool + operator==(const error_code& __lhs, const error_code& __rhs) noexcept + { return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); } + + /// @relates error_code + inline bool + operator==(const error_code& __lhs, const error_condition& __rhs) noexcept + { + return (__lhs.category().equivalent(__lhs.value(), __rhs) + || __rhs.category().equivalent(__lhs, __rhs.value())); + } + + /// @relates error_condition + inline bool + operator==(const error_condition& __lhs, + const error_condition& __rhs) noexcept + { + return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); + } + +#if __cpp_lib_three_way_comparison + /// Define an ordering for error_condition objects. + /// @relates error_condition + inline strong_ordering + operator<=>(const error_condition& __lhs, + const error_condition& __rhs) noexcept + { + if (auto __c = __lhs.category() <=> __rhs.category(); __c != 0) + return __c; + return __lhs.value() <=> __rhs.value(); + } +#else + /// Define an ordering for error_condition objects. + /// @relates error_condition + inline bool + operator<(const error_condition& __lhs, + const error_condition& __rhs) noexcept + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } + + /// @relates error_condition + inline bool + operator==(const error_condition& __lhs, const error_code& __rhs) noexcept + { + return (__rhs.category().equivalent(__rhs.value(), __lhs) + || __lhs.category().equivalent(__rhs, __lhs.value())); + } + + /// @relates error_code + inline bool + operator!=(const error_code& __lhs, const error_code& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// @relates error_code + inline bool + operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// @relates error_condition + inline bool + operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// @relates error_condition + inline bool + operator!=(const error_condition& __lhs, + const error_condition& __rhs) noexcept + { return !(__lhs == __rhs); } +#endif // three_way_comparison + /// @} + + /** + * @brief An exception type that includes an `error_code` value. + * + * Typically used to report errors from the operating system and other + * low-level APIs. + * + * @since C++11 + * @ingroup exceptions + */ + class system_error : public std::runtime_error + { + private: + error_code _M_code; + + public: + system_error(error_code __ec = error_code()) + : runtime_error(__ec.message()), _M_code(__ec) { } + + system_error(error_code __ec, const string& __what) + : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { } + + system_error(error_code __ec, const char* __what) + : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { } + + system_error(int __v, const error_category& __ecat, const char* __what) + : system_error(error_code(__v, __ecat), __what) { } + + system_error(int __v, const error_category& __ecat) + : runtime_error(error_code(__v, __ecat).message()), + _M_code(__v, __ecat) { } + + system_error(int __v, const error_category& __ecat, const string& __what) + : runtime_error(__what + ": " + error_code(__v, __ecat).message()), + _M_code(__v, __ecat) { } + +#if __cplusplus >= 201103L + system_error (const system_error &) = default; + system_error &operator= (const system_error &) = default; +#endif + + virtual ~system_error() noexcept; + + const error_code& + code() const noexcept { return _M_code; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifndef _GLIBCXX_COMPATIBILITY_CXX0X + // DR 1182. + /// std::hash specialization for error_code. + /// @relates error_code + template<> + struct hash + : public __hash_base + { + size_t + operator()(const error_code& __e) const noexcept + { + const size_t __tmp = std::_Hash_impl::hash(__e.value()); + return std::_Hash_impl::__hash_combine(&__e.category(), __tmp); + } + }; +#endif // _GLIBCXX_COMPATIBILITY_CXX0X + +#if __cplusplus >= 201703L + // DR 2686. + /// std::hash specialization for error_condition. + /// @relates error_condition + template<> + struct hash + : public __hash_base + { + size_t + operator()(const error_condition& __e) const noexcept + { + const size_t __tmp = std::_Hash_impl::hash(__e.value()); + return std::_Hash_impl::__hash_combine(&__e.category(), __tmp); + } + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_SYSTEM_ERROR diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error.blob new file mode 100644 index 0000000000000000000000000000000000000000..0784e5deccbd770bf9a8f68f1b8c6c8dacc72215 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@system_error.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread new file mode 100644 index 0000000000000000000000000000000000000000..92b24268ffe8eb226741a923b4c1844c5f4b2d39 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread @@ -0,0 +1,265 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/thread + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_THREAD +#define _GLIBCXX_THREAD 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#if __cplusplus > 201703L +# include // std::strong_ordering +# include // std::stop_source, std::stop_token, std::nostopstate +#endif + +#include // std::thread, get_id, yield +#include // std::this_thread::sleep_for, sleep_until + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup threads Threads + * @ingroup concurrency + * + * Classes for thread support. + * @{ + */ + + // std::thread is defined in + +#if __cpp_lib_three_way_comparison + inline strong_ordering + operator<=>(thread::id __x, thread::id __y) noexcept + { return __x._M_thread <=> __y._M_thread; } +#else + inline bool + operator!=(thread::id __x, thread::id __y) noexcept + { return !(__x == __y); } + + inline bool + operator<(thread::id __x, thread::id __y) noexcept + { + // Pthreads doesn't define any way to do this, so we just have to + // assume native_handle_type is LessThanComparable. + return __x._M_thread < __y._M_thread; + } + + inline bool + operator<=(thread::id __x, thread::id __y) noexcept + { return !(__y < __x); } + + inline bool + operator>(thread::id __x, thread::id __y) noexcept + { return __y < __x; } + + inline bool + operator>=(thread::id __x, thread::id __y) noexcept + { return !(__x < __y); } +#endif // __cpp_lib_three_way_comparison + + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id) + { + if (__id == thread::id()) + return __out << "thread::id of a non-executing thread"; + else + return __out << __id._M_thread; + } + +#ifdef __cpp_lib_jthread + +#ifndef __STRICT_ANSI__ + template + constexpr bool __pmf_expects_stop_token = false; + + template + constexpr bool __pmf_expects_stop_token<_Callable, _Obj, _Args...> + = __and_>, + is_invocable<_Callable, _Obj, stop_token, _Args...>>::value; +#endif + + /// A thread that can be requested to stop and automatically joined. + class jthread + { + public: + using id = thread::id; + using native_handle_type = thread::native_handle_type; + + jthread() noexcept + : _M_stop_source{nostopstate} + { } + + template, + jthread>>> + explicit + jthread(_Callable&& __f, _Args&&... __args) + : _M_thread{_S_create(_M_stop_source, std::forward<_Callable>(__f), + std::forward<_Args>(__args)...)} + { } + + jthread(const jthread&) = delete; + jthread(jthread&&) noexcept = default; + + ~jthread() + { + if (joinable()) + { + request_stop(); + join(); + } + } + + jthread& + operator=(const jthread&) = delete; + + jthread& + operator=(jthread&& __other) noexcept + { + std::jthread(std::move(__other)).swap(*this); + return *this; + } + + void + swap(jthread& __other) noexcept + { + std::swap(_M_stop_source, __other._M_stop_source); + std::swap(_M_thread, __other._M_thread); + } + + [[nodiscard]] bool + joinable() const noexcept + { + return _M_thread.joinable(); + } + + void + join() + { + _M_thread.join(); + } + + void + detach() + { + _M_thread.detach(); + } + + [[nodiscard]] id + get_id() const noexcept + { + return _M_thread.get_id(); + } + + [[nodiscard]] native_handle_type + native_handle() + { + return _M_thread.native_handle(); + } + + [[nodiscard]] static unsigned + hardware_concurrency() noexcept + { + return thread::hardware_concurrency(); + } + + [[nodiscard]] stop_source + get_stop_source() noexcept + { + return _M_stop_source; + } + + [[nodiscard]] stop_token + get_stop_token() const noexcept + { + return _M_stop_source.get_token(); + } + + bool request_stop() noexcept + { + return _M_stop_source.request_stop(); + } + + friend void swap(jthread& __lhs, jthread& __rhs) noexcept + { + __lhs.swap(__rhs); + } + + private: + template + static thread + _S_create(stop_source& __ssrc, _Callable&& __f, _Args&&... __args) + { +#ifndef __STRICT_ANSI__ + if constexpr (__pmf_expects_stop_token<_Callable, _Args...>) + return _S_create_pmf(__ssrc, __f, std::forward<_Args>(__args)...); + else +#endif + if constexpr(is_invocable_v, stop_token, + decay_t<_Args>...>) + return thread{std::forward<_Callable>(__f), __ssrc.get_token(), + std::forward<_Args>(__args)...}; + else + { + static_assert(is_invocable_v, + decay_t<_Args>...>, + "std::jthread arguments must be invocable after" + " conversion to rvalues"); + return thread{std::forward<_Callable>(__f), + std::forward<_Args>(__args)...}; + } + } + +#ifndef __STRICT_ANSI__ + template + static thread + _S_create_pmf(stop_source& __ssrc, _Callable __f, _Obj&& __obj, + _Args&&... __args) + { + return thread{__f, std::forward<_Obj>(__obj), __ssrc.get_token(), + std::forward<_Args>(__args)...}; + } +#endif + + stop_source _M_stop_source; + thread _M_thread; + }; +#endif // __cpp_lib_jthread + + /// @} group threads + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 +#endif // _GLIBCXX_THREAD diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread.blob new file mode 100644 index 0000000000000000000000000000000000000000..86a147f35ea6ae3eccaa837b7794788488a4a5a9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@thread.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple new file mode 100644 index 0000000000000000000000000000000000000000..6d0060a191c6da3631477e5ca43e8c16bf62f9e7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple @@ -0,0 +1,1893 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/tuple + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_TUPLE +#define _GLIBCXX_TUPLE 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include // for std::pair +#include // for std::allocator_arg_t +#include // for std::get, std::tuple_size etc. +#include // for std::__invoke +#if __cplusplus > 201703L +# include +# define __cpp_lib_constexpr_tuple 201811L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + template + class tuple; + + template + struct __is_empty_non_tuple : is_empty<_Tp> { }; + + // Using EBO for elements that are tuples causes ambiguous base errors. + template + struct __is_empty_non_tuple> : false_type { }; + + // Use the Empty Base-class Optimization for empty, non-final types. + template + using __empty_not_final + = __conditional_t<__is_final(_Tp), false_type, + __is_empty_non_tuple<_Tp>>; + + template::value> + struct _Head_base; + +#if __has_cpp_attribute(__no_unique_address__) + template + struct _Head_base<_Idx, _Head, true> + { + constexpr _Head_base() + : _M_head_impl() { } + + constexpr _Head_base(const _Head& __h) + : _M_head_impl(__h) { } + + constexpr _Head_base(const _Head_base&) = default; + constexpr _Head_base(_Head_base&&) = default; + + template + constexpr _Head_base(_UHead&& __h) + : _M_head_impl(std::forward<_UHead>(__h)) { } + + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc0) + : _M_head_impl() { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) + : _M_head_impl(allocator_arg, *__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) + : _M_head_impl(*__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc0, _UHead&& __uhead) + : _M_head_impl(std::forward<_UHead>(__uhead)) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) + : _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead) + : _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { } + + static constexpr _Head& + _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; } + + static constexpr const _Head& + _M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; } + + [[__no_unique_address__]] _Head _M_head_impl; + }; +#else + template + struct _Head_base<_Idx, _Head, true> + : public _Head + { + constexpr _Head_base() + : _Head() { } + + constexpr _Head_base(const _Head& __h) + : _Head(__h) { } + + constexpr _Head_base(const _Head_base&) = default; + constexpr _Head_base(_Head_base&&) = default; + + template + constexpr _Head_base(_UHead&& __h) + : _Head(std::forward<_UHead>(__h)) { } + + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc0) + : _Head() { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) + : _Head(allocator_arg, *__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) + : _Head(*__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc0, _UHead&& __uhead) + : _Head(std::forward<_UHead>(__uhead)) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) + : _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead) + : _Head(std::forward<_UHead>(__uhead), *__a._M_a) { } + + static constexpr _Head& + _M_head(_Head_base& __b) noexcept { return __b; } + + static constexpr const _Head& + _M_head(const _Head_base& __b) noexcept { return __b; } + }; +#endif + + template + struct _Head_base<_Idx, _Head, false> + { + constexpr _Head_base() + : _M_head_impl() { } + + constexpr _Head_base(const _Head& __h) + : _M_head_impl(__h) { } + + constexpr _Head_base(const _Head_base&) = default; + constexpr _Head_base(_Head_base&&) = default; + + template + constexpr _Head_base(_UHead&& __h) + : _M_head_impl(std::forward<_UHead>(__h)) { } + + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc0) + : _M_head_impl() { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) + : _M_head_impl(allocator_arg, *__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) + : _M_head_impl(*__a._M_a) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc0, _UHead&& __uhead) + : _M_head_impl(std::forward<_UHead>(__uhead)) { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) + : _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead) + : _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { } + + static constexpr _Head& + _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; } + + static constexpr const _Head& + _M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; } + + _Head _M_head_impl; + }; + + /** + * Contains the actual implementation of the @c tuple template, stored + * as a recursive inheritance hierarchy from the first element (most + * derived class) to the last (least derived class). The @c Idx + * parameter gives the 0-based index of the element stored at this + * point in the hierarchy; we use it to implement a constant-time + * get() operation. + */ + template + struct _Tuple_impl; + + /** + * Recursive tuple implementation. Here we store the @c Head element + * and derive from a @c Tuple_impl containing the remaining elements + * (which contains the @c Tail). + */ + template + struct _Tuple_impl<_Idx, _Head, _Tail...> + : public _Tuple_impl<_Idx + 1, _Tail...>, + private _Head_base<_Idx, _Head> + { + template friend struct _Tuple_impl; + + typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; + typedef _Head_base<_Idx, _Head> _Base; + + static constexpr _Head& + _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } + + static constexpr const _Head& + _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } + + static constexpr _Inherited& + _M_tail(_Tuple_impl& __t) noexcept { return __t; } + + static constexpr const _Inherited& + _M_tail(const _Tuple_impl& __t) noexcept { return __t; } + + constexpr _Tuple_impl() + : _Inherited(), _Base() { } + + explicit constexpr + _Tuple_impl(const _Head& __head, const _Tail&... __tail) + : _Inherited(__tail...), _Base(__head) + { } + + template> + explicit constexpr + _Tuple_impl(_UHead&& __head, _UTail&&... __tail) + : _Inherited(std::forward<_UTail>(__tail)...), + _Base(std::forward<_UHead>(__head)) + { } + + constexpr _Tuple_impl(const _Tuple_impl&) = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2729. Missing SFINAE on std::pair::operator= + _Tuple_impl& operator=(const _Tuple_impl&) = delete; + + _Tuple_impl(_Tuple_impl&&) = default; + + template + constexpr + _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in) + : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)), + _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) + : _Inherited(std::move + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), + _Base(std::forward<_UHead> + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) + : _Inherited(__tag, __a), + _Base(__tag, __use_alloc<_Head>(__a)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Head& __head, const _Tail&... __tail) + : _Inherited(__tag, __a, __tail...), + _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) + { } + + template> + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _UHead&& __head, _UTail&&... __tail) + : _Inherited(__tag, __a, std::forward<_UTail>(__tail)...), + _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), + std::forward<_UHead>(__head)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl& __in) + : _Inherited(__tag, __a, _M_tail(__in)), + _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl&& __in) + : _Inherited(__tag, __a, std::move(_M_tail(__in))), + _Base(__use_alloc<_Head, _Alloc, _Head>(__a), + std::forward<_Head>(_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl<_Idx, _UHead, _UTails...>& __in) + : _Inherited(__tag, __a, + _Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)), + _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a), + _Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl<_Idx, _UHead, _UTails...>&& __in) + : _Inherited(__tag, __a, std::move + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), + _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), + std::forward<_UHead> + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign(const _Tuple_impl<_Idx, _UElements...>& __in) + { + _M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in); + _M_tail(*this)._M_assign( + _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)); + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) + { + _M_head(*this) = std::forward<_UHead> + (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)); + _M_tail(*this)._M_assign( + std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))); + } + + protected: + _GLIBCXX20_CONSTEXPR + void + _M_swap(_Tuple_impl& __in) + { + using std::swap; + swap(_M_head(*this), _M_head(__in)); + _Inherited::_M_swap(_M_tail(__in)); + } + }; + + // Basis case of inheritance recursion. + template + struct _Tuple_impl<_Idx, _Head> + : private _Head_base<_Idx, _Head> + { + template friend struct _Tuple_impl; + + typedef _Head_base<_Idx, _Head> _Base; + + static constexpr _Head& + _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } + + static constexpr const _Head& + _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } + + constexpr + _Tuple_impl() + : _Base() { } + + explicit constexpr + _Tuple_impl(const _Head& __head) + : _Base(__head) + { } + + template + explicit constexpr + _Tuple_impl(_UHead&& __head) + : _Base(std::forward<_UHead>(__head)) + { } + + constexpr _Tuple_impl(const _Tuple_impl&) = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2729. Missing SFINAE on std::pair::operator= + _Tuple_impl& operator=(const _Tuple_impl&) = delete; + +#if _GLIBCXX_INLINE_VERSION + _Tuple_impl(_Tuple_impl&&) = default; +#else + constexpr + _Tuple_impl(_Tuple_impl&& __in) + noexcept(is_nothrow_move_constructible<_Head>::value) + : _Base(static_cast<_Base&&>(__in)) + { } +#endif + + template + constexpr + _Tuple_impl(const _Tuple_impl<_Idx, _UHead>& __in) + : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) + { } + + template + constexpr + _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in) + : _Base(std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) + : _Base(__tag, __use_alloc<_Head>(__a)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Head& __head) + : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _UHead&& __head) + : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), + std::forward<_UHead>(__head)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl& __in) + : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl&& __in) + : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), + std::forward<_Head>(_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Tuple_impl<_Idx, _UHead>& __in) + : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a), + _Tuple_impl<_Idx, _UHead>::_M_head(__in)) + { } + + template + _GLIBCXX20_CONSTEXPR + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + _Tuple_impl<_Idx, _UHead>&& __in) + : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), + std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) + { } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign(const _Tuple_impl<_Idx, _UHead>& __in) + { + _M_head(*this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in); + } + + template + _GLIBCXX20_CONSTEXPR + void + _M_assign(_Tuple_impl<_Idx, _UHead>&& __in) + { + _M_head(*this) + = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)); + } + + protected: + _GLIBCXX20_CONSTEXPR + void + _M_swap(_Tuple_impl& __in) + { + using std::swap; + swap(_M_head(*this), _M_head(__in)); + } + }; + + // Concept utility functions, reused in conditionally-explicit + // constructors. + template + struct _TupleConstraints + { + // Constraint for a non-explicit constructor. + // True iff each Ti in _Types... can be constructed from Ui in _UTypes... + // and every Ui is implicitly convertible to Ti. + template + static constexpr bool __is_implicitly_constructible() + { + return __and_..., + is_convertible<_UTypes, _Types>... + >::value; + } + + // Constraint for a non-explicit constructor. + // True iff each Ti in _Types... can be constructed from Ui in _UTypes... + // but not every Ui is implicitly convertible to Ti. + template + static constexpr bool __is_explicitly_constructible() + { + return __and_..., + __not_<__and_...>> + >::value; + } + + static constexpr bool __is_implicitly_default_constructible() + { + return __and_... + >::value; + } + + static constexpr bool __is_explicitly_default_constructible() + { + return __and_..., + __not_<__and_< + std::__is_implicitly_default_constructible<_Types>...> + >>::value; + } + }; + + // Partial specialization used when a required precondition isn't met, + // e.g. when sizeof...(_Types) != sizeof...(_UTypes). + template + struct _TupleConstraints + { + template + static constexpr bool __is_implicitly_constructible() + { return false; } + + template + static constexpr bool __is_explicitly_constructible() + { return false; } + }; + + /// Primary class template, tuple + template + class tuple : public _Tuple_impl<0, _Elements...> + { + typedef _Tuple_impl<0, _Elements...> _Inherited; + + template + using _TCC = _TupleConstraints<_Cond, _Elements...>; + + // Constraint for non-explicit default constructor + template + using _ImplicitDefaultCtor = __enable_if_t< + _TCC<_Dummy>::__is_implicitly_default_constructible(), + bool>; + + // Constraint for explicit default constructor + template + using _ExplicitDefaultCtor = __enable_if_t< + _TCC<_Dummy>::__is_explicitly_default_constructible(), + bool>; + + // Constraint for non-explicit constructors + template + using _ImplicitCtor = __enable_if_t< + _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(), + bool>; + + // Constraint for non-explicit constructors + template + using _ExplicitCtor = __enable_if_t< + _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(), + bool>; + + template + static constexpr + __enable_if_t + __assignable() + { return __and_...>::value; } + + // Condition for noexcept-specifier of an assignment operator. + template + static constexpr bool __nothrow_assignable() + { + return + __and_...>::value; + } + + // Condition for noexcept-specifier of a constructor. + template + static constexpr bool __nothrow_constructible() + { + return + __and_...>::value; + } + + // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) == 1. + template + static constexpr bool __valid_args() + { + return sizeof...(_Elements) == 1 + && !is_same>::value; + } + + // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) > 1. + template + static constexpr bool __valid_args() + { return (sizeof...(_Tail) + 2) == sizeof...(_Elements); } + + /* Constraint for constructors with a tuple parameter ensures + * that the constructor is only viable when it would not interfere with + * tuple(UTypes&&...) or tuple(const tuple&) or tuple(tuple&&). + * Such constructors are only viable if: + * either sizeof...(Types) != 1, + * or (when Types... expands to T and UTypes... expands to U) + * is_convertible_v, is_constructible_v, + * and is_same_v are all false. + */ + template> + struct _UseOtherCtor + : false_type + { }; + // If TUPLE is convertible to the single element in *this, + // then TUPLE should match tuple(UTypes&&...) instead. + template + struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>> + : __or_, is_constructible<_Tp, _Tuple>> + { }; + // If TUPLE and *this each have a single element of the same type, + // then TUPLE should match a copy/move constructor instead. + template + struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>> + : true_type + { }; + + // Return true iff sizeof...(Types) == 1 && tuple_size_v == 1 + // and the single element in Types can be initialized from TUPLE, + // or is the same type as tuple_element_t<0, TUPLE>. + template + static constexpr bool __use_other_ctor() + { return _UseOtherCtor<_Tuple>::value; } + + public: + template::value> = true> + constexpr + tuple() + noexcept(__and_...>::value) + : _Inherited() { } + + template::value> = false> + explicit constexpr + tuple() + noexcept(__and_...>::value) + : _Inherited() { } + + template= 1), + _ImplicitCtor<_NotEmpty, const _Elements&...> = true> + constexpr + tuple(const _Elements&... __elements) + noexcept(__nothrow_constructible()) + : _Inherited(__elements...) { } + + template= 1), + _ExplicitCtor<_NotEmpty, const _Elements&...> = false> + explicit constexpr + tuple(const _Elements&... __elements) + noexcept(__nothrow_constructible()) + : _Inherited(__elements...) { } + + template(), + _ImplicitCtor<_Valid, _UElements...> = true> + constexpr + tuple(_UElements&&... __elements) + noexcept(__nothrow_constructible<_UElements...>()) + : _Inherited(std::forward<_UElements>(__elements)...) { } + + template(), + _ExplicitCtor<_Valid, _UElements...> = false> + explicit constexpr + tuple(_UElements&&... __elements) + noexcept(__nothrow_constructible<_UElements...>()) + : _Inherited(std::forward<_UElements>(__elements)...) { } + + constexpr tuple(const tuple&) = default; + + constexpr tuple(tuple&&) = default; + + template&>(), + _ImplicitCtor<_Valid, const _UElements&...> = true> + constexpr + tuple(const tuple<_UElements...>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&>(__in)) + { } + + template&>(), + _ExplicitCtor<_Valid, const _UElements&...> = false> + explicit constexpr + tuple(const tuple<_UElements...>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&>(__in)) + { } + + template&&>(), + _ImplicitCtor<_Valid, _UElements...> = true> + constexpr + tuple(tuple<_UElements...>&& __in) + noexcept(__nothrow_constructible<_UElements...>()) + : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } + + template&&>(), + _ExplicitCtor<_Valid, _UElements...> = false> + explicit constexpr + tuple(tuple<_UElements...>&& __in) + noexcept(__nothrow_constructible<_UElements...>()) + : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } + + // Allocator-extended constructors. + + template::value> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a) + : _Inherited(__tag, __a) { } + + template= 1), + _ImplicitCtor<_NotEmpty, const _Elements&...> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const _Elements&... __elements) + : _Inherited(__tag, __a, __elements...) { } + + template= 1), + _ExplicitCtor<_NotEmpty, const _Elements&...> = false> + _GLIBCXX20_CONSTEXPR + explicit + tuple(allocator_arg_t __tag, const _Alloc& __a, + const _Elements&... __elements) + : _Inherited(__tag, __a, __elements...) { } + + template(), + _ImplicitCtor<_Valid, _UElements...> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + _UElements&&... __elements) + : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...) + { } + + template(), + _ExplicitCtor<_Valid, _UElements...> = false> + _GLIBCXX20_CONSTEXPR + explicit + tuple(allocator_arg_t __tag, const _Alloc& __a, + _UElements&&... __elements) + : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...) + { } + + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) + : _Inherited(__tag, __a, static_cast(__in)) { } + + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) + : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } + + template&>(), + _ImplicitCtor<_Valid, const _UElements&...> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_UElements...>& __in) + : _Inherited(__tag, __a, + static_cast&>(__in)) + { } + + template&>(), + _ExplicitCtor<_Valid, const _UElements&...> = false> + _GLIBCXX20_CONSTEXPR + explicit + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_UElements...>& __in) + : _Inherited(__tag, __a, + static_cast&>(__in)) + { } + + template&&>(), + _ImplicitCtor<_Valid, _UElements...> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + tuple<_UElements...>&& __in) + : _Inherited(__tag, __a, + static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) + { } + + template&&>(), + _ExplicitCtor<_Valid, _UElements...> = false> + _GLIBCXX20_CONSTEXPR + explicit + tuple(allocator_arg_t __tag, const _Alloc& __a, + tuple<_UElements...>&& __in) + : _Inherited(__tag, __a, + static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) + { } + + // tuple assignment + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(__conditional_t<__assignable(), + const tuple&, + const __nonesuch&> __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(__conditional_t<__assignable<_Elements...>(), + tuple&&, + __nonesuch&&> __in) + noexcept(__nothrow_assignable<_Elements...>()) + { + this->_M_assign(std::move(__in)); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable(), tuple&> + operator=(const tuple<_UElements...>& __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable<_UElements...>(), tuple&> + operator=(tuple<_UElements...>&& __in) + noexcept(__nothrow_assignable<_UElements...>()) + { + this->_M_assign(std::move(__in)); + return *this; + } + + // tuple swap + _GLIBCXX20_CONSTEXPR + void + swap(tuple& __in) + noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value) + { _Inherited::_M_swap(__in); } + }; + +#if __cpp_deduction_guides >= 201606 + template + tuple(_UTypes...) -> tuple<_UTypes...>; + template + tuple(pair<_T1, _T2>) -> tuple<_T1, _T2>; + template + tuple(allocator_arg_t, _Alloc, _UTypes...) -> tuple<_UTypes...>; + template + tuple(allocator_arg_t, _Alloc, pair<_T1, _T2>) -> tuple<_T1, _T2>; + template + tuple(allocator_arg_t, _Alloc, tuple<_UTypes...>) -> tuple<_UTypes...>; +#endif + + // Explicit specialization, zero-element tuple. + template<> + class tuple<> + { + public: + _GLIBCXX20_CONSTEXPR + void swap(tuple&) noexcept { /* no-op */ } + // We need the default since we're going to define no-op + // allocator constructors. + tuple() = default; + // No-op allocator constructors. + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t, const _Alloc&) noexcept { } + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept { } + }; + + /// Partial specialization, 2-element tuple. + /// Includes construction and assignment from a pair. + template + class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2> + { + typedef _Tuple_impl<0, _T1, _T2> _Inherited; + + // Constraint for non-explicit default constructor + template + using _ImplicitDefaultCtor = __enable_if_t< + _TupleConstraints<_Dummy, _U1, _U2>:: + __is_implicitly_default_constructible(), + bool>; + + // Constraint for explicit default constructor + template + using _ExplicitDefaultCtor = __enable_if_t< + _TupleConstraints<_Dummy, _U1, _U2>:: + __is_explicitly_default_constructible(), + bool>; + + template + using _TCC = _TupleConstraints<_Dummy, _T1, _T2>; + + // Constraint for non-explicit constructors + template + using _ImplicitCtor = __enable_if_t< + _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(), + bool>; + + // Constraint for non-explicit constructors + template + using _ExplicitCtor = __enable_if_t< + _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(), + bool>; + + template + static constexpr bool __assignable() + { + return __and_, + is_assignable<_T2&, _U2>>::value; + } + + template + static constexpr bool __nothrow_assignable() + { + return __and_, + is_nothrow_assignable<_T2&, _U2>>::value; + } + + template + static constexpr bool __nothrow_constructible() + { + return __and_, + is_nothrow_constructible<_T2, _U2>>::value; + } + + static constexpr bool __nothrow_default_constructible() + { + return __and_, + is_nothrow_default_constructible<_T2>>::value; + } + + template + static constexpr bool __is_alloc_arg() + { return is_same<__remove_cvref_t<_U1>, allocator_arg_t>::value; } + + public: + template = true> + constexpr + tuple() + noexcept(__nothrow_default_constructible()) + : _Inherited() { } + + template = false> + explicit constexpr + tuple() + noexcept(__nothrow_default_constructible()) + : _Inherited() { } + + template = true> + constexpr + tuple(const _T1& __a1, const _T2& __a2) + noexcept(__nothrow_constructible()) + : _Inherited(__a1, __a2) { } + + template = false> + explicit constexpr + tuple(const _T1& __a1, const _T2& __a2) + noexcept(__nothrow_constructible()) + : _Inherited(__a1, __a2) { } + + template(), _U1, _U2> = true> + constexpr + tuple(_U1&& __a1, _U2&& __a2) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } + + template(), _U1, _U2> = false> + explicit constexpr + tuple(_U1&& __a1, _U2&& __a2) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } + + constexpr tuple(const tuple&) = default; + + constexpr tuple(tuple&&) = default; + + template = true> + constexpr + tuple(const tuple<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&>(__in)) { } + + template = false> + explicit constexpr + tuple(const tuple<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(static_cast&>(__in)) { } + + template = true> + constexpr + tuple(tuple<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } + + template = false> + explicit constexpr + tuple(tuple<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } + + template = true> + constexpr + tuple(const pair<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(__in.first, __in.second) { } + + template = false> + explicit constexpr + tuple(const pair<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) + : _Inherited(__in.first, __in.second) { } + + template = true> + constexpr + tuple(pair<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(std::forward<_U1>(__in.first), + std::forward<_U2>(__in.second)) { } + + template = false> + explicit constexpr + tuple(pair<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) + : _Inherited(std::forward<_U1>(__in.first), + std::forward<_U2>(__in.second)) { } + + // Allocator-extended constructors. + + template::value, _T1, _T2> = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a) + : _Inherited(__tag, __a) { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const _T1& __a1, const _T2& __a2) + : _Inherited(__tag, __a, __a1, __a2) { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const _T1& __a1, const _T2& __a2) + : _Inherited(__tag, __a, __a1, __a2) { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2) + : _Inherited(__tag, __a, std::forward<_U1>(__a1), + std::forward<_U2>(__a2)) { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + _U1&& __a1, _U2&& __a2) + : _Inherited(__tag, __a, std::forward<_U1>(__a1), + std::forward<_U2>(__a2)) { } + + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) + : _Inherited(__tag, __a, static_cast(__in)) { } + + template + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) + : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_U1, _U2>& __in) + : _Inherited(__tag, __a, + static_cast&>(__in)) + { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const tuple<_U1, _U2>& __in) + : _Inherited(__tag, __a, + static_cast&>(__in)) + { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) + : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) + { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) + : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) + { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const pair<_U1, _U2>& __in) + : _Inherited(__tag, __a, __in.first, __in.second) { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, + const pair<_U1, _U2>& __in) + : _Inherited(__tag, __a, __in.first, __in.second) { } + + template = true> + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) + : _Inherited(__tag, __a, std::forward<_U1>(__in.first), + std::forward<_U2>(__in.second)) { } + + template = false> + explicit + _GLIBCXX20_CONSTEXPR + tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) + : _Inherited(__tag, __a, std::forward<_U1>(__in.first), + std::forward<_U2>(__in.second)) { } + + // Tuple assignment. + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(__conditional_t<__assignable(), + const tuple&, + const __nonesuch&> __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(__conditional_t<__assignable<_T1, _T2>(), + tuple&&, + __nonesuch&&> __in) + noexcept(__nothrow_assignable<_T1, _T2>()) + { + this->_M_assign(std::move(__in)); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable(), tuple&> + operator=(const tuple<_U1, _U2>& __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable<_U1, _U2>(), tuple&> + operator=(tuple<_U1, _U2>&& __in) + noexcept(__nothrow_assignable<_U1, _U2>()) + { + this->_M_assign(std::move(__in)); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable(), tuple&> + operator=(const pair<_U1, _U2>& __in) + noexcept(__nothrow_assignable()) + { + this->_M_head(*this) = __in.first; + this->_M_tail(*this)._M_head(*this) = __in.second; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + __enable_if_t<__assignable<_U1, _U2>(), tuple&> + operator=(pair<_U1, _U2>&& __in) + noexcept(__nothrow_assignable<_U1, _U2>()) + { + this->_M_head(*this) = std::forward<_U1>(__in.first); + this->_M_tail(*this)._M_head(*this) = std::forward<_U2>(__in.second); + return *this; + } + + _GLIBCXX20_CONSTEXPR + void + swap(tuple& __in) + noexcept(__and_<__is_nothrow_swappable<_T1>, + __is_nothrow_swappable<_T2>>::value) + { _Inherited::_M_swap(__in); } + }; + + + /// class tuple_size + template + struct tuple_size> + : public integral_constant { }; + +#if __cplusplus >= 201703L + template + inline constexpr size_t tuple_size_v> + = sizeof...(_Types); + + template + inline constexpr size_t tuple_size_v> + = sizeof...(_Types); +#endif + + /// Trait to get the Ith element type from a tuple. + template + struct tuple_element<__i, tuple<_Types...>> + { + static_assert(__i < sizeof...(_Types), "tuple index must be in range"); + + using type = typename _Nth_type<__i, _Types...>::type; + }; + + template + constexpr _Head& + __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept + { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } + + template + constexpr const _Head& + __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept + { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } + + // Deleted overload to improve diagnostics for invalid indices + template + __enable_if_t<(__i >= sizeof...(_Types))> + __get_helper(const tuple<_Types...>&) = delete; + + /// Return a reference to the ith element of a tuple. + template + constexpr __tuple_element_t<__i, tuple<_Elements...>>& + get(tuple<_Elements...>& __t) noexcept + { return std::__get_helper<__i>(__t); } + + /// Return a const reference to the ith element of a const tuple. + template + constexpr const __tuple_element_t<__i, tuple<_Elements...>>& + get(const tuple<_Elements...>& __t) noexcept + { return std::__get_helper<__i>(__t); } + + /// Return an rvalue reference to the ith element of a tuple rvalue. + template + constexpr __tuple_element_t<__i, tuple<_Elements...>>&& + get(tuple<_Elements...>&& __t) noexcept + { + typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type; + return std::forward<__element_type>(std::__get_helper<__i>(__t)); + } + + /// Return a const rvalue reference to the ith element of a const tuple rvalue. + template + constexpr const __tuple_element_t<__i, tuple<_Elements...>>&& + get(const tuple<_Elements...>&& __t) noexcept + { + typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type; + return std::forward(std::__get_helper<__i>(__t)); + } + + /// @cond undocumented + // Deleted overload chosen for invalid indices. + template + constexpr __enable_if_t<(__i >= sizeof...(_Elements))> + get(const tuple<_Elements...>&) = delete; + /// @endcond + +#if __cplusplus >= 201402L + +#define __cpp_lib_tuples_by_type 201304L + + /// Return a reference to the unique element of type _Tp of a tuple. + template + constexpr _Tp& + get(tuple<_Types...>& __t) noexcept + { + constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>(); + static_assert(__idx < sizeof...(_Types), + "the type T in std::get must occur exactly once in the tuple"); + return std::__get_helper<__idx>(__t); + } + + /// Return a reference to the unique element of type _Tp of a tuple rvalue. + template + constexpr _Tp&& + get(tuple<_Types...>&& __t) noexcept + { + constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>(); + static_assert(__idx < sizeof...(_Types), + "the type T in std::get must occur exactly once in the tuple"); + return std::forward<_Tp>(std::__get_helper<__idx>(__t)); + } + + /// Return a const reference to the unique element of type _Tp of a tuple. + template + constexpr const _Tp& + get(const tuple<_Types...>& __t) noexcept + { + constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>(); + static_assert(__idx < sizeof...(_Types), + "the type T in std::get must occur exactly once in the tuple"); + return std::__get_helper<__idx>(__t); + } + + /// Return a const reference to the unique element of type _Tp of + /// a const tuple rvalue. + template + constexpr const _Tp&& + get(const tuple<_Types...>&& __t) noexcept + { + constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>(); + static_assert(__idx < sizeof...(_Types), + "the type T in std::get must occur exactly once in the tuple"); + return std::forward(std::__get_helper<__idx>(__t)); + } +#endif + + // This class performs the comparison operations on tuples + template + struct __tuple_compare + { + static constexpr bool + __eq(const _Tp& __t, const _Up& __u) + { + return bool(std::get<__i>(__t) == std::get<__i>(__u)) + && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u); + } + + static constexpr bool + __less(const _Tp& __t, const _Up& __u) + { + return bool(std::get<__i>(__t) < std::get<__i>(__u)) + || (!bool(std::get<__i>(__u) < std::get<__i>(__t)) + && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u)); + } + }; + + template + struct __tuple_compare<_Tp, _Up, __size, __size> + { + static constexpr bool + __eq(const _Tp&, const _Up&) { return true; } + + static constexpr bool + __less(const _Tp&, const _Up&) { return false; } + }; + + template + constexpr bool + operator==(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + static_assert(sizeof...(_TElements) == sizeof...(_UElements), + "tuple objects can only be compared if they have equal sizes."); + using __compare = __tuple_compare, + tuple<_UElements...>, + 0, sizeof...(_TElements)>; + return __compare::__eq(__t, __u); + } + +#if __cpp_lib_three_way_comparison + template + constexpr _Cat + __tuple_cmp(const _Tp&, const _Up&, index_sequence<>) + { return _Cat::equivalent; } + + template + constexpr _Cat + __tuple_cmp(const _Tp& __t, const _Up& __u, + index_sequence<_Idx0, _Idxs...>) + { + auto __c + = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u)); + if (__c != 0) + return __c; + return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>()); + } + + template + constexpr + common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...> + operator<=>(const tuple<_Tps...>& __t, const tuple<_Ups...>& __u) + { + using _Cat + = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>; + return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>()); + } +#else + template + constexpr bool + operator<(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + static_assert(sizeof...(_TElements) == sizeof...(_UElements), + "tuple objects can only be compared if they have equal sizes."); + using __compare = __tuple_compare, + tuple<_UElements...>, + 0, sizeof...(_TElements)>; + return __compare::__less(__t, __u); + } + + template + constexpr bool + operator!=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t == __u); } + + template + constexpr bool + operator>(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return __u < __t; } + + template + constexpr bool + operator<=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__u < __t); } + + template + constexpr bool + operator>=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t < __u); } +#endif // three_way_comparison + + // NB: DR 705. + template + constexpr tuple::__type...> + make_tuple(_Elements&&... __args) + { + typedef tuple::__type...> + __result_type; + return __result_type(std::forward<_Elements>(__args)...); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2275. Why is forward_as_tuple not constexpr? + /// std::forward_as_tuple + template + constexpr tuple<_Elements&&...> + forward_as_tuple(_Elements&&... __args) noexcept + { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); } + + // Declarations of std::array and its std::get overloads, so that + // std::tuple_cat can use them if is included before . + + template struct array; + + template + constexpr _Tp& + get(array<_Tp, _Nm>&) noexcept; + + template + constexpr _Tp&& + get(array<_Tp, _Nm>&&) noexcept; + + template + constexpr const _Tp& + get(const array<_Tp, _Nm>&) noexcept; + + template + constexpr const _Tp&& + get(const array<_Tp, _Nm>&&) noexcept; + + + template + struct __make_tuple_impl; + + template + struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm> + : __make_tuple_impl<_Idx + 1, + tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>, + _Tuple, _Nm> + { }; + + template + struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm> + { + typedef tuple<_Tp...> __type; + }; + + template + struct __do_make_tuple + : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value> + { }; + + // Returns the std::tuple equivalent of a tuple-like type. + template + struct __make_tuple + : public __do_make_tuple<__remove_cvref_t<_Tuple>> + { }; + + // Combines several std::tuple's into a single one. + template + struct __combine_tuples; + + template<> + struct __combine_tuples<> + { + typedef tuple<> __type; + }; + + template + struct __combine_tuples> + { + typedef tuple<_Ts...> __type; + }; + + template + struct __combine_tuples, tuple<_T2s...>, _Rem...> + { + typedef typename __combine_tuples, + _Rem...>::__type __type; + }; + + // Computes the result type of tuple_cat given a set of tuple-like types. + template + struct __tuple_cat_result + { + typedef typename __combine_tuples + ::__type...>::__type __type; + }; + + // Helper to determine the index set for the first tuple-like + // type of a given set. + template + struct __make_1st_indices; + + template<> + struct __make_1st_indices<> + { + typedef _Index_tuple<> __type; + }; + + template + struct __make_1st_indices<_Tp, _Tpls...> + { + typedef typename _Build_index_tuple::type>::value>::__type __type; + }; + + // Performs the actual concatenation by step-wise expanding tuple-like + // objects into the elements, which are finally forwarded into the + // result tuple. + template + struct __tuple_concater; + + template + struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...> + { + template + static constexpr _Ret + _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us) + { + typedef typename __make_1st_indices<_Tpls...>::__type __idx; + typedef __tuple_concater<_Ret, __idx, _Tpls...> __next; + return __next::_S_do(std::forward<_Tpls>(__tps)..., + std::forward<_Us>(__us)..., + std::get<_Is>(std::forward<_Tp>(__tp))...); + } + }; + + template + struct __tuple_concater<_Ret, _Index_tuple<>> + { + template + static constexpr _Ret + _S_do(_Us&&... __us) + { + return _Ret(std::forward<_Us>(__us)...); + } + }; + + template + struct __is_tuple_like_impl> : true_type + { }; + + /// tuple_cat + template...>::value>::type> + constexpr auto + tuple_cat(_Tpls&&... __tpls) + -> typename __tuple_cat_result<_Tpls...>::__type + { + typedef typename __tuple_cat_result<_Tpls...>::__type __ret; + typedef typename __make_1st_indices<_Tpls...>::__type __idx; + typedef __tuple_concater<__ret, __idx, _Tpls...> __concater; + return __concater::_S_do(std::forward<_Tpls>(__tpls)...); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2301. Why is tie not constexpr? + /// tie + template + constexpr tuple<_Elements&...> + tie(_Elements&... __args) noexcept + { return tuple<_Elements&...>(__args...); } + + /// swap + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_Elements>...>::value + >::type +#else + void +#endif + swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + _GLIBCXX20_CONSTEXPR + typename enable_if...>::value>::type + swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; +#endif + + // A class (and instance) which can be used in 'tie' when an element + // of a tuple is not required. + // _GLIBCXX14_CONSTEXPR + // 2933. PR for LWG 2773 could be clearer + struct _Swallow_assign + { + template + _GLIBCXX14_CONSTEXPR const _Swallow_assign& + operator=(const _Tp&) const + { return *this; } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2773. Making std::ignore constexpr + _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{}; + + /// Partial specialization for tuples + template + struct uses_allocator, _Alloc> : true_type { }; + + // See stl_pair.h... + /** "piecewise construction" using a tuple of arguments for each member. + * + * @param __first Arguments for the first member of the pair. + * @param __second Arguments for the second member of the pair. + * + * The elements of each tuple will be used as the constructor arguments + * for the data members of the pair. + */ + template + template + _GLIBCXX20_CONSTEXPR + inline + pair<_T1, _T2>:: + pair(piecewise_construct_t, + tuple<_Args1...> __first, tuple<_Args2...> __second) + : pair(__first, __second, + typename _Build_index_tuple::__type(), + typename _Build_index_tuple::__type()) + { } + + template + template + _GLIBCXX20_CONSTEXPR inline + pair<_T1, _T2>:: + pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>) + : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...), + second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) + { } + +#if __cplusplus >= 201703L + + // Unpack a std::tuple into a type trait and use its value. + // For cv std::tuple<_Up> the result is _Trait<_Tp, cv _Up...>::value. + // For cv std::tuple<_Up>& the result is _Trait<_Tp, cv _Up&...>::value. + // Otherwise the result is false (because we don't know if std::get throws). + template class _Trait, typename _Tp, typename _Tuple> + inline constexpr bool __unpack_std_tuple = false; + + template class _Trait, typename _Tp, typename... _Up> + inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>> + = _Trait<_Tp, _Up...>::value; + + template class _Trait, typename _Tp, typename... _Up> + inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&> + = _Trait<_Tp, _Up&...>::value; + + template class _Trait, typename _Tp, typename... _Up> + inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const tuple<_Up...>> + = _Trait<_Tp, const _Up...>::value; + + template class _Trait, typename _Tp, typename... _Up> + inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const tuple<_Up...>&> + = _Trait<_Tp, const _Up&...>::value; + +# define __cpp_lib_apply 201603L + + template + constexpr decltype(auto) + __apply_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Idx...>) + { + return std::__invoke(std::forward<_Fn>(__f), + std::get<_Idx>(std::forward<_Tuple>(__t))...); + } + + template + constexpr decltype(auto) + apply(_Fn&& __f, _Tuple&& __t) + noexcept(__unpack_std_tuple) + { + using _Indices + = make_index_sequence>>; + return std::__apply_impl(std::forward<_Fn>(__f), + std::forward<_Tuple>(__t), + _Indices{}); + } + +#define __cpp_lib_make_from_tuple 201606L + + template + constexpr _Tp + __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>) + { return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); } + + template + constexpr _Tp + make_from_tuple(_Tuple&& __t) + noexcept(__unpack_std_tuple) + { + return __make_from_tuple_impl<_Tp>( + std::forward<_Tuple>(__t), + make_index_sequence>>{}); + } +#endif // C++17 + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_TUPLE diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple.blob new file mode 100644 index 0000000000000000000000000000000000000000..a22733966fbb45bdc4a58e82c3ea4b6f305538be Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@tuple.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits new file mode 100644 index 0000000000000000000000000000000000000000..2572d8edd693e042156c09fec967d5ee6dd966fc --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits @@ -0,0 +1,3708 @@ +// C++11 -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/type_traits + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_TYPE_TRAITS +#define _GLIBCXX_TYPE_TRAITS 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + class reference_wrapper; + + /** + * @defgroup metaprogramming Metaprogramming + * @ingroup utilities + * + * Template utilities for compile-time introspection and modification, + * including type classification traits, type property inspection traits + * and type transformation traits. + * + * @since C++11 + * + * @{ + */ + + /// integral_constant + template + struct integral_constant + { + static constexpr _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + constexpr operator value_type() const noexcept { return value; } +#if __cplusplus > 201103L + +#define __cpp_lib_integral_constant_callable 201304L + + constexpr value_type operator()() const noexcept { return value; } +#endif + }; + +#if ! __cpp_inline_variables + template + constexpr _Tp integral_constant<_Tp, __v>::value; +#endif + + /// The type used as a compile-time boolean with true value. + using true_type = integral_constant; + + /// The type used as a compile-time boolean with false value. + using false_type = integral_constant; + + /// @cond undocumented + /// bool_constant for C++11 + template + using __bool_constant = integral_constant; + /// @endcond + +#if __cplusplus >= 201703L +# define __cpp_lib_bool_constant 201505L + /// Alias template for compile-time boolean constant types. + /// @since C++17 + template + using bool_constant = integral_constant; +#endif + + // Metaprogramming helper types. + + template + struct __conditional + { + template + using type = _Tp; + }; + + template<> + struct __conditional + { + template + using type = _Up; + }; + + // More efficient version of std::conditional_t for internal use (and C++11) + template + using __conditional_t + = typename __conditional<_Cond>::template type<_If, _Else>; + + /// @cond undocumented + template + struct __type_identity + { using type = _Type; }; + + template + using __type_identity_t = typename __type_identity<_Tp>::type; + + template + struct __or_; + + template<> + struct __or_<> + : public false_type + { }; + + template + struct __or_<_B1> + : public _B1 + { }; + + template + struct __or_<_B1, _B2> + : public __conditional_t<_B1::value, _B1, _B2> + { }; + + template + struct __or_<_B1, _B2, _B3, _Bn...> + : public __conditional_t<_B1::value, _B1, __or_<_B2, _B3, _Bn...>> + { }; + + template + struct __and_; + + template<> + struct __and_<> + : public true_type + { }; + + template + struct __and_<_B1> + : public _B1 + { }; + + template + struct __and_<_B1, _B2> + : public __conditional_t<_B1::value, _B2, _B1> + { }; + + template + struct __and_<_B1, _B2, _B3, _Bn...> + : public __conditional_t<_B1::value, __and_<_B2, _B3, _Bn...>, _B1> + { }; + + template + struct __not_ + : public __bool_constant + { }; + /// @endcond + +#if __cplusplus >= 201703L + + /// @cond undocumented + template + inline constexpr bool __or_v = __or_<_Bn...>::value; + template + inline constexpr bool __and_v = __and_<_Bn...>::value; + /// @endcond + +#define __cpp_lib_logical_traits 201510L + + template + struct conjunction + : __and_<_Bn...> + { }; + + template + struct disjunction + : __or_<_Bn...> + { }; + + template + struct negation + : __not_<_Pp> + { }; + + /** @ingroup variable_templates + * @{ + */ + template + inline constexpr bool conjunction_v = conjunction<_Bn...>::value; + + template + inline constexpr bool disjunction_v = disjunction<_Bn...>::value; + + template + inline constexpr bool negation_v = negation<_Pp>::value; + /// @} + +#endif // C++17 + + // Forward declarations + template + struct is_reference; + template + struct is_function; + template + struct is_void; + template + struct remove_cv; + template + struct is_const; + + /// @cond undocumented + template + struct __is_array_unknown_bounds; + + // Helper functions that return false_type for incomplete classes, + // incomplete unions and arrays of known bound from those. + + template + constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) + { return {}; } + + template + constexpr typename __or_< + is_reference<_NestedType>, + is_function<_NestedType>, + is_void<_NestedType>, + __is_array_unknown_bounds<_NestedType> + >::type __is_complete_or_unbounded(_TypeIdentity) + { return {}; } + + // For several sfinae-friendly trait implementations we transport both the + // result information (as the member type) and the failure information (no + // member type). This is very similar to std::enable_if, but we cannot use + // them, because we need to derive from them as an implementation detail. + + template + struct __success_type + { typedef _Tp type; }; + + struct __failure_type + { }; + + // __remove_cv_t (std::remove_cv_t for C++11). + template + using __remove_cv_t = typename remove_cv<_Tp>::type; + + // Primary type categories. + + template + struct __is_void_helper + : public false_type { }; + + template<> + struct __is_void_helper + : public true_type { }; + /// @endcond + + /// is_void + template + struct is_void + : public __is_void_helper<__remove_cv_t<_Tp>>::type + { }; + + /// @cond undocumented + template + struct __is_integral_helper + : public false_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + // We want is_integral to be true (and make_signed/unsigned to work) + // even when libc doesn't provide working and related functions, + // so don't check _GLIBCXX_USE_WCHAR_T here. + template<> + struct __is_integral_helper + : public true_type { }; + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __is_integral_helper + : public true_type { }; +#endif + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + // Conditionalizing on __STRICT_ANSI__ here will break any port that + // uses one of these types for size_t. +#if defined(__GLIBCXX_TYPE_INT_N_0) + __extension__ + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> + : public true_type { }; + + __extension__ + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + __extension__ + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> + : public true_type { }; + + __extension__ + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + __extension__ + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> + : public true_type { }; + + __extension__ + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + __extension__ + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> + : public true_type { }; + + __extension__ + template<> + struct __is_integral_helper + : public true_type { }; +#endif + /// @endcond + + /// is_integral + template + struct is_integral + : public __is_integral_helper<__remove_cv_t<_Tp>>::type + { }; + + /// @cond undocumented + template + struct __is_floating_point_helper + : public false_type { }; + + template<> + struct __is_floating_point_helper + : public true_type { }; + + template<> + struct __is_floating_point_helper + : public true_type { }; + + template<> + struct __is_floating_point_helper + : public true_type { }; + +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) + template<> + struct __is_floating_point_helper<__float128> + : public true_type { }; +#endif + /// @endcond + + /// is_floating_point + template + struct is_floating_point + : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type + { }; + + /// is_array + template + struct is_array + : public false_type { }; + + template + struct is_array<_Tp[_Size]> + : public true_type { }; + + template + struct is_array<_Tp[]> + : public true_type { }; + + template + struct __is_pointer_helper + : public false_type { }; + + template + struct __is_pointer_helper<_Tp*> + : public true_type { }; + + /// is_pointer + template + struct is_pointer + : public __is_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + /// is_lvalue_reference + template + struct is_lvalue_reference + : public false_type { }; + + template + struct is_lvalue_reference<_Tp&> + : public true_type { }; + + /// is_rvalue_reference + template + struct is_rvalue_reference + : public false_type { }; + + template + struct is_rvalue_reference<_Tp&&> + : public true_type { }; + + template + struct __is_member_object_pointer_helper + : public false_type { }; + + template + struct __is_member_object_pointer_helper<_Tp _Cp::*> + : public __not_>::type { }; + + /// is_member_object_pointer + template + struct is_member_object_pointer + : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + template + struct __is_member_function_pointer_helper + : public false_type { }; + + template + struct __is_member_function_pointer_helper<_Tp _Cp::*> + : public is_function<_Tp>::type { }; + + /// is_member_function_pointer + template + struct is_member_function_pointer + : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + /// is_enum + template + struct is_enum + : public integral_constant + { }; + + /// is_union + template + struct is_union + : public integral_constant + { }; + + /// is_class + template + struct is_class + : public integral_constant + { }; + + /// is_function + template + struct is_function + : public __bool_constant::value> { }; + + template + struct is_function<_Tp&> + : public false_type { }; + + template + struct is_function<_Tp&&> + : public false_type { }; + +#define __cpp_lib_is_null_pointer 201309L + + template + struct __is_null_pointer_helper + : public false_type { }; + + template<> + struct __is_null_pointer_helper + : public true_type { }; + + /// is_null_pointer (LWG 2247). + template + struct is_null_pointer + : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + /// __is_nullptr_t (deprecated extension). + /// @deprecated Non-standard. Use `is_null_pointer` instead. + template + struct __is_nullptr_t + : public is_null_pointer<_Tp> + { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer"); + + // Composite type categories. + + /// is_reference + template + struct is_reference + : public __or_, + is_rvalue_reference<_Tp>>::type + { }; + + /// is_arithmetic + template + struct is_arithmetic + : public __or_, is_floating_point<_Tp>>::type + { }; + + /// is_fundamental + template + struct is_fundamental + : public __or_, is_void<_Tp>, + is_null_pointer<_Tp>>::type + { }; + + /// is_object + template + struct is_object + : public __not_<__or_, is_reference<_Tp>, + is_void<_Tp>>>::type + { }; + + template + struct is_member_pointer; + + /// is_scalar + template + struct is_scalar + : public __or_, is_enum<_Tp>, is_pointer<_Tp>, + is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type + { }; + + /// is_compound + template + struct is_compound + : public __not_>::type { }; + + /// @cond undocumented + template + struct __is_member_pointer_helper + : public false_type { }; + + template + struct __is_member_pointer_helper<_Tp _Cp::*> + : public true_type { }; + /// @endcond + + /// is_member_pointer + template + struct is_member_pointer + : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + template + struct is_same; + + /// @cond undocumented + template + using __is_one_of = __or_...>; + + // Check if a type is one of the signed integer types. + __extension__ + template + using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, + signed char, signed short, signed int, signed long, + signed long long +#if defined(__GLIBCXX_TYPE_INT_N_0) + , signed __GLIBCXX_TYPE_INT_N_0 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + , signed __GLIBCXX_TYPE_INT_N_1 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + , signed __GLIBCXX_TYPE_INT_N_2 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + , signed __GLIBCXX_TYPE_INT_N_3 +#endif + >; + + // Check if a type is one of the unsigned integer types. + __extension__ + template + using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, + unsigned char, unsigned short, unsigned int, unsigned long, + unsigned long long +#if defined(__GLIBCXX_TYPE_INT_N_0) + , unsigned __GLIBCXX_TYPE_INT_N_0 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + , unsigned __GLIBCXX_TYPE_INT_N_1 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + , unsigned __GLIBCXX_TYPE_INT_N_2 +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + , unsigned __GLIBCXX_TYPE_INT_N_3 +#endif + >; + + // Check if a type is one of the signed or unsigned integer types. + template + using __is_standard_integer + = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; + + // __void_t (std::void_t for C++11) + template using __void_t = void; + + // Utility to detect referenceable types ([defns.referenceable]). + + template + struct __is_referenceable + : public false_type + { }; + + template + struct __is_referenceable<_Tp, __void_t<_Tp&>> + : public true_type + { }; + /// @endcond + + // Type properties. + + /// is_const + template + struct is_const + : public false_type { }; + + template + struct is_const<_Tp const> + : public true_type { }; + + /// is_volatile + template + struct is_volatile + : public false_type { }; + + template + struct is_volatile<_Tp volatile> + : public true_type { }; + + /// is_trivial + template + struct is_trivial + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_trivially_copyable + template + struct is_trivially_copyable + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_standard_layout + template + struct is_standard_layout + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /** is_pod + * @deprecated Deprecated in C++20. + * Use `is_standard_layout && is_trivial` instead. + */ + // Could use is_standard_layout && is_trivial instead of the builtin. + template + struct + _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") + is_pod + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /** is_literal_type + * @deprecated Deprecated in C++17, removed in C++20. + * The idea of a literal type isn't useful. + */ + template + struct + _GLIBCXX17_DEPRECATED + is_literal_type + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_empty + template + struct is_empty + : public integral_constant + { }; + + /// is_polymorphic + template + struct is_polymorphic + : public integral_constant + { }; + +#if __cplusplus >= 201402L +#define __cpp_lib_is_final 201402L + /// is_final + /// @since C++14 + template + struct is_final + : public integral_constant + { }; +#endif + + /// is_abstract + template + struct is_abstract + : public integral_constant + { }; + + /// @cond undocumented + template::value> + struct __is_signed_helper + : public false_type { }; + + template + struct __is_signed_helper<_Tp, true> + : public integral_constant + { }; + /// @endcond + + /// is_signed + template + struct is_signed + : public __is_signed_helper<_Tp>::type + { }; + + /// is_unsigned + template + struct is_unsigned + : public __and_, __not_>> + { }; + + /// @cond undocumented + template + _Up + __declval(int); + + template + _Tp + __declval(long); + /// @endcond + + template + auto declval() noexcept -> decltype(__declval<_Tp>(0)); + + template + struct extent; + + template + struct remove_all_extents; + + /// @cond undocumented + template + struct __is_array_known_bounds + : public integral_constant::value > 0)> + { }; + + template + struct __is_array_unknown_bounds + : public __and_, __not_>> + { }; + + // Destructible and constructible type properties. + + // In N3290 is_destructible does not say anything about function + // types and abstract types, see LWG 2049. This implementation + // describes function types as non-destructible and all complete + // object types as destructible, iff the explicit destructor + // call expression is wellformed. + struct __do_is_destructible_impl + { + template().~_Tp())> + static true_type __test(int); + + template + static false_type __test(...); + }; + + template + struct __is_destructible_impl + : public __do_is_destructible_impl + { + typedef decltype(__test<_Tp>(0)) type; + }; + + template, + __is_array_unknown_bounds<_Tp>, + is_function<_Tp>>::value, + bool = __or_, is_scalar<_Tp>>::value> + struct __is_destructible_safe; + + template + struct __is_destructible_safe<_Tp, false, false> + : public __is_destructible_impl::type>::type + { }; + + template + struct __is_destructible_safe<_Tp, true, false> + : public false_type { }; + + template + struct __is_destructible_safe<_Tp, false, true> + : public true_type { }; + /// @endcond + + /// is_destructible + template + struct is_destructible + : public __is_destructible_safe<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + + // is_nothrow_destructible requires that is_destructible is + // satisfied as well. We realize that by mimicing the + // implementation of is_destructible but refer to noexcept(expr) + // instead of decltype(expr). + struct __do_is_nt_destructible_impl + { + template + static __bool_constant().~_Tp())> + __test(int); + + template + static false_type __test(...); + }; + + template + struct __is_nt_destructible_impl + : public __do_is_nt_destructible_impl + { + typedef decltype(__test<_Tp>(0)) type; + }; + + template, + __is_array_unknown_bounds<_Tp>, + is_function<_Tp>>::value, + bool = __or_, is_scalar<_Tp>>::value> + struct __is_nt_destructible_safe; + + template + struct __is_nt_destructible_safe<_Tp, false, false> + : public __is_nt_destructible_impl::type>::type + { }; + + template + struct __is_nt_destructible_safe<_Tp, true, false> + : public false_type { }; + + template + struct __is_nt_destructible_safe<_Tp, false, true> + : public true_type { }; + /// @endcond + + /// is_nothrow_destructible + template + struct is_nothrow_destructible + : public __is_nt_destructible_safe<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template + struct __is_constructible_impl + : public __bool_constant<__is_constructible(_Tp, _Args...)> + { }; + /// @endcond + + /// is_constructible + template + struct is_constructible + : public __is_constructible_impl<_Tp, _Args...> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_default_constructible + template + struct is_default_constructible + : public __is_constructible_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template::value> + struct __is_copy_constructible_impl; + + template + struct __is_copy_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_copy_constructible_impl<_Tp, true> + : public __is_constructible_impl<_Tp, const _Tp&> + { }; + /// @endcond + + /// is_copy_constructible + template + struct is_copy_constructible + : public __is_copy_constructible_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template::value> + struct __is_move_constructible_impl; + + template + struct __is_move_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_move_constructible_impl<_Tp, true> + : public __is_constructible_impl<_Tp, _Tp&&> + { }; + /// @endcond + + /// is_move_constructible + template + struct is_move_constructible + : public __is_move_constructible_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template + using __is_nothrow_constructible_impl + = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; + /// @endcond + + /// is_nothrow_constructible + template + struct is_nothrow_constructible + : public __is_nothrow_constructible_impl<_Tp, _Args...>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_nothrow_default_constructible + template + struct is_nothrow_default_constructible + : public __bool_constant<__is_nothrow_constructible(_Tp)> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template::value> + struct __is_nothrow_copy_constructible_impl; + + template + struct __is_nothrow_copy_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_nothrow_copy_constructible_impl<_Tp, true> + : public __is_nothrow_constructible_impl<_Tp, const _Tp&> + { }; + /// @endcond + + /// is_nothrow_copy_constructible + template + struct is_nothrow_copy_constructible + : public __is_nothrow_copy_constructible_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template::value> + struct __is_nothrow_move_constructible_impl; + + template + struct __is_nothrow_move_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_nothrow_move_constructible_impl<_Tp, true> + : public __is_nothrow_constructible_impl<_Tp, _Tp&&> + { }; + /// @endcond + + /// is_nothrow_move_constructible + template + struct is_nothrow_move_constructible + : public __is_nothrow_move_constructible_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_assignable + template + struct is_assignable + : public __bool_constant<__is_assignable(_Tp, _Up)> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_copy_assignable_impl; + + template + struct __is_copy_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_copy_assignable_impl<_Tp, true> + : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> + { }; + + /// is_copy_assignable + template + struct is_copy_assignable + : public __is_copy_assignable_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_move_assignable_impl; + + template + struct __is_move_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_move_assignable_impl<_Tp, true> + : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> + { }; + + /// is_move_assignable + template + struct is_move_assignable + : public __is_move_assignable_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template + using __is_nothrow_assignable_impl + = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; + + /// is_nothrow_assignable + template + struct is_nothrow_assignable + : public __is_nothrow_assignable_impl<_Tp, _Up> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_nt_copy_assignable_impl; + + template + struct __is_nt_copy_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_nt_copy_assignable_impl<_Tp, true> + : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> + { }; + + /// is_nothrow_copy_assignable + template + struct is_nothrow_copy_assignable + : public __is_nt_copy_assignable_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_nt_move_assignable_impl; + + template + struct __is_nt_move_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_nt_move_assignable_impl<_Tp, true> + : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> + { }; + + /// is_nothrow_move_assignable + template + struct is_nothrow_move_assignable + : public __is_nt_move_assignable_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_trivially_constructible + template + struct is_trivially_constructible + : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_trivially_default_constructible + template + struct is_trivially_default_constructible + : public __bool_constant<__is_trivially_constructible(_Tp)> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + struct __do_is_implicitly_default_constructible_impl + { + template + static void __helper(const _Tp&); + + template + static true_type __test(const _Tp&, + decltype(__helper({}))* = 0); + + static false_type __test(...); + }; + + template + struct __is_implicitly_default_constructible_impl + : public __do_is_implicitly_default_constructible_impl + { + typedef decltype(__test(declval<_Tp>())) type; + }; + + template + struct __is_implicitly_default_constructible_safe + : public __is_implicitly_default_constructible_impl<_Tp>::type + { }; + + template + struct __is_implicitly_default_constructible + : public __and_<__is_constructible_impl<_Tp>, + __is_implicitly_default_constructible_safe<_Tp>> + { }; + + template::value> + struct __is_trivially_copy_constructible_impl; + + template + struct __is_trivially_copy_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_trivially_copy_constructible_impl<_Tp, true> + : public __and_<__is_copy_constructible_impl<_Tp>, + integral_constant> + { }; + + /// is_trivially_copy_constructible + template + struct is_trivially_copy_constructible + : public __is_trivially_copy_constructible_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_trivially_move_constructible_impl; + + template + struct __is_trivially_move_constructible_impl<_Tp, false> + : public false_type { }; + + template + struct __is_trivially_move_constructible_impl<_Tp, true> + : public __and_<__is_move_constructible_impl<_Tp>, + integral_constant> + { }; + + /// is_trivially_move_constructible + template + struct is_trivially_move_constructible + : public __is_trivially_move_constructible_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_trivially_assignable + template + struct is_trivially_assignable + : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_trivially_copy_assignable_impl; + + template + struct __is_trivially_copy_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_trivially_copy_assignable_impl<_Tp, true> + : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> + { }; + + /// is_trivially_copy_assignable + template + struct is_trivially_copy_assignable + : public __is_trivially_copy_assignable_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + template::value> + struct __is_trivially_move_assignable_impl; + + template + struct __is_trivially_move_assignable_impl<_Tp, false> + : public false_type { }; + + template + struct __is_trivially_move_assignable_impl<_Tp, true> + : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> + { }; + + /// is_trivially_move_assignable + template + struct is_trivially_move_assignable + : public __is_trivially_move_assignable_impl<_Tp> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_trivially_destructible + template + struct is_trivially_destructible + : public __and_<__is_destructible_safe<_Tp>, + __bool_constant<__has_trivial_destructor(_Tp)>> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + + /// has_virtual_destructor + template + struct has_virtual_destructor + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + + // type property queries. + + /// alignment_of + template + struct alignment_of + : public integral_constant + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// rank + template + struct rank + : public integral_constant { }; + + template + struct rank<_Tp[_Size]> + : public integral_constant::value> { }; + + template + struct rank<_Tp[]> + : public integral_constant::value> { }; + + /// extent + template + struct extent + : public integral_constant { }; + + template + struct extent<_Tp[_Size], _Uint> + : public integral_constant::value> + { }; + + template + struct extent<_Tp[], _Uint> + : public integral_constant::value> + { }; + + + // Type relations. + + /// is_same + template + struct is_same +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME + : public integral_constant +#else + : public false_type +#endif + { }; + +#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME + template + struct is_same<_Tp, _Tp> + : public true_type + { }; +#endif + + /// is_base_of + template + struct is_base_of + : public integral_constant + { }; + + template, is_function<_To>, + is_array<_To>>::value> + struct __is_convertible_helper + { + typedef typename is_void<_To>::type type; + }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + template + class __is_convertible_helper<_From, _To, false> + { + template + static void __test_aux(_To1) noexcept; + + template(std::declval<_From1>()))> + static true_type + __test(int); + + template + static false_type + __test(...); + + public: + typedef decltype(__test<_From, _To>(0)) type; + }; +#pragma GCC diagnostic pop + + /// is_convertible + template + struct is_convertible + : public __is_convertible_helper<_From, _To>::type + { }; + + // helper trait for unique_ptr, shared_ptr, and span + template + using __is_array_convertible + = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; + + template, is_function<_To>, + is_array<_To>>::value> + struct __is_nt_convertible_helper + : is_void<_To> + { }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + template + class __is_nt_convertible_helper<_From, _To, false> + { + template + static void __test_aux(_To1) noexcept; + + template + static + __bool_constant(std::declval<_From1>()))> + __test(int); + + template + static false_type + __test(...); + + public: + using type = decltype(__test<_From, _To>(0)); + }; +#pragma GCC diagnostic pop + + // is_nothrow_convertible for C++11 + template + struct __is_nothrow_convertible + : public __is_nt_convertible_helper<_From, _To>::type + { }; + +#if __cplusplus > 201703L +#define __cpp_lib_is_nothrow_convertible 201806L + /// is_nothrow_convertible + template + struct is_nothrow_convertible + : public __is_nt_convertible_helper<_From, _To>::type + { }; + + /// is_nothrow_convertible_v + template + inline constexpr bool is_nothrow_convertible_v + = is_nothrow_convertible<_From, _To>::value; +#endif // C++2a + + // Const-volatile modifications. + + /// remove_const + template + struct remove_const + { typedef _Tp type; }; + + template + struct remove_const<_Tp const> + { typedef _Tp type; }; + + /// remove_volatile + template + struct remove_volatile + { typedef _Tp type; }; + + template + struct remove_volatile<_Tp volatile> + { typedef _Tp type; }; + + /// remove_cv + template + struct remove_cv + { using type = _Tp; }; + + template + struct remove_cv + { using type = _Tp; }; + + template + struct remove_cv + { using type = _Tp; }; + + template + struct remove_cv + { using type = _Tp; }; + + /// add_const + template + struct add_const + { typedef _Tp const type; }; + + /// add_volatile + template + struct add_volatile + { typedef _Tp volatile type; }; + + /// add_cv + template + struct add_cv + { + typedef typename + add_const::type>::type type; + }; + +#if __cplusplus > 201103L + +#define __cpp_lib_transformation_trait_aliases 201304L + + /// Alias template for remove_const + template + using remove_const_t = typename remove_const<_Tp>::type; + + /// Alias template for remove_volatile + template + using remove_volatile_t = typename remove_volatile<_Tp>::type; + + /// Alias template for remove_cv + template + using remove_cv_t = typename remove_cv<_Tp>::type; + + /// Alias template for add_const + template + using add_const_t = typename add_const<_Tp>::type; + + /// Alias template for add_volatile + template + using add_volatile_t = typename add_volatile<_Tp>::type; + + /// Alias template for add_cv + template + using add_cv_t = typename add_cv<_Tp>::type; +#endif + + // Reference transformations. + + /// remove_reference + template + struct remove_reference + { typedef _Tp type; }; + + template + struct remove_reference<_Tp&> + { typedef _Tp type; }; + + template + struct remove_reference<_Tp&&> + { typedef _Tp type; }; + + template::value> + struct __add_lvalue_reference_helper + { typedef _Tp type; }; + + template + struct __add_lvalue_reference_helper<_Tp, true> + { typedef _Tp& type; }; + + /// add_lvalue_reference + template + struct add_lvalue_reference + : public __add_lvalue_reference_helper<_Tp> + { }; + + template::value> + struct __add_rvalue_reference_helper + { typedef _Tp type; }; + + template + struct __add_rvalue_reference_helper<_Tp, true> + { typedef _Tp&& type; }; + + /// add_rvalue_reference + template + struct add_rvalue_reference + : public __add_rvalue_reference_helper<_Tp> + { }; + +#if __cplusplus > 201103L + /// Alias template for remove_reference + template + using remove_reference_t = typename remove_reference<_Tp>::type; + + /// Alias template for add_lvalue_reference + template + using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; + + /// Alias template for add_rvalue_reference + template + using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; +#endif + + // Sign modifications. + + /// @cond undocumented + + // Utility for constructing identically cv-qualified types. + template + struct __cv_selector; + + template + struct __cv_selector<_Unqualified, false, false> + { typedef _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, false, true> + { typedef volatile _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, false> + { typedef const _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, true> + { typedef const volatile _Unqualified __type; }; + + template::value, + bool _IsVol = is_volatile<_Qualified>::value> + class __match_cv_qualifiers + { + typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; + + public: + typedef typename __match::__type __type; + }; + + // Utility for finding the unsigned versions of signed integral types. + template + struct __make_unsigned + { typedef _Tp __type; }; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned short __type; }; + + template<> + struct __make_unsigned + { typedef unsigned int __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long long __type; }; + +#if defined(__GLIBCXX_TYPE_INT_N_0) + __extension__ + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> + { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + __extension__ + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> + { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + __extension__ + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> + { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + __extension__ + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> + { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; +#endif + + // Select between integral and enum: not possible to be both. + template::value, + bool _IsEnum = is_enum<_Tp>::value> + class __make_unsigned_selector; + + template + class __make_unsigned_selector<_Tp, true, false> + { + using __unsigned_type + = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; + + public: + using __type + = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; + }; + + class __make_unsigned_selector_base + { + protected: + template struct _List { }; + + template + struct _List<_Tp, _Up...> : _List<_Up...> + { static constexpr size_t __size = sizeof(_Tp); }; + + template + struct __select; + + template + struct __select<_Sz, _List<_Uint, _UInts...>, true> + { using __type = _Uint; }; + + template + struct __select<_Sz, _List<_Uint, _UInts...>, false> + : __select<_Sz, _List<_UInts...>> + { }; + }; + + // Choose unsigned integer type with the smallest rank and same size as _Tp + template + class __make_unsigned_selector<_Tp, false, true> + : __make_unsigned_selector_base + { + // With -fshort-enums, an enum may be as small as a char. + using _UInts = _List; + + using __unsigned_type = typename __select::__type; + + public: + using __type + = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; + }; + + // wchar_t, char8_t, char16_t and char32_t are integral types but are + // neither signed integer types nor unsigned integer types, so must be + // transformed to the unsigned integer type with the smallest rank. + // Use the partial specialization for enumeration types to do that. + template<> + struct __make_unsigned + { + using __type + = typename __make_unsigned_selector::__type; + }; + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __make_unsigned + { + using __type + = typename __make_unsigned_selector::__type; + }; +#endif + + template<> + struct __make_unsigned + { + using __type + = typename __make_unsigned_selector::__type; + }; + + template<> + struct __make_unsigned + { + using __type + = typename __make_unsigned_selector::__type; + }; + /// @endcond + + // Given an integral/enum type, return the corresponding unsigned + // integer type. + // Primary template. + /// make_unsigned + template + struct make_unsigned + { typedef typename __make_unsigned_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_unsigned; + + /// @cond undocumented + + // Utility for finding the signed versions of unsigned integral types. + template + struct __make_signed + { typedef _Tp __type; }; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed short __type; }; + + template<> + struct __make_signed + { typedef signed int __type; }; + + template<> + struct __make_signed + { typedef signed long __type; }; + + template<> + struct __make_signed + { typedef signed long long __type; }; + +#if defined(__GLIBCXX_TYPE_INT_N_0) + __extension__ + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + __extension__ + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + __extension__ + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + __extension__ + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; +#endif + + // Select between integral and enum: not possible to be both. + template::value, + bool _IsEnum = is_enum<_Tp>::value> + class __make_signed_selector; + + template + class __make_signed_selector<_Tp, true, false> + { + using __signed_type + = typename __make_signed<__remove_cv_t<_Tp>>::__type; + + public: + using __type + = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; + }; + + // Choose signed integer type with the smallest rank and same size as _Tp + template + class __make_signed_selector<_Tp, false, true> + { + typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; + + public: + typedef typename __make_signed_selector<__unsigned_type>::__type __type; + }; + + // wchar_t, char16_t and char32_t are integral types but are neither + // signed integer types nor unsigned integer types, so must be + // transformed to the signed integer type with the smallest rank. + // Use the partial specialization for enumeration types to do that. + template<> + struct __make_signed + { + using __type + = typename __make_signed_selector::__type; + }; + +#if defined(_GLIBCXX_USE_CHAR8_T) + template<> + struct __make_signed + { + using __type + = typename __make_signed_selector::__type; + }; +#endif + + template<> + struct __make_signed + { + using __type + = typename __make_signed_selector::__type; + }; + + template<> + struct __make_signed + { + using __type + = typename __make_signed_selector::__type; + }; + /// @endcond + + // Given an integral/enum type, return the corresponding signed + // integer type. + // Primary template. + /// make_signed + template + struct make_signed + { typedef typename __make_signed_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_signed; + +#if __cplusplus > 201103L + /// Alias template for make_signed + template + using make_signed_t = typename make_signed<_Tp>::type; + + /// Alias template for make_unsigned + template + using make_unsigned_t = typename make_unsigned<_Tp>::type; +#endif + + // Array modifications. + + /// remove_extent + template + struct remove_extent + { typedef _Tp type; }; + + template + struct remove_extent<_Tp[_Size]> + { typedef _Tp type; }; + + template + struct remove_extent<_Tp[]> + { typedef _Tp type; }; + + /// remove_all_extents + template + struct remove_all_extents + { typedef _Tp type; }; + + template + struct remove_all_extents<_Tp[_Size]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + template + struct remove_all_extents<_Tp[]> + { typedef typename remove_all_extents<_Tp>::type type; }; + +#if __cplusplus > 201103L + /// Alias template for remove_extent + template + using remove_extent_t = typename remove_extent<_Tp>::type; + + /// Alias template for remove_all_extents + template + using remove_all_extents_t = typename remove_all_extents<_Tp>::type; +#endif + + // Pointer modifications. + + template + struct __remove_pointer_helper + { typedef _Tp type; }; + + template + struct __remove_pointer_helper<_Tp, _Up*> + { typedef _Up type; }; + + /// remove_pointer + template + struct remove_pointer + : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> + { }; + + template, + is_void<_Tp>>::value> + struct __add_pointer_helper + { typedef _Tp type; }; + + template + struct __add_pointer_helper<_Tp, true> + { typedef typename remove_reference<_Tp>::type* type; }; + + /// add_pointer + template + struct add_pointer + : public __add_pointer_helper<_Tp> + { }; + +#if __cplusplus > 201103L + /// Alias template for remove_pointer + template + using remove_pointer_t = typename remove_pointer<_Tp>::type; + + /// Alias template for add_pointer + template + using add_pointer_t = typename add_pointer<_Tp>::type; +#endif + + template + struct __aligned_storage_msa + { + union __type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__)) { } __align; + }; + }; + + /** + * @brief Alignment type. + * + * The value of _Align is a default-alignment which shall be the + * most stringent alignment requirement for any C++ object type + * whose size is no greater than _Len (3.9). The member typedef + * type shall be a POD type suitable for use as uninitialized + * storage for any object whose size is at most _Len and whose + * alignment is a divisor of _Align. + */ + template::__type)> + struct aligned_storage + { + union type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__((_Align)))) { } __align; + }; + }; + + template + struct __strictest_alignment + { + static const size_t _S_alignment = 0; + static const size_t _S_size = 0; + }; + + template + struct __strictest_alignment<_Tp, _Types...> + { + static const size_t _S_alignment = + alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment + ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; + static const size_t _S_size = + sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size + ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; + }; + + /** + * @brief Provide aligned storage for types. + * + * [meta.trans.other] + * + * Provides aligned storage for any of the provided types of at + * least size _Len. + * + * @see aligned_storage + */ + template + struct aligned_union + { + private: + static_assert(sizeof...(_Types) != 0, "At least one type is required"); + + using __strictest = __strictest_alignment<_Types...>; + static const size_t _S_len = _Len > __strictest::_S_size + ? _Len : __strictest::_S_size; + public: + /// The value of the strictest alignment of _Types. + static const size_t alignment_value = __strictest::_S_alignment; + /// The storage. + typedef typename aligned_storage<_S_len, alignment_value>::type type; + }; + + template + const size_t aligned_union<_Len, _Types...>::alignment_value; + + /// @cond undocumented + + // Decay trait for arrays and functions, used for perfect forwarding + // in make_pair, make_tuple, etc. + template::value, + bool _IsFunction = is_function<_Up>::value> + struct __decay_selector; + + // NB: DR 705. + template + struct __decay_selector<_Up, false, false> + { typedef __remove_cv_t<_Up> __type; }; + + template + struct __decay_selector<_Up, true, false> + { typedef typename remove_extent<_Up>::type* __type; }; + + template + struct __decay_selector<_Up, false, true> + { typedef typename add_pointer<_Up>::type __type; }; + /// @endcond + + /// decay + template + class decay + { + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + /// @cond undocumented + + // Helper which adds a reference to a type when given a reference_wrapper + template + struct __strip_reference_wrapper + { + typedef _Tp __type; + }; + + template + struct __strip_reference_wrapper > + { + typedef _Tp& __type; + }; + + // __decay_t (std::decay_t for C++11). + template + using __decay_t = typename decay<_Tp>::type; + + template + using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; + /// @endcond + + // Primary template. + /// Define a member typedef `type` only if a boolean constant is true. + template + struct enable_if + { }; + + // Partial specialization for true. + template + struct enable_if + { typedef _Tp type; }; + + /// @cond undocumented + + // __enable_if_t (std::enable_if_t for C++11) + template + using __enable_if_t = typename enable_if<_Cond, _Tp>::type; + + // Helper for SFINAE constraints + template + using _Require = __enable_if_t<__and_<_Cond...>::value>; + + // __remove_cvref_t (std::remove_cvref_t for C++11). + template + using __remove_cvref_t + = typename remove_cv::type>::type; + /// @endcond + + // Primary template. + /// Define a member typedef @c type to one of two argument types. + template + struct conditional + { typedef _Iftrue type; }; + + // Partial specialization for false. + template + struct conditional + { typedef _Iffalse type; }; + + /// common_type + template + struct common_type; + + // Sfinae-friendly common_type implementation: + + /// @cond undocumented + struct __do_common_type_impl + { + template + using __cond_t + = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); + + // if decay_t() : declval())> + // denotes a valid type, let C denote that type. + template + static __success_type<__decay_t<__cond_t<_Tp, _Up>>> + _S_test(int); + +#if __cplusplus > 201703L + // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, + // let C denote the type decay_t. + template + static __success_type<__remove_cvref_t<__cond_t>> + _S_test_2(int); +#endif + + template + static __failure_type + _S_test_2(...); + + template + static decltype(_S_test_2<_Tp, _Up>(0)) + _S_test(...); + }; + + // If sizeof...(T) is zero, there shall be no member type. + template<> + struct common_type<> + { }; + + // If sizeof...(T) is one, the same type, if any, as common_type_t. + template + struct common_type<_Tp0> + : public common_type<_Tp0, _Tp0> + { }; + + // If sizeof...(T) is two, ... + template, typename _Dp2 = __decay_t<_Tp2>> + struct __common_type_impl + { + // If is_same_v is false or is_same_v is false, + // let C denote the same type, if any, as common_type_t. + using type = common_type<_Dp1, _Dp2>; + }; + + template + struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> + : private __do_common_type_impl + { + // Otherwise, if decay_t() : declval())> + // denotes a valid type, let C denote that type. + using type = decltype(_S_test<_Tp1, _Tp2>(0)); + }; + + // If sizeof...(T) is two, ... + template + struct common_type<_Tp1, _Tp2> + : public __common_type_impl<_Tp1, _Tp2>::type + { }; + + template + struct __common_type_pack + { }; + + template + struct __common_type_fold; + + // If sizeof...(T) is greater than two, ... + template + struct common_type<_Tp1, _Tp2, _Rp...> + : public __common_type_fold, + __common_type_pack<_Rp...>> + { }; + + // Let C denote the same type, if any, as common_type_t. + // If there is such a type C, type shall denote the same type, if any, + // as common_type_t. + template + struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, + __void_t> + : public common_type + { }; + + // Otherwise, there shall be no member type. + template + struct __common_type_fold<_CTp, _Rp, void> + { }; + + template::value> + struct __underlying_type_impl + { + using type = __underlying_type(_Tp); + }; + + template + struct __underlying_type_impl<_Tp, false> + { }; + /// @endcond + + /// The underlying type of an enum. + template + struct underlying_type + : public __underlying_type_impl<_Tp> + { }; + + /// @cond undocumented + template + struct __declval_protector + { + static const bool __stop = false; + }; + /// @endcond + + /** Utility to simplify expressions used in unevaluated operands + * @since C++11 + * @ingroup utilities + */ + template + auto declval() noexcept -> decltype(__declval<_Tp>(0)) + { + static_assert(__declval_protector<_Tp>::__stop, + "declval() must not be used!"); + return __declval<_Tp>(0); + } + + /// result_of + template + struct result_of; + + // Sfinae-friendly result_of implementation: + +#define __cpp_lib_result_of_sfinae 201210L + + /// @cond undocumented + struct __invoke_memfun_ref { }; + struct __invoke_memfun_deref { }; + struct __invoke_memobj_ref { }; + struct __invoke_memobj_deref { }; + struct __invoke_other { }; + + // Associate a tag type with a specialization of __success_type. + template + struct __result_of_success : __success_type<_Tp> + { using __invoke_type = _Tag; }; + + // [func.require] paragraph 1 bullet 1: + struct __result_of_memfun_ref_impl + { + template + static __result_of_success().*std::declval<_Fp>())(std::declval<_Args>()...) + ), __invoke_memfun_ref> _S_test(int); + + template + static __failure_type _S_test(...); + }; + + template + struct __result_of_memfun_ref + : private __result_of_memfun_ref_impl + { + typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; + }; + + // [func.require] paragraph 1 bullet 2: + struct __result_of_memfun_deref_impl + { + template + static __result_of_success()).*std::declval<_Fp>())(std::declval<_Args>()...) + ), __invoke_memfun_deref> _S_test(int); + + template + static __failure_type _S_test(...); + }; + + template + struct __result_of_memfun_deref + : private __result_of_memfun_deref_impl + { + typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; + }; + + // [func.require] paragraph 1 bullet 3: + struct __result_of_memobj_ref_impl + { + template + static __result_of_success().*std::declval<_Fp>() + ), __invoke_memobj_ref> _S_test(int); + + template + static __failure_type _S_test(...); + }; + + template + struct __result_of_memobj_ref + : private __result_of_memobj_ref_impl + { + typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; + }; + + // [func.require] paragraph 1 bullet 4: + struct __result_of_memobj_deref_impl + { + template + static __result_of_success()).*std::declval<_Fp>() + ), __invoke_memobj_deref> _S_test(int); + + template + static __failure_type _S_test(...); + }; + + template + struct __result_of_memobj_deref + : private __result_of_memobj_deref_impl + { + typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; + }; + + template + struct __result_of_memobj; + + template + struct __result_of_memobj<_Res _Class::*, _Arg> + { + typedef __remove_cvref_t<_Arg> _Argval; + typedef _Res _Class::* _MemPtr; + typedef typename __conditional_t<__or_, + is_base_of<_Class, _Argval>>::value, + __result_of_memobj_ref<_MemPtr, _Arg>, + __result_of_memobj_deref<_MemPtr, _Arg> + >::type type; + }; + + template + struct __result_of_memfun; + + template + struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> + { + typedef typename remove_reference<_Arg>::type _Argval; + typedef _Res _Class::* _MemPtr; + typedef typename __conditional_t::value, + __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, + __result_of_memfun_deref<_MemPtr, _Arg, _Args...> + >::type type; + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2219. INVOKE-ing a pointer to member with a reference_wrapper + // as the object expression + + // Used by result_of, invoke etc. to unwrap a reference_wrapper. + template> + struct __inv_unwrap + { + using type = _Tp; + }; + + template + struct __inv_unwrap<_Tp, reference_wrapper<_Up>> + { + using type = _Up&; + }; + + template + struct __result_of_impl + { + typedef __failure_type type; + }; + + template + struct __result_of_impl + : public __result_of_memobj<__decay_t<_MemPtr>, + typename __inv_unwrap<_Arg>::type> + { }; + + template + struct __result_of_impl + : public __result_of_memfun<__decay_t<_MemPtr>, + typename __inv_unwrap<_Arg>::type, _Args...> + { }; + + // [func.require] paragraph 1 bullet 5: + struct __result_of_other_impl + { + template + static __result_of_success()(std::declval<_Args>()...) + ), __invoke_other> _S_test(int); + + template + static __failure_type _S_test(...); + }; + + template + struct __result_of_impl + : private __result_of_other_impl + { + typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; + }; + + // __invoke_result (std::invoke_result for C++11) + template + struct __invoke_result + : public __result_of_impl< + is_member_object_pointer< + typename remove_reference<_Functor>::type + >::value, + is_member_function_pointer< + typename remove_reference<_Functor>::type + >::value, + _Functor, _ArgTypes... + >::type + { }; + /// @endcond + + template + struct result_of<_Functor(_ArgTypes...)> + : public __invoke_result<_Functor, _ArgTypes...> + { } _GLIBCXX17_DEPRECATED_SUGGEST("std::invoke_result"); + +#if __cplusplus >= 201402L + /// Alias template for aligned_storage + template::__type)> + using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; + + template + using aligned_union_t = typename aligned_union<_Len, _Types...>::type; + + /// Alias template for decay + template + using decay_t = typename decay<_Tp>::type; + + /// Alias template for enable_if + template + using enable_if_t = typename enable_if<_Cond, _Tp>::type; + + /// Alias template for conditional + template + using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; + + /// Alias template for common_type + template + using common_type_t = typename common_type<_Tp...>::type; + + /// Alias template for underlying_type + template + using underlying_type_t = typename underlying_type<_Tp>::type; + + /// Alias template for result_of + template + using result_of_t = typename result_of<_Tp>::type; +#endif // C++14 + +#if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 +#define __cpp_lib_void_t 201411L + /// A metafunction that always yields void, used for detecting valid types. + template using void_t = void; +#endif + + /// @cond undocumented + + /// Implementation of the detection idiom (negative case). + template class _Op, typename... _Args> + struct __detector + { + using value_t = false_type; + using type = _Default; + }; + + /// Implementation of the detection idiom (positive case). + template class _Op, + typename... _Args> + struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> + { + using value_t = true_type; + using type = _Op<_Args...>; + }; + + // Detect whether _Op<_Args...> is a valid type, use _Default if not. + template class _Op, + typename... _Args> + using __detected_or = __detector<_Default, void, _Op, _Args...>; + + // _Op<_Args...> if that is a valid type, otherwise _Default. + template class _Op, + typename... _Args> + using __detected_or_t + = typename __detected_or<_Default, _Op, _Args...>::type; + + /** + * Use SFINAE to determine if the type _Tp has a publicly-accessible + * member type _NTYPE. + */ +#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ + template> \ + struct __has_##_NTYPE \ + : false_type \ + { }; \ + template \ + struct __has_##_NTYPE<_Tp, __void_t> \ + : true_type \ + { }; + + template + struct __is_swappable; + + template + struct __is_nothrow_swappable; + + template + struct __is_tuple_like_impl : false_type + { }; + + // Internal type trait that allows us to sfinae-protect tuple_cat. + template + struct __is_tuple_like + : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type + { }; + /// @endcond + + template + _GLIBCXX20_CONSTEXPR + inline + _Require<__not_<__is_tuple_like<_Tp>>, + is_move_constructible<_Tp>, + is_move_assignable<_Tp>> + swap(_Tp&, _Tp&) + noexcept(__and_, + is_nothrow_move_assignable<_Tp>>::value); + + template + _GLIBCXX20_CONSTEXPR + inline + __enable_if_t<__is_swappable<_Tp>::value> + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) + noexcept(__is_nothrow_swappable<_Tp>::value); + + /// @cond undocumented + namespace __swappable_details { + using std::swap; + + struct __do_is_swappable_impl + { + template(), std::declval<_Tp&>()))> + static true_type __test(int); + + template + static false_type __test(...); + }; + + struct __do_is_nothrow_swappable_impl + { + template + static __bool_constant< + noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) + > __test(int); + + template + static false_type __test(...); + }; + + } // namespace __swappable_details + + template + struct __is_swappable_impl + : public __swappable_details::__do_is_swappable_impl + { + typedef decltype(__test<_Tp>(0)) type; + }; + + template + struct __is_nothrow_swappable_impl + : public __swappable_details::__do_is_nothrow_swappable_impl + { + typedef decltype(__test<_Tp>(0)) type; + }; + + template + struct __is_swappable + : public __is_swappable_impl<_Tp>::type + { }; + + template + struct __is_nothrow_swappable + : public __is_nothrow_swappable_impl<_Tp>::type + { }; + /// @endcond + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 +#define __cpp_lib_is_swappable 201603L + /// Metafunctions used for detecting swappable types: p0185r1 + + /// is_swappable + template + struct is_swappable + : public __is_swappable_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_nothrow_swappable + template + struct is_nothrow_swappable + : public __is_nothrow_swappable_impl<_Tp>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + +#if __cplusplus >= 201402L + /// is_swappable_v + template + _GLIBCXX17_INLINE constexpr bool is_swappable_v = + is_swappable<_Tp>::value; + + /// is_nothrow_swappable_v + template + _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = + is_nothrow_swappable<_Tp>::value; +#endif // __cplusplus >= 201402L + + /// @cond undocumented + namespace __swappable_with_details { + using std::swap; + + struct __do_is_swappable_with_impl + { + template(), std::declval<_Up>())), + typename + = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> + static true_type __test(int); + + template + static false_type __test(...); + }; + + struct __do_is_nothrow_swappable_with_impl + { + template + static __bool_constant< + noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) + && + noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) + > __test(int); + + template + static false_type __test(...); + }; + + } // namespace __swappable_with_details + + template + struct __is_swappable_with_impl + : public __swappable_with_details::__do_is_swappable_with_impl + { + typedef decltype(__test<_Tp, _Up>(0)) type; + }; + + // Optimization for the homogenous lvalue case, not required: + template + struct __is_swappable_with_impl<_Tp&, _Tp&> + : public __swappable_details::__do_is_swappable_impl + { + typedef decltype(__test<_Tp&>(0)) type; + }; + + template + struct __is_nothrow_swappable_with_impl + : public __swappable_with_details::__do_is_nothrow_swappable_with_impl + { + typedef decltype(__test<_Tp, _Up>(0)) type; + }; + + // Optimization for the homogenous lvalue case, not required: + template + struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> + : public __swappable_details::__do_is_nothrow_swappable_impl + { + typedef decltype(__test<_Tp&>(0)) type; + }; + /// @endcond + + /// is_swappable_with + template + struct is_swappable_with + : public __is_swappable_with_impl<_Tp, _Up>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "first template argument must be a complete class or an unbounded array"); + static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), + "second template argument must be a complete class or an unbounded array"); + }; + + /// is_nothrow_swappable_with + template + struct is_nothrow_swappable_with + : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "first template argument must be a complete class or an unbounded array"); + static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), + "second template argument must be a complete class or an unbounded array"); + }; + +#if __cplusplus >= 201402L + /// is_swappable_with_v + template + _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = + is_swappable_with<_Tp, _Up>::value; + + /// is_nothrow_swappable_with_v + template + _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = + is_nothrow_swappable_with<_Tp, _Up>::value; +#endif // __cplusplus >= 201402L + +#endif// c++1z or gnu++11 + + /// @cond undocumented + + // __is_invocable (std::is_invocable for C++11) + + // The primary template is used for invalid INVOKE expressions. + template::value, typename = void> + struct __is_invocable_impl : false_type { }; + + // Used for valid INVOKE and INVOKE expressions. + template + struct __is_invocable_impl<_Result, _Ret, + /* is_void<_Ret> = */ true, + __void_t> + : true_type + { }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + // Used for INVOKE expressions to check the implicit conversion to R. + template + struct __is_invocable_impl<_Result, _Ret, + /* is_void<_Ret> = */ false, + __void_t> + { + private: + // The type of the INVOKE expression. + // Unlike declval, this doesn't add_rvalue_reference. + static typename _Result::type _S_get(); + + template + static void _S_conv(_Tp); + + // This overload is viable if INVOKE(f, args...) can convert to _Tp. + template(_S_get()))> + static true_type + _S_test(int); + + template + static false_type + _S_test(...); + + public: + using type = decltype(_S_test<_Ret>(1)); + }; +#pragma GCC diagnostic pop + + template + struct __is_invocable + : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type + { }; + + template + constexpr bool __call_is_nt(__invoke_memfun_ref) + { + using _Up = typename __inv_unwrap<_Tp>::type; + return noexcept((std::declval<_Up>().*std::declval<_Fn>())( + std::declval<_Args>()...)); + } + + template + constexpr bool __call_is_nt(__invoke_memfun_deref) + { + return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( + std::declval<_Args>()...)); + } + + template + constexpr bool __call_is_nt(__invoke_memobj_ref) + { + using _Up = typename __inv_unwrap<_Tp>::type; + return noexcept(std::declval<_Up>().*std::declval<_Fn>()); + } + + template + constexpr bool __call_is_nt(__invoke_memobj_deref) + { + return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); + } + + template + constexpr bool __call_is_nt(__invoke_other) + { + return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); + } + + template + struct __call_is_nothrow + : __bool_constant< + std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) + > + { }; + + template + using __call_is_nothrow_ + = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; + + // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) + template + struct __is_nothrow_invocable + : __and_<__is_invocable<_Fn, _Args...>, + __call_is_nothrow_<_Fn, _Args...>>::type + { }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + struct __nonesuchbase {}; + struct __nonesuch : private __nonesuchbase { + ~__nonesuch() = delete; + __nonesuch(__nonesuch const&) = delete; + void operator=(__nonesuch const&) = delete; + }; +#pragma GCC diagnostic pop + /// @endcond + +#if __cplusplus >= 201703L +# define __cpp_lib_is_invocable 201703L + + /// std::invoke_result + template + struct invoke_result + : public __invoke_result<_Functor, _ArgTypes...> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}), + "_Functor must be a complete class or an unbounded array"); + static_assert((std::__is_complete_or_unbounded( + __type_identity<_ArgTypes>{}) && ...), + "each argument type must be a complete class or an unbounded array"); + }; + + /// std::invoke_result_t + template + using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; + + /// std::is_invocable + template + struct is_invocable + : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), + "_Fn must be a complete class or an unbounded array"); + static_assert((std::__is_complete_or_unbounded( + __type_identity<_ArgTypes>{}) && ...), + "each argument type must be a complete class or an unbounded array"); + }; + + /// std::is_invocable_r + template + struct is_invocable_r + : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), + "_Fn must be a complete class or an unbounded array"); + static_assert((std::__is_complete_or_unbounded( + __type_identity<_ArgTypes>{}) && ...), + "each argument type must be a complete class or an unbounded array"); + static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), + "_Ret must be a complete class or an unbounded array"); + }; + + /// std::is_nothrow_invocable + template + struct is_nothrow_invocable + : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, + __call_is_nothrow_<_Fn, _ArgTypes...>>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), + "_Fn must be a complete class or an unbounded array"); + static_assert((std::__is_complete_or_unbounded( + __type_identity<_ArgTypes>{}) && ...), + "each argument type must be a complete class or an unbounded array"); + }; + + /// @cond undocumented + template + struct __is_nt_invocable_impl : false_type { }; + + template + struct __is_nt_invocable_impl<_Result, _Ret, + __void_t> + : __or_, + __is_nothrow_convertible> + { }; + /// @endcond + + /// std::is_nothrow_invocable_r + template + struct is_nothrow_invocable_r + : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, + __call_is_nothrow_<_Fn, _ArgTypes...>>::type + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), + "_Fn must be a complete class or an unbounded array"); + static_assert((std::__is_complete_or_unbounded( + __type_identity<_ArgTypes>{}) && ...), + "each argument type must be a complete class or an unbounded array"); + static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), + "_Ret must be a complete class or an unbounded array"); + }; +#endif // C++17 + +#if __cplusplus >= 201703L +# define __cpp_lib_type_trait_variable_templates 201510L + /** + * @defgroup variable_templates Variable templates for type traits + * @ingroup metaprogramming + * + * Each variable `is_xxx_v` is a boolean constant with the same value + * as the `value` member of the corresponding type trait `is_xxx`. + * + * @since C++17 unless noted otherwise. + */ + + /** + * @{ + * @ingroup variable_templates + */ +template + inline constexpr bool is_void_v = is_void<_Tp>::value; +template + inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; +template + inline constexpr bool is_integral_v = is_integral<_Tp>::value; +template + inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; +template + inline constexpr bool is_array_v = is_array<_Tp>::value; +template + inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; +template + inline constexpr bool is_lvalue_reference_v = + is_lvalue_reference<_Tp>::value; +template + inline constexpr bool is_rvalue_reference_v = + is_rvalue_reference<_Tp>::value; +template + inline constexpr bool is_member_object_pointer_v = + is_member_object_pointer<_Tp>::value; +template + inline constexpr bool is_member_function_pointer_v = + is_member_function_pointer<_Tp>::value; +template + inline constexpr bool is_enum_v = is_enum<_Tp>::value; +template + inline constexpr bool is_union_v = is_union<_Tp>::value; +template + inline constexpr bool is_class_v = is_class<_Tp>::value; +template + inline constexpr bool is_function_v = is_function<_Tp>::value; +template + inline constexpr bool is_reference_v = is_reference<_Tp>::value; +template + inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; +template + inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; +template + inline constexpr bool is_object_v = is_object<_Tp>::value; +template + inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; +template + inline constexpr bool is_compound_v = is_compound<_Tp>::value; +template + inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; +template + inline constexpr bool is_const_v = is_const<_Tp>::value; +template + inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; +template + inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; +template + inline constexpr bool is_trivially_copyable_v = + is_trivially_copyable<_Tp>::value; +template + inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +template + _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead") + inline constexpr bool is_pod_v = is_pod<_Tp>::value; +template + _GLIBCXX17_DEPRECATED + inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; +#pragma GCC diagnostic pop + template + inline constexpr bool is_empty_v = is_empty<_Tp>::value; +template + inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; +template + inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; +template + inline constexpr bool is_final_v = is_final<_Tp>::value; +template + inline constexpr bool is_signed_v = is_signed<_Tp>::value; +template + inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; +template + inline constexpr bool is_constructible_v = + is_constructible<_Tp, _Args...>::value; +template + inline constexpr bool is_default_constructible_v = + is_default_constructible<_Tp>::value; +template + inline constexpr bool is_copy_constructible_v = + is_copy_constructible<_Tp>::value; +template + inline constexpr bool is_move_constructible_v = + is_move_constructible<_Tp>::value; +template + inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; +template + inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; +template + inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; +template + inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; +template + inline constexpr bool is_trivially_constructible_v = + is_trivially_constructible<_Tp, _Args...>::value; +template + inline constexpr bool is_trivially_default_constructible_v = + is_trivially_default_constructible<_Tp>::value; +template + inline constexpr bool is_trivially_copy_constructible_v = + is_trivially_copy_constructible<_Tp>::value; +template + inline constexpr bool is_trivially_move_constructible_v = + is_trivially_move_constructible<_Tp>::value; +template + inline constexpr bool is_trivially_assignable_v = + is_trivially_assignable<_Tp, _Up>::value; +template + inline constexpr bool is_trivially_copy_assignable_v = + is_trivially_copy_assignable<_Tp>::value; +template + inline constexpr bool is_trivially_move_assignable_v = + is_trivially_move_assignable<_Tp>::value; +template + inline constexpr bool is_trivially_destructible_v = + is_trivially_destructible<_Tp>::value; +template + inline constexpr bool is_nothrow_constructible_v = + is_nothrow_constructible<_Tp, _Args...>::value; +template + inline constexpr bool is_nothrow_default_constructible_v = + is_nothrow_default_constructible<_Tp>::value; +template + inline constexpr bool is_nothrow_copy_constructible_v = + is_nothrow_copy_constructible<_Tp>::value; +template + inline constexpr bool is_nothrow_move_constructible_v = + is_nothrow_move_constructible<_Tp>::value; +template + inline constexpr bool is_nothrow_assignable_v = + is_nothrow_assignable<_Tp, _Up>::value; +template + inline constexpr bool is_nothrow_copy_assignable_v = + is_nothrow_copy_assignable<_Tp>::value; +template + inline constexpr bool is_nothrow_move_assignable_v = + is_nothrow_move_assignable<_Tp>::value; +template + inline constexpr bool is_nothrow_destructible_v = + is_nothrow_destructible<_Tp>::value; +template + inline constexpr bool has_virtual_destructor_v = + has_virtual_destructor<_Tp>::value; +template + inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; +template + inline constexpr size_t rank_v = rank<_Tp>::value; +template + inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME +template + inline constexpr bool is_same_v = __is_same(_Tp, _Up); +#else +template + inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; +#endif +template + inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; +template + inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; +template + inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; +template + inline constexpr bool is_nothrow_invocable_v + = is_nothrow_invocable<_Fn, _Args...>::value; +template + inline constexpr bool is_invocable_r_v + = is_invocable_r<_Ret, _Fn, _Args...>::value; +template + inline constexpr bool is_nothrow_invocable_r_v + = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; +/// @} + +#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP +# define __cpp_lib_has_unique_object_representations 201606L + /// has_unique_object_representations + /// @since C++17 + template + struct has_unique_object_representations + : bool_constant<__has_unique_object_representations( + remove_cv_t> + )> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// @ingroup variable_templates + template + inline constexpr bool has_unique_object_representations_v + = has_unique_object_representations<_Tp>::value; +#endif + +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE +# define __cpp_lib_is_aggregate 201703L + /// is_aggregate + /// @since C++17 + template + struct is_aggregate + : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> + { }; + + /// @ingroup variable_templates + template + inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; +#endif +#endif // C++17 + +#if __cplusplus >= 202002L + + /** * Remove references and cv-qualifiers. + * @since C++20 + * @{ + */ +#define __cpp_lib_remove_cvref 201711L + + template + struct remove_cvref + : remove_cv<_Tp> + { }; + + template + struct remove_cvref<_Tp&> + : remove_cv<_Tp> + { }; + + template + struct remove_cvref<_Tp&&> + : remove_cv<_Tp> + { }; + + template + using remove_cvref_t = typename remove_cvref<_Tp>::type; + /// @} + + /** * Identity metafunction. + * @since C++20 + * @{ + */ +#define __cpp_lib_type_identity 201806L + template + struct type_identity { using type = _Tp; }; + + template + using type_identity_t = typename type_identity<_Tp>::type; + /// @} + +#define __cpp_lib_unwrap_ref 201811L + + /** Unwrap a reference_wrapper + * @since C++20 + * @{ + */ + template + struct unwrap_reference { using type = _Tp; }; + + template + struct unwrap_reference> { using type = _Tp&; }; + + template + using unwrap_reference_t = typename unwrap_reference<_Tp>::type; + /// @} + + /** Decay type and if it's a reference_wrapper, unwrap it + * @since C++20 + * @{ + */ + template + struct unwrap_ref_decay { using type = unwrap_reference_t>; }; + + template + using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; + /// @} + +#define __cpp_lib_bounded_array_traits 201902L + + /// True for a type that is an array of known bound. + /// @since C++20 + template + struct is_bounded_array + : public __is_array_known_bounds<_Tp> + { }; + + /// True for a type that is an array of unknown bound. + /// @since C++20 + template + struct is_unbounded_array + : public __is_array_unknown_bounds<_Tp> + { }; + + /// @ingroup variable_templates + /// @since C++20 + template + inline constexpr bool is_bounded_array_v + = is_bounded_array<_Tp>::value; + + /// @ingroup variable_templates + /// @since C++20 + template + inline constexpr bool is_unbounded_array_v + = is_unbounded_array<_Tp>::value; + +#if __has_builtin(__is_layout_compatible) + + /// @since C++20 + template + struct is_layout_compatible + : bool_constant<__is_layout_compatible(_Tp, _Up)> + { }; + + /// @ingroup variable_templates + /// @since C++20 + template + constexpr bool is_layout_compatible_v + = __is_layout_compatible(_Tp, _Up); + +#if __has_builtin(__builtin_is_corresponding_member) +#define __cpp_lib_is_layout_compatible 201907L + + /// @since C++20 + template + constexpr bool + is_corresponding_member(_M1 _S1::*__m1, _M2 _S2::*__m2) noexcept + { return __builtin_is_corresponding_member(__m1, __m2); } +#endif +#endif + +#if __has_builtin(__is_pointer_interconvertible_base_of) + /// True if `_Derived` is standard-layout and has a base class of type `_Base` + /// @since C++20 + template + struct is_pointer_interconvertible_base_of + : bool_constant<__is_pointer_interconvertible_base_of(_Base, _Derived)> + { }; + + /// @ingroup variable_templates + /// @since C++20 + template + constexpr bool is_pointer_interconvertible_base_of_v + = __is_pointer_interconvertible_base_of(_Base, _Derived); + +#if __has_builtin(__builtin_is_pointer_interconvertible_with_class) +#define __cpp_lib_is_pointer_interconvertible 201907L + + /// True if `__mp` points to the first member of a standard-layout type + /// @returns true if `s.*__mp` is pointer-interconvertible with `s` + /// @since C++20 + template + constexpr bool + is_pointer_interconvertible_with_class(_Mem _Tp::*__mp) noexcept + { return __builtin_is_pointer_interconvertible_with_class(__mp); } +#endif +#endif + +#if __cplusplus > 202002L +#define __cpp_lib_is_scoped_enum 202011L + + /// True if the type is a scoped enumeration type. + /// @since C++23 + + template + struct is_scoped_enum + : false_type + { }; + + template + requires __is_enum(_Tp) + && requires(_Tp __t) { __t = __t; } // fails if incomplete + struct is_scoped_enum<_Tp> + : bool_constant + { }; + + // FIXME remove this partial specialization and use remove_cv_t<_Tp> above + // when PR c++/99968 is fixed. + template + requires __is_enum(_Tp) + && requires(_Tp __t) { __t = __t; } // fails if incomplete + struct is_scoped_enum + : bool_constant + { }; + + /// @ingroup variable_templates + /// @since C++23 + template + inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; + +#endif // C++23 + +#if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED +#define __cpp_lib_is_constant_evaluated 201811L + + /// Returns true only when called during constant evaluation. + /// @since C++20 + constexpr inline bool + is_constant_evaluated() noexcept + { +#if __cpp_if_consteval >= 202106L + if consteval { return true; } else { return false; } +#else + return __builtin_is_constant_evaluated(); +#endif + } +#endif + + /// @cond undocumented + template + using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type; + + template + using __cond_res + = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); + + template + struct __common_ref_impl + { }; + + // [meta.trans.other], COMMON-REF(A, B) + template + using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type; + + // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &) + template + using __condres_cvref + = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; + + // If A and B are both lvalue reference types, ... + template + struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>> + : enable_if>, + __condres_cvref<_Xp, _Yp>> + { }; + + // let C be remove_reference_t&& + template + using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&; + + // If A and B are both rvalue reference types, ... + template + struct __common_ref_impl<_Xp&&, _Yp&&, + _Require>, + is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>> + { using type = __common_ref_C<_Xp, _Yp>; }; + + // let D be COMMON-REF(const X&, Y&) + template + using __common_ref_D = __common_ref; + + // If A is an rvalue reference and B is an lvalue reference, ... + template + struct __common_ref_impl<_Xp&&, _Yp&, + _Require>>> + { using type = __common_ref_D<_Xp, _Yp>; }; + + // If A is an lvalue reference and B is an rvalue reference, ... + template + struct __common_ref_impl<_Xp&, _Yp&&> + : __common_ref_impl<_Yp&&, _Xp&> + { }; + /// @endcond + + template class _TQual, template class _UQual> + struct basic_common_reference + { }; + + /// @cond undocumented + template + struct __xref + { template using __type = __copy_cv<_Tp, _Up>; }; + + template + struct __xref<_Tp&> + { template using __type = __copy_cv<_Tp, _Up>&; }; + + template + struct __xref<_Tp&&> + { template using __type = __copy_cv<_Tp, _Up>&&; }; + + template + using __basic_common_ref + = typename basic_common_reference, + remove_cvref_t<_Tp2>, + __xref<_Tp1>::template __type, + __xref<_Tp2>::template __type>::type; + /// @endcond + + template + struct common_reference; + + template + using common_reference_t = typename common_reference<_Tp...>::type; + + // If sizeof...(T) is zero, there shall be no member type. + template<> + struct common_reference<> + { }; + + // If sizeof...(T) is one ... + template + struct common_reference<_Tp0> + { using type = _Tp0; }; + + /// @cond undocumented + template + struct __common_reference_impl + : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> + { }; + + // If sizeof...(T) is two ... + template + struct common_reference<_Tp1, _Tp2> + : __common_reference_impl<_Tp1, _Tp2> + { }; + + // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... + template + struct __common_reference_impl<_Tp1&, _Tp2&, 1, + void_t<__common_ref<_Tp1&, _Tp2&>>> + { using type = __common_ref<_Tp1&, _Tp2&>; }; + + template + struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, + void_t<__common_ref<_Tp1&&, _Tp2&&>>> + { using type = __common_ref<_Tp1&&, _Tp2&&>; }; + + template + struct __common_reference_impl<_Tp1&, _Tp2&&, 1, + void_t<__common_ref<_Tp1&, _Tp2&&>>> + { using type = __common_ref<_Tp1&, _Tp2&&>; }; + + template + struct __common_reference_impl<_Tp1&&, _Tp2&, 1, + void_t<__common_ref<_Tp1&&, _Tp2&>>> + { using type = __common_ref<_Tp1&&, _Tp2&>; }; + + // Otherwise, if basic_common_reference<...>::type is well-formed, ... + template + struct __common_reference_impl<_Tp1, _Tp2, 2, + void_t<__basic_common_ref<_Tp1, _Tp2>>> + { using type = __basic_common_ref<_Tp1, _Tp2>; }; + + // Otherwise, if COND-RES(T1, T2) is well-formed, ... + template + struct __common_reference_impl<_Tp1, _Tp2, 3, + void_t<__cond_res<_Tp1, _Tp2>>> + { using type = __cond_res<_Tp1, _Tp2>; }; + + // Otherwise, if common_type_t is well-formed, ... + template + struct __common_reference_impl<_Tp1, _Tp2, 4, + void_t>> + { using type = common_type_t<_Tp1, _Tp2>; }; + + // Otherwise, there shall be no member type. + template + struct __common_reference_impl<_Tp1, _Tp2, 5, void> + { }; + + // Otherwise, if sizeof...(T) is greater than two, ... + template + struct common_reference<_Tp1, _Tp2, _Rest...> + : __common_type_fold, + __common_type_pack<_Rest...>> + { }; + + // Reuse __common_type_fold for common_reference + template + struct __common_type_fold, + __common_type_pack<_Rest...>, + void_t>> + : public common_reference, _Rest...> + { }; + /// @endcond + +#endif // C++2a + + /// @} group metaprogramming + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_TYPE_TRAITS diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits.blob new file mode 100644 index 0000000000000000000000000000000000000000..98396287efac2d2e0488e76519fbfb10531ac3ab Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@type_traits.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex new file mode 100644 index 0000000000000000000000000000000000000000..e1f472709aa723194691ffe5c1a93f8f4f90e42a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex @@ -0,0 +1,129 @@ +// C++11 -*- C++ -*- + +// Copyright (C) 2010-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/typeindex + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_TYPEINDEX +#define _GLIBCXX_TYPEINDEX 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Class type_index + * @ingroup utilities + * + * The class type_index provides a simple wrapper for type_info + * which can be used as an index type in associative containers + * (23.6) and in unordered associative containers (23.7). + */ + struct type_index + { + type_index(const type_info& __rhs) noexcept + : _M_target(&__rhs) { } + + bool + operator==(const type_index& __rhs) const noexcept + { return *_M_target == *__rhs._M_target; } + +#if ! __cpp_lib_three_way_comparison + bool + operator!=(const type_index& __rhs) const noexcept + { return *_M_target != *__rhs._M_target; } +#endif + + bool + operator<(const type_index& __rhs) const noexcept + { return _M_target->before(*__rhs._M_target); } + + bool + operator<=(const type_index& __rhs) const noexcept + { return !__rhs._M_target->before(*_M_target); } + + bool + operator>(const type_index& __rhs) const noexcept + { return __rhs._M_target->before(*_M_target); } + + bool + operator>=(const type_index& __rhs) const noexcept + { return !_M_target->before(*__rhs._M_target); } + +#if __cpp_lib_three_way_comparison + strong_ordering + operator<=>(const type_index& __rhs) const noexcept + { + if (*_M_target == *__rhs._M_target) + return strong_ordering::equal; + if (_M_target->before(*__rhs._M_target)) + return strong_ordering::less; + return strong_ordering::greater; + } +#endif + + size_t + hash_code() const noexcept + { return _M_target->hash_code(); } + + const char* + name() const noexcept + { return _M_target->name(); } + + private: + const type_info* _M_target; + }; + + template struct hash; + + /// std::hash specialization for type_index. + template<> + struct hash + { + typedef size_t result_type; + typedef type_index argument_type; + + size_t + operator()(const type_index& __ti) const noexcept + { return __ti.hash_code(); } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_TYPEINDEX diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex.blob new file mode 100644 index 0000000000000000000000000000000000000000..e2a875e8cfbbc0a438bf2ca17d6cf584414193f8 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeindex.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo new file mode 100644 index 0000000000000000000000000000000000000000..3018a510fd5f8634ec5e7fc98958e0eb232a9183 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo @@ -0,0 +1,255 @@ +// RTTI support for -*- C++ -*- +// Copyright (C) 1994-2022 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file typeinfo + * This is a Standard C++ Library header. + */ + +#ifndef _TYPEINFO +#define _TYPEINFO + +#pragma GCC system_header + +#include +#if __cplusplus >= 201103L +#include +#endif + +#pragma GCC visibility push(default) + +#if __cplusplus >= 202100L +# define __cpp_lib_constexpr_typeinfo 202106L +#endif + +extern "C++" { + +namespace __cxxabiv1 +{ + class __class_type_info; +} // namespace __cxxabiv1 + +// Determine whether typeinfo names for the same type are merged (in which +// case comparison can just compare pointers) or not (in which case strings +// must be compared), and whether comparison is to be implemented inline or +// not. We used to do inline pointer comparison by default if weak symbols +// are available, but even with weak symbols sometimes names are not merged +// when objects are loaded with RTLD_LOCAL, so now we always use strcmp by +// default. For ABI compatibility, we do the strcmp inline if weak symbols +// are available, and out-of-line if not. Out-of-line pointer comparison +// is used where the object files are to be portable to multiple systems, +// some of which may not be able to use pointer comparison, but the +// particular system for which libstdc++ is being built can use pointer +// comparison; in particular for most ARM EABI systems, where the ABI +// specifies out-of-line comparison. The compiler's target configuration +// can override the defaults by defining __GXX_TYPEINFO_EQUALITY_INLINE to +// 1 or 0 to indicate whether or not comparison is inline, and +// __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to indicate whether or not pointer +// comparison can be used. + +#ifndef __GXX_MERGED_TYPEINFO_NAMES +// By default, typeinfo names are not merged. +#define __GXX_MERGED_TYPEINFO_NAMES 0 +#endif + +// By default follow the old inline rules to avoid ABI changes. +#ifndef __GXX_TYPEINFO_EQUALITY_INLINE + #if !__GXX_WEAK__ + #define __GXX_TYPEINFO_EQUALITY_INLINE 0 + #else + #define __GXX_TYPEINFO_EQUALITY_INLINE 1 + #endif +#endif + +namespace std +{ + /** + * @brief Part of RTTI. + * + * The @c type_info class describes type information generated by + * an implementation. + */ + class type_info + { + public: + /** Destructor first. Being the first non-inline virtual function, this + * controls in which translation unit the vtable is emitted. The + * compiler makes use of that information to know where to emit + * the runtime-mandated type_info structures in the new-abi. */ + virtual ~type_info(); + + /** Returns an @e implementation-defined byte string; this is not + * portable between compilers! */ + const char* name() const _GLIBCXX_NOEXCEPT + { return __name[0] == '*' ? __name + 1 : __name; } + + /** Returns true if `*this` precedes `__arg` in the implementation's + * collation order. */ + bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT; + + _GLIBCXX23_CONSTEXPR + bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT; + +#if __cpp_impl_three_way_comparison < 201907L + bool operator!=(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { return !operator==(__arg); } +#endif + +#if __cplusplus >= 201103L + size_t hash_code() const noexcept + { +# if !__GXX_MERGED_TYPEINFO_NAMES + return _Hash_bytes(name(), __builtin_strlen(name()), + static_cast(0xc70f6907UL)); +# else + return reinterpret_cast(__name); +# endif + } +#endif // C++11 + + // Return true if this is a pointer type of some kind + virtual bool __is_pointer_p() const; + + // Return true if this is a function type + virtual bool __is_function_p() const; + + // Try and catch a thrown type. Store an adjusted pointer to the + // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then + // THR_OBJ points to the thrown object. If THR_TYPE is a pointer + // type, then THR_OBJ is the pointer itself. OUTER indicates the + // number of outer pointers, and whether they were const + // qualified. + virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; + + // Internally used during catch matching + virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, + void **__obj_ptr) const; + + protected: + const char *__name; + + explicit type_info(const char *__n): __name(__n) { } + + private: + // type_info objects cannot be copied. +#if __cplusplus >= 201103L + type_info& operator=(const type_info&) = delete; + type_info(const type_info&) = delete; +#else + type_info& operator=(const type_info&); + type_info(const type_info&); +#endif + +#if ! __GXX_TYPEINFO_EQUALITY_INLINE + bool __equal(const type_info&) const _GLIBCXX_NOEXCEPT; +#endif + }; + +#if __GXX_TYPEINFO_EQUALITY_INLINE + inline bool + type_info::before(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { +#if !__GXX_MERGED_TYPEINFO_NAMES + // Even with the new abi, on systems that support dlopen + // we can run into cases where type_info names aren't merged, + // so we still need to do string comparison. + if (__name[0] != '*' || __arg.__name[0] != '*') + return __builtin_strcmp (__name, __arg.__name) < 0; +#else + // On some targets we can rely on type_info's NTBS being unique, + // and therefore address comparisons are sufficient. +#endif + + // In old abi, or when weak symbols are not supported, there can + // be multiple instances of a type_info object for one + // type. Uniqueness must use the __name value, not object address. + return __name < __arg.__name; + } +#endif + +#if __GXX_TYPEINFO_EQUALITY_INLINE || __cplusplus > 202002L + _GLIBCXX23_CONSTEXPR inline bool + type_info::operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { + if (std::__is_constant_evaluated()) + return this == &__arg; + + if (__name == __arg.__name) + return true; + +#if !__GXX_TYPEINFO_EQUALITY_INLINE + // ABI requires comparisons to be non-inline. + return __equal(__arg); +#elif !__GXX_MERGED_TYPEINFO_NAMES + // Need to do string comparison. + return __name[0] != '*' && __builtin_strcmp (__name, __arg.name()) == 0; +#else + return false; +#endif + } +# endif + + + /** + * @brief Thrown during incorrect typecasting. + * @ingroup exceptions + * + * If you attempt an invalid @c dynamic_cast expression, an instance of + * this class (or something derived from this class) is thrown. */ + class bad_cast : public exception + { + public: + bad_cast() _GLIBCXX_USE_NOEXCEPT { } + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_cast() _GLIBCXX_USE_NOEXCEPT; + + // See comment in eh_exception.cc. + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; + }; + + /** + * @brief Thrown when a NULL pointer in a @c typeid expression is used. + * @ingroup exceptions + */ + class bad_typeid : public exception + { + public: + bad_typeid () _GLIBCXX_USE_NOEXCEPT { } + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_typeid() _GLIBCXX_USE_NOEXCEPT; + + // See comment in eh_exception.cc. + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; + }; +} // namespace std + +} // extern "C++" + +#pragma GCC visibility pop + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo.blob new file mode 100644 index 0000000000000000000000000000000000000000..c9f2eaaaa4cdfd6ce4d8df11fadac416000f8900 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@typeinfo.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map new file mode 100644 index 0000000000000000000000000000000000000000..bb14ffa7f2e55ab6ee47ddbe88357b454b8763d1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map @@ -0,0 +1,109 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/unordered_map + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UNORDERED_MAP +#define _GLIBCXX_UNORDERED_MAP 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include // equal_to, _Identity, _Select1st +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template, + typename _Pred = std::equal_to<_Key>> + using unordered_map + = std::unordered_map<_Key, _Tp, _Hash, _Pred, + polymorphic_allocator>>; + template, + typename _Pred = std::equal_to<_Key>> + using unordered_multimap + = std::unordered_multimap<_Key, _Tp, _Hash, _Pred, + polymorphic_allocator>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline typename unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>::size_type + erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { + const _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } + + template + inline typename unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>:: + size_type + erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { + const _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif // C++11 + +#endif // _GLIBCXX_UNORDERED_MAP diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map.blob new file mode 100644 index 0000000000000000000000000000000000000000..aa4e4bc170ff4971d7cd64ddff812e658fced9f9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_map.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set new file mode 100644 index 0000000000000000000000000000000000000000..777e3b8111628519bd5afd186e8d9508b00f889a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set @@ -0,0 +1,108 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/unordered_set + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UNORDERED_SET +#define _GLIBCXX_UNORDERED_SET 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include // equal_to, _Identity, _Select1st +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template, + typename _Pred = std::equal_to<_Key>> + using unordered_set + = std::unordered_set<_Key, _Hash, _Pred, + polymorphic_allocator<_Key>>; + template, + typename _Pred = std::equal_to<_Key>> + using unordered_multiset + = std::unordered_multiset<_Key, _Hash, _Pred, + polymorphic_allocator<_Key>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline typename unordered_set<_Key, _Hash, _CPred, _Alloc>::size_type + erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { + const _GLIBCXX_STD_C::unordered_set<_Key, _Hash, _CPred, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } + + template + inline typename unordered_multiset<_Key, _Hash, _CPred, _Alloc>::size_type + erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { + const _GLIBCXX_STD_C::unordered_multiset<_Key, _Hash, _CPred, _Alloc>& + __ucont = __cont; + return __detail::__erase_nodes_if(__cont, __ucont, __pred); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif // C++11 + +#endif // _GLIBCXX_UNORDERED_SET diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set.blob new file mode 100644 index 0000000000000000000000000000000000000000..692637674a666be40ff0a1dbd38c925f6ee8f55b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@unordered_set.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility new file mode 100644 index 0000000000000000000000000000000000000000..ad5faa50f57306af581e1466d35cd03928704579 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility @@ -0,0 +1,225 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/utility + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_UTILITY +#define _GLIBCXX_UTILITY 1 + +#pragma GCC system_header + +/** + * @defgroup utilities Utilities + * + * Basic function and class templates used with the rest of the library. + * Includes pair, swap, forward/move helpers, declval, integer_sequence. + */ + +#include +#include +#include + +#if __cplusplus >= 201103L + +#include +#include +#include +#include + +#if __cplusplus >= 202002L +#include // __is_standard_integer, __int_traits +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201402L +#define __cpp_lib_exchange_function 201304L + + /// Assign @p __new_val to @p __obj and return its previous value. + template + _GLIBCXX20_CONSTEXPR + inline _Tp + exchange(_Tp& __obj, _Up&& __new_val) + noexcept(__and_, + is_nothrow_assignable<_Tp&, _Up>>::value) + { return std::__exchange(__obj, std::forward<_Up>(__new_val)); } + +#if __cplusplus >= 201703L + +#define __cpp_lib_as_const 201510L + template + [[nodiscard]] + constexpr add_const_t<_Tp>& + as_const(_Tp& __t) noexcept + { return __t; } + + template + void as_const(const _Tp&&) = delete; + +#if __cplusplus > 201703L +#define __cpp_lib_integer_comparison_functions 202002L + + template + constexpr bool + cmp_equal(_Tp __t, _Up __u) noexcept + { + static_assert(__is_standard_integer<_Tp>::value); + static_assert(__is_standard_integer<_Up>::value); + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) + return __t == __u; + else if constexpr (is_signed_v<_Tp>) + return __t >= 0 && make_unsigned_t<_Tp>(__t) == __u; + else + return __u >= 0 && __t == make_unsigned_t<_Up>(__u); + } + + template + constexpr bool + cmp_not_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_equal(__t, __u); } + + template + constexpr bool + cmp_less(_Tp __t, _Up __u) noexcept + { + static_assert(__is_standard_integer<_Tp>::value); + static_assert(__is_standard_integer<_Up>::value); + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) + return __t < __u; + else if constexpr (is_signed_v<_Tp>) + return __t < 0 || make_unsigned_t<_Tp>(__t) < __u; + else + return __u >= 0 && __t < make_unsigned_t<_Up>(__u); + } + + template + constexpr bool + cmp_greater(_Tp __t, _Up __u) noexcept + { return std::cmp_less(__u, __t); } + + template + constexpr bool + cmp_less_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_less(__u, __t); } + + template + constexpr bool + cmp_greater_equal(_Tp __t, _Up __u) noexcept + { return !std::cmp_less(__t, __u); } + + template + constexpr bool + in_range(_Tp __t) noexcept + { + static_assert(__is_standard_integer<_Up>::value); + static_assert(__is_standard_integer<_Tp>::value); + using __gnu_cxx::__int_traits; + + if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) + return __int_traits<_Up>::__min <= __t + && __t <= __int_traits<_Up>::__max; + else if constexpr (is_signed_v<_Tp>) + return __t >= 0 + && make_unsigned_t<_Tp>(__t) <= __int_traits<_Up>::__max; + else + return __t <= make_unsigned_t<_Up>(__int_traits<_Up>::__max); + } + +#if __cplusplus > 202002L +#define __cpp_lib_to_underlying 202102L + /// Convert an object of enumeration type to its underlying type. + template + [[nodiscard]] + constexpr underlying_type_t<_Tp> + to_underlying(_Tp __value) noexcept + { return static_cast>(__value); } + +#define __cpp_lib_unreachable 202202L + /// Informs the compiler that program control flow never reaches this point. + /** + * Evaluating a call to this function results in undefined behaviour. + * This can be used as an assertion informing the compiler that certain + * conditions are impossible, for when the compiler is unable to determine + * that by itself. + * + * For example, it can be used to prevent warnings about reaching the + * end of a non-void function without returning. + * + * @since C++23 + */ + [[noreturn,__gnu__::__always_inline__]] + inline void + unreachable() + { +#ifdef _GLIBCXX_DEBUG + std::__glibcxx_assert_fail(nullptr, 0, "std::unreachable()", nullptr); +#elif defined _GLIBCXX_ASSERTIONS + __builtin_trap(); +#else + __builtin_unreachable(); +#endif + } +#endif // C++23 +#endif // C++20 +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif + +#endif /* _GLIBCXX_UTILITY */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility.blob new file mode 100644 index 0000000000000000000000000000000000000000..4eb7240822b40bc76043e5cccf006069380a01d3 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@utility.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray new file mode 100644 index 0000000000000000000000000000000000000000..87fec2b6df358c93cb1709befe899aaf6caaeca4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray @@ -0,0 +1,1267 @@ +// The template and inlines for the -*- C++ -*- valarray class. + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/valarray + * This is a Standard C++ Library header. + */ + +// Written by Gabriel Dos Reis + +#ifndef _GLIBCXX_VALARRAY +#define _GLIBCXX_VALARRAY 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + class _Expr; + + template + class _ValArray; + +namespace __detail +{ + template class _Meta, class _Dom> + struct _UnClos; + + template class _Meta1, + template class _Meta2, + class _Dom1, class _Dom2> + class _BinClos; + + template class _Meta, class _Dom> + class _SClos; + + template class _Meta, class _Dom> + class _GClos; + + template class _Meta, class _Dom> + class _IClos; + + template class _Meta, class _Dom> + class _ValFunClos; + + template class _Meta, class _Dom> + class _RefFunClos; +} // namespace __detail + + using __detail::_UnClos; + using __detail::_BinClos; + using __detail::_SClos; + using __detail::_GClos; + using __detail::_IClos; + using __detail::_ValFunClos; + using __detail::_RefFunClos; + + template class valarray; // An array of type _Tp + class slice; // BLAS-like slice out of an array + template class slice_array; + class gslice; // generalized slice out of an array + template class gslice_array; + template class mask_array; // masked array + template class indirect_array; // indirected array + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup numeric_arrays Numeric Arrays + * @ingroup numerics + * + * Classes and functions for representing and manipulating arrays of elements. + * @{ + */ + + /** + * @brief Smart array designed to support numeric processing. + * + * A valarray is an array that provides constraints intended to allow for + * effective optimization of numeric array processing by reducing the + * aliasing that can result from pointer representations. It represents a + * one-dimensional array from which different multidimensional subsets can + * be accessed and modified. + * + * @tparam _Tp Type of object in the array. + */ + template + class valarray + { + template + struct _UnaryOp + { + typedef typename __fun<_Op, _Tp>::result_type __rt; + typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt; + }; + public: + typedef _Tp value_type; + + // _lib.valarray.cons_ construct/destroy: + /// Construct an empty array. + valarray() _GLIBCXX_NOTHROW; + + /// Construct an array with @a n elements. + explicit valarray(size_t); + + /// Construct an array with @a n elements initialized to @a t. + valarray(const _Tp&, size_t); + + /// Construct an array initialized to the first @a n elements of @a t. + valarray(const _Tp* __restrict__, size_t); + + /// Copy constructor. + valarray(const valarray&); + +#if __cplusplus >= 201103L + /// Move constructor. + valarray(valarray&&) noexcept; +#endif + + /// Construct an array with the same size and values in @a sa. + valarray(const slice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ga. + valarray(const gslice_array<_Tp>&); + + /// Construct an array with the same size and values in @a ma. + valarray(const mask_array<_Tp>&); + + /// Construct an array with the same size and values in @a ia. + valarray(const indirect_array<_Tp>&); + +#if __cplusplus >= 201103L + /// Construct an array with an initializer_list of values. + valarray(initializer_list<_Tp>); +#endif + + template + valarray(const _Expr<_Dom, _Tp>& __e); + + ~valarray() _GLIBCXX_NOEXCEPT; + + // _lib.valarray.assign_ assignment: + /** + * @brief Assign elements to an array. + * + * Assign elements of array to values in @a v. + * + * @param __v Valarray to get values from. + */ + valarray<_Tp>& operator=(const valarray<_Tp>& __v); + +#if __cplusplus >= 201103L + /** + * @brief Move assign elements to an array. + * + * Move assign elements of array to values in @a v. + * + * @param __v Valarray to get values from. + */ + valarray<_Tp>& operator=(valarray<_Tp>&& __v) noexcept; +#endif + + /** + * @brief Assign elements to a value. + * + * Assign all elements of array to @a t. + * + * @param __t Value for elements. + */ + valarray<_Tp>& operator=(const _Tp& __t); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a sa. Results are undefined + * if @a sa does not have the same size as this array. + * + * @param __sa Array slice to get values from. + */ + valarray<_Tp>& operator=(const slice_array<_Tp>& __sa); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ga. Results are undefined + * if @a ga does not have the same size as this array. + * + * @param __ga Array slice to get values from. + */ + valarray<_Tp>& operator=(const gslice_array<_Tp>& __ga); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ma. Results are undefined + * if @a ma does not have the same size as this array. + * + * @param __ma Array slice to get values from. + */ + valarray<_Tp>& operator=(const mask_array<_Tp>& __ma); + + /** + * @brief Assign elements to an array subset. + * + * Assign elements of array to values in @a ia. Results are undefined + * if @a ia does not have the same size as this array. + * + * @param __ia Array slice to get values from. + */ + valarray<_Tp>& operator=(const indirect_array<_Tp>& __ia); + +#if __cplusplus >= 201103L + /** + * @brief Assign elements to an initializer_list. + * + * Assign elements of array to values in @a __l. Results are undefined + * if @a __l does not have the same size as this array. + * + * @param __l initializer_list to get values from. + */ + valarray& operator=(initializer_list<_Tp> __l); +#endif + + template valarray<_Tp>& + operator= (const _Expr<_Dom, _Tp>&); + + // _lib.valarray.access_ element access: + /** + * Return a reference to the i'th array element. + * + * @param __i Index of element to return. + * @return Reference to the i'th element. + */ + _Tp& operator[](size_t __i) _GLIBCXX_NOTHROW; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 389. Const overload of valarray::operator[] returns by value. + const _Tp& operator[](size_t) const _GLIBCXX_NOTHROW; + + // _lib.valarray.sub_ subset operations: + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the slice argument. The new valarray has the same size + * as the input slice. @see slice. + * + * @param __s The source slice. + * @return New valarray containing elements in @a __s. + */ + _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice __s) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the slice argument. The new valarray has the same size + * as the input slice. @see slice. + * + * @param __s The source slice. + * @return New valarray containing elements in @a __s. + */ + slice_array<_Tp> operator[](slice __s); + + /** + * @brief Return an array subset. + * + * Returns a slice_array referencing the elements of the array + * indicated by the slice argument. @see gslice. + * + * @param __s The source slice. + * @return Slice_array referencing elements indicated by @a __s. + */ + _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice& __s) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the gslice argument. The new valarray has + * the same size as the input gslice. @see gslice. + * + * @param __s The source gslice. + * @return New valarray containing elements in @a __s. + */ + gslice_array<_Tp> operator[](const gslice& __s); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements should be copied into + * the new valarray. Each element of the array is added to the return + * valarray if the corresponding element of the argument is true. + * + * @param __m The valarray bitmask. + * @return New valarray containing elements indicated by @a __m. + */ + valarray<_Tp> operator[](const valarray& __m) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns a new mask_array referencing the elements of the array + * indicated by the argument. The input is a valarray of bool which + * represents a bitmask indicating which elements are part of the + * subset. Elements of the array are part of the subset if the + * corresponding element of the argument is true. + * + * @param __m The valarray bitmask. + * @return New valarray containing elements indicated by @a __m. + */ + mask_array<_Tp> operator[](const valarray& __m); + + /** + * @brief Return an array subset. + * + * Returns a new valarray containing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to copy to + * the return valarray. + * + * @param __i The valarray element index list. + * @return New valarray containing elements in @a __s. + */ + _Expr<_IClos<_ValArray, _Tp>, _Tp> + operator[](const valarray& __i) const; + + /** + * @brief Return a reference to an array subset. + * + * Returns an indirect_array referencing the elements of the array + * indicated by the argument. The elements in the argument are + * interpreted as the indices of elements of this valarray to include + * in the subset. The returned indirect_array refers to these + * elements. + * + * @param __i The valarray element index list. + * @return Indirect_array referencing elements in @a __i. + */ + indirect_array<_Tp> operator[](const valarray& __i); + + // _lib.valarray.unary_ unary operators: + /// Return a new valarray by applying unary + to each element. + typename _UnaryOp<__unary_plus>::_Rt operator+() const; + + /// Return a new valarray by applying unary - to each element. + typename _UnaryOp<__negate>::_Rt operator-() const; + + /// Return a new valarray by applying unary ~ to each element. + typename _UnaryOp<__bitwise_not>::_Rt operator~() const; + + /// Return a new valarray by applying unary ! to each element. + typename _UnaryOp<__logical_not>::_Rt operator!() const; + + // _lib.valarray.cassign_ computed assignment: + /// Multiply each element of array by @a t. + valarray<_Tp>& operator*=(const _Tp&); + + /// Divide each element of array by @a t. + valarray<_Tp>& operator/=(const _Tp&); + + /// Set each element e of array to e % @a t. + valarray<_Tp>& operator%=(const _Tp&); + + /// Add @a t to each element of array. + valarray<_Tp>& operator+=(const _Tp&); + + /// Subtract @a t to each element of array. + valarray<_Tp>& operator-=(const _Tp&); + + /// Set each element e of array to e ^ @a t. + valarray<_Tp>& operator^=(const _Tp&); + + /// Set each element e of array to e & @a t. + valarray<_Tp>& operator&=(const _Tp&); + + /// Set each element e of array to e | @a t. + valarray<_Tp>& operator|=(const _Tp&); + + /// Left shift each element e of array by @a t bits. + valarray<_Tp>& operator<<=(const _Tp&); + + /// Right shift each element e of array by @a t bits. + valarray<_Tp>& operator>>=(const _Tp&); + + /// Multiply elements of array by corresponding elements of @a v. + valarray<_Tp>& operator*=(const valarray<_Tp>&); + + /// Divide elements of array by corresponding elements of @a v. + valarray<_Tp>& operator/=(const valarray<_Tp>&); + + /// Modulo elements of array by corresponding elements of @a v. + valarray<_Tp>& operator%=(const valarray<_Tp>&); + + /// Add corresponding elements of @a v to elements of array. + valarray<_Tp>& operator+=(const valarray<_Tp>&); + + /// Subtract corresponding elements of @a v from elements of array. + valarray<_Tp>& operator-=(const valarray<_Tp>&); + + /// Logical xor corresponding elements of @a v with elements of array. + valarray<_Tp>& operator^=(const valarray<_Tp>&); + + /// Logical or corresponding elements of @a v with elements of array. + valarray<_Tp>& operator|=(const valarray<_Tp>&); + + /// Logical and corresponding elements of @a v with elements of array. + valarray<_Tp>& operator&=(const valarray<_Tp>&); + + /// Left shift elements of array by corresponding elements of @a v. + valarray<_Tp>& operator<<=(const valarray<_Tp>&); + + /// Right shift elements of array by corresponding elements of @a v. + valarray<_Tp>& operator>>=(const valarray<_Tp>&); + + template + valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&); + template + valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&); + + // _lib.valarray.members_ member functions: +#if __cplusplus >= 201103L + /// Swap. + void swap(valarray<_Tp>& __v) noexcept; +#endif + + /// Return the number of elements in array. + size_t size() const; + + /** + * @brief Return the sum of all elements in the array. + * + * Accumulates the sum of all elements into a Tp using +=. The order + * of adding the elements is unspecified. + */ + _Tp sum() const; + + /// Return the minimum element using operator<(). + _Tp min() const; + + /// Return the maximum element using operator<(). + _Tp max() const; + + /** + * @brief Return a shifted array. + * + * A new valarray is constructed as a copy of this array with elements + * in shifted positions. For an element with index i, the new position + * is i - n. The new valarray has the same size as the current one. + * New elements without a value are set to 0. Elements whose new + * position is outside the bounds of the array are discarded. + * + * Positive arguments shift toward index 0, discarding elements [0, n). + * Negative arguments discard elements from the top of the array. + * + * @param __n Number of element positions to shift. + * @return New valarray with elements in shifted positions. + */ + valarray<_Tp> shift (int __n) const; + + /** + * @brief Return a rotated array. + * + * A new valarray is constructed as a copy of this array with elements + * in shifted positions. For an element with index i, the new position + * is (i - n) % size(). The new valarray has the same size as the + * current one. Elements that are shifted beyond the array bounds are + * shifted into the other end of the array. No elements are lost. + * + * Positive arguments shift toward index 0, wrapping around the top. + * Negative arguments shift towards the top, wrapping around to 0. + * + * @param __n Number of element positions to rotate. + * @return New valarray with elements in shifted positions. + */ + valarray<_Tp> cshift(int __n) const; + + /** + * @brief Apply a function to the array. + * + * Returns a new valarray with elements assigned to the result of + * applying __func to the corresponding element of this array. The new + * array has the same size as this one. + * + * @param __func Function of Tp returning Tp to apply. + * @return New valarray with transformed elements. + */ + _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp __func(_Tp)) const; + + /** + * @brief Apply a function to the array. + * + * Returns a new valarray with elements assigned to the result of + * applying __func to the corresponding element of this array. The new + * array has the same size as this one. + * + * @param __func Function of const Tp& returning Tp to apply. + * @return New valarray with transformed elements. + */ + _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp __func(const _Tp&)) const; + + /** + * @brief Resize array. + * + * Resize this array to @a size and set all elements to @a c. All + * references and iterators are invalidated. + * + * @param __size New array size. + * @param __c New value for all elements. + */ + void resize(size_t __size, _Tp __c = _Tp()); + + private: + size_t _M_size; + _Tp* __restrict__ _M_data; + + friend struct _Array<_Tp>; + }; + +#if __cpp_deduction_guides >= 201606 + template + valarray(const _Tp(&)[_Nm], size_t) -> valarray<_Tp>; +#endif + + template + inline const _Tp& + valarray<_Tp>::operator[](size_t __i) const _GLIBCXX_NOTHROW + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } + + template + inline _Tp& + valarray<_Tp>::operator[](size_t __i) _GLIBCXX_NOTHROW + { + __glibcxx_requires_subscript(__i); + return _M_data[__i]; + } + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + template + inline + valarray<_Tp>::valarray() _GLIBCXX_NOTHROW : _M_size(0), _M_data(0) {} + + template + inline + valarray<_Tp>::valarray(size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { std::__valarray_default_construct(_M_data, _M_data + __n); } + + template + inline + valarray<_Tp>::valarray(const _Tp& __t, size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { std::__valarray_fill_construct(_M_data, _M_data + __n, __t); } + + template + inline + valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n) + : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n)) + { + __glibcxx_assert(__p != 0 || __n == 0); + std::__valarray_copy_construct(__p, __p + __n, _M_data); + } + + template + inline + valarray<_Tp>::valarray(const valarray<_Tp>& __v) + : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) + { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size, + _M_data); } + +#if __cplusplus >= 201103L + template + inline + valarray<_Tp>::valarray(valarray<_Tp>&& __v) noexcept + : _M_size(__v._M_size), _M_data(__v._M_data) + { + __v._M_size = 0; + __v._M_data = 0; + } +#endif + + template + inline + valarray<_Tp>::valarray(const slice_array<_Tp>& __sa) + : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz)) + { + std::__valarray_copy_construct + (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); + } + + template + inline + valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga) + : _M_size(__ga._M_index.size()), + _M_data(__valarray_get_storage<_Tp>(_M_size)) + { + std::__valarray_copy_construct + (__ga._M_array, _Array(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); + } + + template + inline + valarray<_Tp>::valarray(const mask_array<_Tp>& __ma) + : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz)) + { + std::__valarray_copy_construct + (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); + } + + template + inline + valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia) + : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz)) + { + std::__valarray_copy_construct + (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); + } + +#if __cplusplus >= 201103L + template + inline + valarray<_Tp>::valarray(initializer_list<_Tp> __l) + : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size())) + { std::__valarray_copy_construct(__l.begin(), __l.end(), _M_data); } +#endif + + template template + inline + valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e) + : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) + { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); } + + template + inline + valarray<_Tp>::~valarray() _GLIBCXX_NOEXCEPT + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const valarray<_Tp>& __v) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 630. arrays of valarray. + if (_M_size == __v._M_size) + std::__valarray_copy(__v._M_data, _M_size, _M_data); + else + { + if (_M_data) + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + _M_size = __v._M_size; + _M_data = __valarray_get_storage<_Tp>(_M_size); + std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size, + _M_data); + } + return *this; + } + +#if __cplusplus >= 201103L + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(valarray<_Tp>&& __v) noexcept + { + if (_M_data) + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + _M_size = __v._M_size; + _M_data = __v._M_data; + __v._M_size = 0; + __v._M_data = 0; + return *this; + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(initializer_list<_Tp> __l) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 630. arrays of valarray. + if (_M_size == __l.size()) + std::__valarray_copy(__l.begin(), __l.size(), _M_data); + else + { + if (_M_data) + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + _M_size = __l.size(); + _M_data = __valarray_get_storage<_Tp>(_M_size); + std::__valarray_copy_construct(__l.begin(), __l.begin() + _M_size, + _M_data); + } + return *this; + } +#endif + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Tp& __t) + { + std::__valarray_fill(_M_data, _M_size, __t); + return *this; + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const slice_array<_Tp>& __sa) + { + __glibcxx_assert(_M_size == __sa._M_sz); + std::__valarray_copy(__sa._M_array, __sa._M_sz, + __sa._M_stride, _Array<_Tp>(_M_data)); + return *this; + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga) + { + __glibcxx_assert(_M_size == __ga._M_index.size()); + std::__valarray_copy(__ga._M_array, _Array(__ga._M_index), + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const mask_array<_Tp>& __ma) + { + __glibcxx_assert(_M_size == __ma._M_sz); + std::__valarray_copy(__ma._M_array, __ma._M_mask, + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia) + { + __glibcxx_assert(_M_size == __ia._M_sz); + std::__valarray_copy(__ia._M_array, __ia._M_index, + _Array<_Tp>(_M_data), _M_size); + return *this; + } + + template template + inline valarray<_Tp>& + valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 630. arrays of valarray. + if (_M_size == __e.size()) + std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + else + { + if (_M_data) + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + _M_size = __e.size(); + _M_data = __valarray_get_storage<_Tp>(_M_size); + std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); + } + return *this; + } + + template + inline _Expr<_SClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](slice __s) const + { + typedef _SClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s)); + } + + template + inline slice_array<_Tp> + valarray<_Tp>::operator[](slice __s) + { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); } + + template + inline _Expr<_GClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const gslice& __gs) const + { + typedef _GClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp> + (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index)); + } + + template + inline gslice_array<_Tp> + valarray<_Tp>::operator[](const gslice& __gs) + { + return gslice_array<_Tp> + (_Array<_Tp>(_M_data), __gs._M_index->_M_index); + } + + template + inline valarray<_Tp> + valarray<_Tp>::operator[](const valarray& __m) const + { + size_t __s = 0; + size_t __e = __m.size(); + for (size_t __i=0; __i<__e; ++__i) + if (__m[__i]) ++__s; + return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s, + _Array (__m))); + } + + template + inline mask_array<_Tp> + valarray<_Tp>::operator[](const valarray& __m) + { + size_t __s = 0; + size_t __e = __m.size(); + for (size_t __i=0; __i<__e; ++__i) + if (__m[__i]) ++__s; + return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array(__m)); + } + + template + inline _Expr<_IClos<_ValArray,_Tp>, _Tp> + valarray<_Tp>::operator[](const valarray& __i) const + { + typedef _IClos<_ValArray,_Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure(*this, __i)); + } + + template + inline indirect_array<_Tp> + valarray<_Tp>::operator[](const valarray& __i) + { + return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(), + _Array(__i)); + } + +#if __cplusplus >= 201103L + template + inline void + valarray<_Tp>::swap(valarray<_Tp>& __v) noexcept + { + std::swap(_M_size, __v._M_size); + std::swap(_M_data, __v._M_data); + } +#endif + + template + inline size_t + valarray<_Tp>::size() const + { return _M_size; } + + template + inline _Tp + valarray<_Tp>::sum() const + { + __glibcxx_assert(_M_size > 0); + return std::__valarray_sum(_M_data, _M_data + _M_size); + } + + template + inline valarray<_Tp> + valarray<_Tp>::shift(int __n) const + { + valarray<_Tp> __ret; + + if (_M_size == 0) + return __ret; + + _Tp* __restrict__ __tmp_M_data = + std::__valarray_get_storage<_Tp>(_M_size); + + if (__n == 0) + std::__valarray_copy_construct(_M_data, + _M_data + _M_size, __tmp_M_data); + else if (__n > 0) // shift left + { + if (size_t(__n) > _M_size) + __n = int(_M_size); + + std::__valarray_copy_construct(_M_data + __n, + _M_data + _M_size, __tmp_M_data); + std::__valarray_default_construct(__tmp_M_data + _M_size - __n, + __tmp_M_data + _M_size); + } + else // shift right + { + if (-size_t(__n) > _M_size) + __n = -int(_M_size); + + std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n, + __tmp_M_data - __n); + std::__valarray_default_construct(__tmp_M_data, + __tmp_M_data - __n); + } + + __ret._M_size = _M_size; + __ret._M_data = __tmp_M_data; + return __ret; + } + + template + inline valarray<_Tp> + valarray<_Tp>::cshift(int __n) const + { + valarray<_Tp> __ret; + + if (_M_size == 0) + return __ret; + + _Tp* __restrict__ __tmp_M_data = + std::__valarray_get_storage<_Tp>(_M_size); + + if (__n == 0) + std::__valarray_copy_construct(_M_data, + _M_data + _M_size, __tmp_M_data); + else if (__n > 0) // cshift left + { + if (size_t(__n) > _M_size) + __n = int(__n % _M_size); + + std::__valarray_copy_construct(_M_data, _M_data + __n, + __tmp_M_data + _M_size - __n); + std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size, + __tmp_M_data); + } + else // cshift right + { + if (-size_t(__n) > _M_size) + __n = -int(-size_t(__n) % _M_size); + + std::__valarray_copy_construct(_M_data + _M_size + __n, + _M_data + _M_size, __tmp_M_data); + std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n, + __tmp_M_data - __n); + } + + __ret._M_size = _M_size; + __ret._M_data = __tmp_M_data; + return __ret; + } + + template + inline void + valarray<_Tp>::resize(size_t __n, _Tp __c) + { + // This complication is so to make valarray > work + // even though it is not required by the standard. Nobody should + // be saying valarray > anyway. See the specs. + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + if (_M_size != __n) + { + std::__valarray_release_memory(_M_data); + _M_size = __n; + _M_data = __valarray_get_storage<_Tp>(__n); + } + std::__valarray_fill_construct(_M_data, _M_data + __n, __c); + } + + template + inline _Tp + valarray<_Tp>::min() const + { + __glibcxx_assert(_M_size > 0); + return *std::min_element(_M_data, _M_data + _M_size); + } + + template + inline _Tp + valarray<_Tp>::max() const + { + __glibcxx_assert(_M_size > 0); + return *std::max_element(_M_data, _M_data + _M_size); + } + + template + inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> + valarray<_Tp>::apply(_Tp __func(_Tp)) const + { + typedef _ValFunClos<_ValArray, _Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure(*this, __func)); + } + + template + inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> + valarray<_Tp>::apply(_Tp __func(const _Tp &)) const + { + typedef _RefFunClos<_ValArray, _Tp> _Closure; + return _Expr<_Closure, _Tp>(_Closure(*this, __func)); + } + +#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \ + template \ + inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \ + valarray<_Tp>::operator _Op() const \ + { \ + typedef _UnClos<_Name, _ValArray, _Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(*this)); \ + } + + _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus) + _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate) + _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not) + _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not) + +#undef _DEFINE_VALARRAY_UNARY_OPERATOR + +#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \ + template \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Tp &__t) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \ + return *this; \ + } \ + \ + template \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \ + { \ + __glibcxx_assert(_M_size == __v._M_size); \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \ + _Array<_Tp>(__v._M_data)); \ + return *this; \ + } + +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right) + +#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT + +#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \ + template template \ + inline valarray<_Tp>& \ + valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \ + { \ + _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \ + return *this; \ + } + +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left) +_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) + +#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT + + +#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ + template \ + inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ + { \ + __glibcxx_assert(__v.size() == __w.size()); \ + typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const valarray<_Tp>& __v, \ + const typename valarray<_Tp>::value_type& __t) \ + { \ + typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>, \ + typename __fun<_Name, _Tp>::result_type> \ + operator _Op(const typename valarray<_Tp>::value_type& __t, \ + const valarray<_Tp>& __v) \ + { \ + typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \ + typedef typename __fun<_Name, _Tp>::result_type _Rt; \ + return _Expr<_Closure, _Rt>(_Closure(__t, __v)); \ + } + +_DEFINE_BINARY_OPERATOR(+, __plus) +_DEFINE_BINARY_OPERATOR(-, __minus) +_DEFINE_BINARY_OPERATOR(*, __multiplies) +_DEFINE_BINARY_OPERATOR(/, __divides) +_DEFINE_BINARY_OPERATOR(%, __modulus) +_DEFINE_BINARY_OPERATOR(^, __bitwise_xor) +_DEFINE_BINARY_OPERATOR(&, __bitwise_and) +_DEFINE_BINARY_OPERATOR(|, __bitwise_or) +_DEFINE_BINARY_OPERATOR(<<, __shift_left) +_DEFINE_BINARY_OPERATOR(>>, __shift_right) +_DEFINE_BINARY_OPERATOR(&&, __logical_and) +_DEFINE_BINARY_OPERATOR(||, __logical_or) +_DEFINE_BINARY_OPERATOR(==, __equal_to) +_DEFINE_BINARY_OPERATOR(!=, __not_equal_to) +_DEFINE_BINARY_OPERATOR(<, __less) +_DEFINE_BINARY_OPERATOR(>, __greater) +_DEFINE_BINARY_OPERATOR(<=, __less_equal) +_DEFINE_BINARY_OPERATOR(>=, __greater_equal) + +#undef _DEFINE_BINARY_OPERATOR + +#if __cplusplus >= 201103L + /** + * @brief Return an iterator pointing to the first element of + * the valarray. + * @param __va valarray. + */ + template + [[__nodiscard__]] + inline _Tp* + begin(valarray<_Tp>& __va) noexcept + { return __va.size() ? std::__addressof(__va[0]) : nullptr; } + + /** + * @brief Return an iterator pointing to the first element of + * the const valarray. + * @param __va valarray. + */ + template + [[__nodiscard__]] + inline const _Tp* + begin(const valarray<_Tp>& __va) noexcept + { return __va.size() ? std::__addressof(__va[0]) : nullptr; } + + /** + * @brief Return an iterator pointing to one past the last element of + * the valarray. + * @param __va valarray. + */ + template + [[__nodiscard__]] + inline _Tp* + end(valarray<_Tp>& __va) noexcept + { + if (auto __n = __va.size()) + return std::__addressof(__va[0]) + __n; + else + return nullptr; + } + + /** + * @brief Return an iterator pointing to one past the last element of + * the const valarray. + * @param __va valarray. + */ + template + [[__nodiscard__]] + inline const _Tp* + end(const valarray<_Tp>& __va) noexcept + { + if (auto __n = __va.size()) + return std::__addressof(__va[0]) + __n; + else + return nullptr; + } +#endif // C++11 + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_VALARRAY */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray.blob new file mode 100644 index 0000000000000000000000000000000000000000..4923279df91de87687a148032f225ec261891f7a Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@valarray.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector new file mode 100644 index 0000000000000000000000000000000000000000..a880dfcac6f41c0d74095b14e3d3b0b6797f95f9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector @@ -0,0 +1,149 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/vector + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_VECTOR +#define _GLIBCXX_VECTOR 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include +#endif + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr { + template class polymorphic_allocator; + template + using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; + } // namespace pmr +# ifdef _GLIBCXX_DEBUG + namespace _GLIBCXX_STD_C::pmr { + template + using vector + = _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>; + } // namespace _GLIBCXX_STD_C::pmr +# endif +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + _GLIBCXX20_CONSTEXPR + inline typename vector<_Tp, _Alloc>::size_type + erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) + { + using namespace __gnu_cxx; + _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __ucont = __cont; + const auto __osz = __cont.size(); + const auto __end = __ucont.end(); + auto __removed = std::__remove_if(__ucont.begin(), __end, + __ops::__pred_iter(std::ref(__pred))); + if (__removed != __end) + { + __cont.erase(__niter_wrap(__cont.begin(), __removed), + __cont.end()); + return __osz - __cont.size(); + } + + return 0; + } + + template + _GLIBCXX20_CONSTEXPR + inline typename vector<_Tp, _Alloc>::size_type + erase(vector<_Tp, _Alloc>& __cont, const _Up& __value) + { + using namespace __gnu_cxx; + _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __ucont = __cont; + const auto __osz = __cont.size(); + const auto __end = __ucont.end(); + auto __removed = std::__remove_if(__ucont.begin(), __end, + __ops::__iter_equals_val(__value)); + if (__removed != __end) + { + __cont.erase(__niter_wrap(__cont.begin(), __removed), + __cont.end()); + return __osz - __cont.size(); + } + + return 0; + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_VECTOR */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector.blob new file mode 100644 index 0000000000000000000000000000000000000000..5f59d466fa457718d24a1f934640f49c0e1e5703 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@vector.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h new file mode 100644 index 0000000000000000000000000000000000000000..ee56ad2bc4d5760b93db2ebce5516e66091113d1 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h @@ -0,0 +1,40 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file atomic_word.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + + +// This is a memory order acquire fence. +#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) +// This is a memory order release fence. +#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE) + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5b21e44777359f3e9803d020ad52e92cde38637d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@atomic_word.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h new file mode 100644 index 0000000000000000000000000000000000000000..fb1f458c0f0dfd58d70c636981a62a3da7371c4d --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h @@ -0,0 +1,135 @@ +// Wrapper of C-language FILE struct -*- C++ -*- + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 27.8 File-based streams +// + +/** @file bits/basic_file.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _GLIBCXX_BASIC_FILE_STDIO_H +#define _GLIBCXX_BASIC_FILE_STDIO_H 1 + +#pragma GCC system_header + +#include +#include // for __c_lock and __c_file +#include // for swap +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Generic declaration. + template + class __basic_file; + + // Specialization. + template<> + class __basic_file + { + // Underlying data source/sink. + __c_file* _M_cfile; + + // True iff we opened _M_cfile, and thus must close it ourselves. + bool _M_cfile_created; + + public: + __basic_file(__c_lock* __lock = 0) throw (); + +#if __cplusplus >= 201103L + __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept + : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created) + { + __rv._M_cfile = nullptr; + __rv._M_cfile_created = false; + } + + __basic_file& operator=(const __basic_file&) = delete; + __basic_file& operator=(__basic_file&&) = delete; + + void + swap(__basic_file& __f) noexcept + { + std::swap(_M_cfile, __f._M_cfile); + std::swap(_M_cfile_created, __f._M_cfile_created); + } +#endif + + __basic_file* + open(const char* __name, ios_base::openmode __mode, int __prot = 0664); + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + __basic_file* + open(const wchar_t* __name, ios_base::openmode __mode); +#endif + + __basic_file* + sys_open(__c_file* __file, ios_base::openmode); + + __basic_file* + sys_open(int __fd, ios_base::openmode __mode) throw (); + + __basic_file* + close(); + + _GLIBCXX_PURE bool + is_open() const throw (); + + _GLIBCXX_PURE int + fd() throw (); + + _GLIBCXX_PURE __c_file* + file() throw (); + + ~__basic_file(); + + streamsize + xsputn(const char* __s, streamsize __n); + + streamsize + xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2); + + streamsize + xsgetn(char* __s, streamsize __n); + + streamoff + seekoff(streamoff __off, ios_base::seekdir __way) throw (); + + int + sync(); + + streamsize + showmanyc(); + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d2e27197d630f9733e63ce5c5fb6ff5a198f3199 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@basic_file.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..9cf5b807e5a832ea9d57c61b04094db7aa23963c --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h @@ -0,0 +1,64 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++allocator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _GLIBCXX_CXX_ALLOCATOR_H +#define _GLIBCXX_CXX_ALLOCATOR_H 1 + +#include + +#if __cplusplus >= 201103L +namespace std +{ + /** + * @brief An alias to the base class for std::allocator. + * + * Used to set the std::allocator base class to std::__new_allocator. + * + * @ingroup allocators + * @tparam _Tp Type of allocated object. + */ + template + using __allocator_base = __new_allocator<_Tp>; +} +#else +// Define __new_allocator as the base class to std::allocator. +# define __allocator_base __new_allocator +#endif + +#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR +# if defined(__SANITIZE_ADDRESS__) +# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 +# elif defined __has_feature +# if __has_feature(address_sanitizer) +# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 +# endif +# endif +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3b4b623f3a82ea9e8878e85b154f0745e8805d2c Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++allocator.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h new file mode 100644 index 0000000000000000000000000000000000000000..517274bf5f9d1444a149c3df06b76c4838213613 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h @@ -0,0 +1,2235 @@ +// Predefined symbols and macros -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++config.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{version} + */ + +#ifndef _GLIBCXX_CXX_CONFIG_H +#define _GLIBCXX_CXX_CONFIG_H 1 + +// The major release number for the GCC release the C++ library belongs to. +#define _GLIBCXX_RELEASE 12 + +// The datestamp of the C++ library in compressed ISO date format. +#define __GLIBCXX__ 20220819 + +// Macros for various attributes. +// _GLIBCXX_PURE +// _GLIBCXX_CONST +// _GLIBCXX_NORETURN +// _GLIBCXX_NOTHROW +// _GLIBCXX_VISIBILITY +#ifndef _GLIBCXX_PURE +# define _GLIBCXX_PURE __attribute__ ((__pure__)) +#endif + +#ifndef _GLIBCXX_CONST +# define _GLIBCXX_CONST __attribute__ ((__const__)) +#endif + +#ifndef _GLIBCXX_NORETURN +# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) +#endif + +// See below for C++ +#ifndef _GLIBCXX_NOTHROW +# ifndef __cplusplus +# define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) +# endif +#endif + +// Macros for visibility attributes. +// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY +// _GLIBCXX_VISIBILITY +# define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 + +#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY +# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) +#else +// If this is not supplied by the OS-specific or CPU-specific +// headers included below, it will be defined to an empty default. +# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) +#endif + +// Macros for deprecated attributes. +// _GLIBCXX_USE_DEPRECATED +// _GLIBCXX_DEPRECATED +// _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX11_DEPRECATED +// _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX14_DEPRECATED +// _GLIBCXX14_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX17_DEPRECATED +// _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX20_DEPRECATED( string-literal ) +// _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) +#ifndef _GLIBCXX_USE_DEPRECATED +# define _GLIBCXX_USE_DEPRECATED 1 +#endif + +#if defined(__DEPRECATED) +# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) +# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ + __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) +#else +# define _GLIBCXX_DEPRECATED +# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201103L) +# define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED +# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX11_DEPRECATED +# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201402L) +# define _GLIBCXX14_DEPRECATED _GLIBCXX_DEPRECATED +# define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX14_DEPRECATED +# define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201703L) +# define _GLIBCXX17_DEPRECATED [[__deprecated__]] +# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX17_DEPRECATED +# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 202002L) +# define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] +# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX20_DEPRECATED(MSG) +# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) +#endif + +// Macros for ABI tag attributes. +#ifndef _GLIBCXX_ABI_TAG_CXX11 +# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) +#endif + +// Macro to warn about unused results. +#if __cplusplus >= 201703L +# define _GLIBCXX_NODISCARD [[__nodiscard__]] +#else +# define _GLIBCXX_NODISCARD +#endif + + + +#if __cplusplus + +// Macro for constexpr, to support in mixed 03/0x mode. +#ifndef _GLIBCXX_CONSTEXPR +# if __cplusplus >= 201103L +# define _GLIBCXX_CONSTEXPR constexpr +# define _GLIBCXX_USE_CONSTEXPR constexpr +# else +# define _GLIBCXX_CONSTEXPR +# define _GLIBCXX_USE_CONSTEXPR const +# endif +#endif + +#ifndef _GLIBCXX14_CONSTEXPR +# if __cplusplus >= 201402L +# define _GLIBCXX14_CONSTEXPR constexpr +# else +# define _GLIBCXX14_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX17_CONSTEXPR +# if __cplusplus >= 201703L +# define _GLIBCXX17_CONSTEXPR constexpr +# else +# define _GLIBCXX17_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX20_CONSTEXPR +# if __cplusplus >= 202002L +# define _GLIBCXX20_CONSTEXPR constexpr +# else +# define _GLIBCXX20_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX23_CONSTEXPR +# if __cplusplus >= 202100L +# define _GLIBCXX23_CONSTEXPR constexpr +# else +# define _GLIBCXX23_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX17_INLINE +# if __cplusplus >= 201703L +# define _GLIBCXX17_INLINE inline +# else +# define _GLIBCXX17_INLINE +# endif +#endif + +// Macro for noexcept, to support in mixed 03/0x mode. +#ifndef _GLIBCXX_NOEXCEPT +# if __cplusplus >= 201103L +# define _GLIBCXX_NOEXCEPT noexcept +# define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) +# define _GLIBCXX_USE_NOEXCEPT noexcept +# define _GLIBCXX_THROW(_EXC) +# else +# define _GLIBCXX_NOEXCEPT +# define _GLIBCXX_NOEXCEPT_IF(...) +# define _GLIBCXX_USE_NOEXCEPT throw() +# define _GLIBCXX_THROW(_EXC) throw(_EXC) +# endif +#endif + +#ifndef _GLIBCXX_NOTHROW +# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT +#endif + +#ifndef _GLIBCXX_THROW_OR_ABORT +# if __cpp_exceptions +# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) +# else +# define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) +# endif +#endif + +#if __cpp_noexcept_function_type +#define _GLIBCXX_NOEXCEPT_PARM , bool _NE +#define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) +#else +#define _GLIBCXX_NOEXCEPT_PARM +#define _GLIBCXX_NOEXCEPT_QUAL +#endif + +// Macro for extern template, ie controlling template linkage via use +// of extern keyword on template declaration. As documented in the g++ +// manual, it inhibits all implicit instantiations and is used +// throughout the library to avoid multiple weak definitions for +// required types that are already explicitly instantiated in the +// library binary. This substantially reduces the binary size of +// resulting executables. +// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern +// templates only in basic_string, thus activating its debug-mode +// checks even at -O0. +# define _GLIBCXX_EXTERN_TEMPLATE 1 + +/* + Outline of libstdc++ namespaces. + + namespace std + { + namespace __debug { } + namespace __parallel { } + namespace __cxx1998 { } + + namespace __detail { + namespace __variant { } // C++17 + } + + namespace rel_ops { } + + namespace tr1 + { + namespace placeholders { } + namespace regex_constants { } + namespace __detail { } + } + + namespace tr2 { } + + namespace decimal { } + + namespace chrono { } // C++11 + namespace placeholders { } // C++11 + namespace regex_constants { } // C++11 + namespace this_thread { } // C++11 + inline namespace literals { // C++14 + inline namespace chrono_literals { } // C++14 + inline namespace complex_literals { } // C++14 + inline namespace string_literals { } // C++14 + inline namespace string_view_literals { } // C++17 + } + } + + namespace abi { } + + namespace __gnu_cxx + { + namespace __detail { } + } + + For full details see: + http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html +*/ +namespace std +{ + typedef __SIZE_TYPE__ size_t; + typedef __PTRDIFF_TYPE__ ptrdiff_t; + +#if __cplusplus >= 201103L + typedef decltype(nullptr) nullptr_t; +#endif + +#pragma GCC visibility push(default) + // This allows the library to terminate without including all of + // and without making the declaration of std::terminate visible to users. + extern "C++" __attribute__ ((__noreturn__, __always_inline__)) + inline void __terminate() _GLIBCXX_USE_NOEXCEPT + { + void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); + terminate(); + } +#pragma GCC visibility pop +} + +# define _GLIBCXX_USE_DUAL_ABI 1 + +#if ! _GLIBCXX_USE_DUAL_ABI +// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI +# undef _GLIBCXX_USE_CXX11_ABI +#endif + +#ifndef _GLIBCXX_USE_CXX11_ABI +# define _GLIBCXX_USE_CXX11_ABI 1 +#endif + +#if _GLIBCXX_USE_CXX11_ABI +namespace std +{ + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +} +namespace __gnu_cxx +{ + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +} +# define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: +# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { +# define _GLIBCXX_END_NAMESPACE_CXX11 } +# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 +#else +# define _GLIBCXX_NAMESPACE_CXX11 +# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 +# define _GLIBCXX_END_NAMESPACE_CXX11 +# define _GLIBCXX_DEFAULT_ABI_TAG +#endif + +// Defined if inline namespaces are used for versioning. +# define _GLIBCXX_INLINE_VERSION 0 + +// Inline namespace for symbol versioning. +#if _GLIBCXX_INLINE_VERSION +# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { +# define _GLIBCXX_END_NAMESPACE_VERSION } + +namespace std +{ +inline _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if __cplusplus >= 201402L + inline namespace literals { + inline namespace chrono_literals { } + inline namespace complex_literals { } + inline namespace string_literals { } +#if __cplusplus > 201402L + inline namespace string_view_literals { } +#endif // C++17 + } +#endif // C++14 +_GLIBCXX_END_NAMESPACE_VERSION +} + +namespace __gnu_cxx +{ +inline _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +} + +#else +# define _GLIBCXX_BEGIN_NAMESPACE_VERSION +# define _GLIBCXX_END_NAMESPACE_VERSION +#endif + +// Inline namespaces for special modes: debug, parallel. +#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Non-inline namespace for components replaced by alternates in active mode. + namespace __cxx1998 + { +# if _GLIBCXX_USE_CXX11_ABI + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +# endif + } + +_GLIBCXX_END_NAMESPACE_VERSION + + // Inline namespace for debug mode. +# ifdef _GLIBCXX_DEBUG + inline namespace __debug { } +# endif + + // Inline namespaces for parallel mode. +# ifdef _GLIBCXX_PARALLEL + inline namespace __parallel { } +# endif +} + +// Check for invalid usage and unsupported mixed-mode use. +# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) +# error illegal use of multiple inlined namespaces +# endif + +// Check for invalid use due to lack for weak symbols. +# if __NO_INLINE__ && !__GXX_WEAK__ +# warning currently using inlined namespace mode which may fail \ + without inlining due to lack of weak symbols +# endif +#endif + +// Macros for namespace scope. Either namespace std:: or the name +// of some nested namespace within it corresponding to the active mode. +// _GLIBCXX_STD_A +// _GLIBCXX_STD_C +// +// Macros for opening/closing conditional namespaces. +// _GLIBCXX_BEGIN_NAMESPACE_ALGO +// _GLIBCXX_END_NAMESPACE_ALGO +// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER +// _GLIBCXX_END_NAMESPACE_CONTAINER +#if defined(_GLIBCXX_DEBUG) +# define _GLIBCXX_STD_C __cxx1998 +# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ + namespace _GLIBCXX_STD_C { +# define _GLIBCXX_END_NAMESPACE_CONTAINER } +#else +# define _GLIBCXX_STD_C std +# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER +# define _GLIBCXX_END_NAMESPACE_CONTAINER +#endif + +#ifdef _GLIBCXX_PARALLEL +# define _GLIBCXX_STD_A __cxx1998 +# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ + namespace _GLIBCXX_STD_A { +# define _GLIBCXX_END_NAMESPACE_ALGO } +#else +# define _GLIBCXX_STD_A std +# define _GLIBCXX_BEGIN_NAMESPACE_ALGO +# define _GLIBCXX_END_NAMESPACE_ALGO +#endif + +// GLIBCXX_ABI Deprecated +// Define if compatibility should be provided for -mlong-double-64. +#undef _GLIBCXX_LONG_DOUBLE_COMPAT + +// Define if compatibility should be provided for alternative 128-bit long +// double formats. Not possible for Clang until __ibm128 is supported. +#ifndef __clang__ +#undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT +#endif + +// Inline namespaces for long double 128 modes. +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ +namespace std +{ + // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. + inline namespace __gnu_cxx_ieee128 { } + inline namespace __gnu_cxx11_ieee128 { } +} +# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { +# define _GLIBCXX_END_NAMESPACE_LDBL } +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } + +#else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ +namespace std +{ + inline namespace __gnu_cxx_ldbl128 { } +} +# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { +# define _GLIBCXX_END_NAMESPACE_LDBL } +#else +# define _GLIBCXX_NAMESPACE_LDBL +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL +# define _GLIBCXX_END_NAMESPACE_LDBL +#endif + +#if _GLIBCXX_USE_CXX11_ABI +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 +#else +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL +#endif + +#endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 + +namespace std +{ +#pragma GCC visibility push(default) + // Internal version of std::is_constant_evaluated(). + // This can be used without checking if the compiler supports the feature. + // The macro _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED can be used to check if + // the compiler support is present to make this function work as expected. + _GLIBCXX_CONSTEXPR inline bool + __is_constant_evaluated() _GLIBCXX_NOEXCEPT + { +#if __cpp_if_consteval >= 202106L +# define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1 + if consteval { return true; } else { return false; } +#elif __cplusplus >= 201103L && __has_builtin(__builtin_is_constant_evaluated) +# define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1 + return __builtin_is_constant_evaluated(); +#else + return false; +#endif + } +#pragma GCC visibility pop +} + +// Debug Mode implies checking assertions. +#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) +# define _GLIBCXX_ASSERTIONS 1 +#endif + +// Disable std::string explicit instantiation declarations in order to assert. +#ifdef _GLIBCXX_ASSERTIONS +# undef _GLIBCXX_EXTERN_TEMPLATE +# define _GLIBCXX_EXTERN_TEMPLATE -1 +#endif + + +#if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED +# define __glibcxx_constexpr_assert(cond) \ + if (std::__is_constant_evaluated() && !bool(cond)) \ + __builtin_unreachable() /* precondition violation detected! */ +#else +# define __glibcxx_constexpr_assert(unevaluated) +#endif + +#define _GLIBCXX_VERBOSE_ASSERT 1 + +// Assert. +#if defined(_GLIBCXX_ASSERTIONS) \ + || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) +# ifdef _GLIBCXX_VERBOSE_ASSERT +namespace std +{ +#pragma GCC visibility push(default) + // Avoid the use of assert, because we're trying to keep the + // include out of the mix. + extern "C++" _GLIBCXX_NORETURN + void + __glibcxx_assert_fail(const char* __file, int __line, + const char* __function, const char* __condition) + _GLIBCXX_NOEXCEPT; +#pragma GCC visibility pop +} +#define __glibcxx_assert_impl(_Condition) \ + if (__builtin_expect(!bool(_Condition), false)) \ + { \ + __glibcxx_constexpr_assert(false); \ + std::__glibcxx_assert_fail(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + #_Condition); \ + } +# else // ! VERBOSE_ASSERT +# define __glibcxx_assert_impl(_Condition) \ + if (__builtin_expect(!bool(_Condition), false)) \ + { \ + __glibcxx_constexpr_assert(false); \ + __builtin_abort(); \ + } +# endif +#endif + +#if defined(_GLIBCXX_ASSERTIONS) +# define __glibcxx_assert(cond) \ + do { __glibcxx_assert_impl(cond); } while (false) +#else +# define __glibcxx_assert(cond) \ + do { __glibcxx_constexpr_assert(cond); } while (false) +#endif + +// Macro indicating that TSAN is in use. +#if __SANITIZE_THREAD__ +# define _GLIBCXX_TSAN 1 +#elif defined __has_feature +# if __has_feature(thread_sanitizer) +# define _GLIBCXX_TSAN 1 +# endif +#endif + +// Macros for race detectors. +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain +// atomic (lock-free) synchronization to race detectors: +// the race detector will infer a happens-before arc from the former to the +// latter when they share the same argument pointer. +// +// The most frequent use case for these macros (and the only case in the +// current implementation of the library) is atomic reference counting: +// void _M_remove_reference() +// { +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); +// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) +// { +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); +// _M_destroy(__a); +// } +// } +// The annotations in this example tell the race detector that all memory +// accesses occurred when the refcount was positive do not race with +// memory accesses which occurred after the refcount became zero. +#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE +# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) +#endif +#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER +# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) +#endif + +// Macros for C linkage: define extern "C" linkage only when using C++. +# define _GLIBCXX_BEGIN_EXTERN_C extern "C" { +# define _GLIBCXX_END_EXTERN_C } + +# define _GLIBCXX_USE_ALLOCATOR_NEW 1 + +#ifdef __SIZEOF_INT128__ +#if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ +// If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined +// unless the compiler is in strict mode. If it's not defined and the strict +// macro is not defined, something is wrong. +#warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" +#endif +#endif + +#else // !__cplusplus +# define _GLIBCXX_BEGIN_EXTERN_C +# define _GLIBCXX_END_EXTERN_C +#endif + + +// First includes. + +// Pick up any OS-specific definitions. +#include + +// Pick up any CPU-specific definitions. +#include + +// If platform uses neither visibility nor psuedo-visibility, +// specify empty default for namespace annotation macros. +#ifndef _GLIBCXX_PSEUDO_VISIBILITY +# define _GLIBCXX_PSEUDO_VISIBILITY(V) +#endif + +// Certain function definitions that are meant to be overridable from +// user code are decorated with this macro. For some targets, this +// macro causes these definitions to be weak. +#ifndef _GLIBCXX_WEAK_DEFINITION +# define _GLIBCXX_WEAK_DEFINITION +#endif + +// By default, we assume that __GXX_WEAK__ also means that there is support +// for declaring functions as weak while not defining such functions. This +// allows for referring to functions provided by other libraries (e.g., +// libitm) without depending on them if the respective features are not used. +#ifndef _GLIBCXX_USE_WEAK_REF +# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ +#endif + +// Conditionally enable annotations for the Transactional Memory TS on C++11. +// Most of the following conditions are due to limitations in the current +// implementation. +#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ + && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ + && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ + && _GLIBCXX_USE_ALLOCATOR_NEW +#define _GLIBCXX_TXN_SAFE transaction_safe +#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic +#else +#define _GLIBCXX_TXN_SAFE +#define _GLIBCXX_TXN_SAFE_DYN +#endif + +#if __cplusplus > 201402L +// In C++17 mathematical special functions are in namespace std. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 +// For C++11 and C++14 they are in namespace std when requested. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#endif + +// The remainder of the prewritten config is automatic; all the +// user hooks are listed above. + +// Create a boolean flag to be used to determine if --fast-math is set. +#ifdef __FAST_MATH__ +# define _GLIBCXX_FAST_MATH 1 +#else +# define _GLIBCXX_FAST_MATH 0 +#endif + +// This marks string literals in header files to be extracted for eventual +// translation. It is primarily used for messages in thrown exceptions; see +// src/functexcept.cc. We use __N because the more traditional _N is used +// for something else under certain OSes (see BADNAMES). +#define __N(msgid) (msgid) + +// For example, is known to #define min and max as macros... +#undef min +#undef max + +// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally +// so they should be tested with #if not with #ifdef. +#if __cplusplus >= 201103L +# ifndef _GLIBCXX_USE_C99_MATH +# define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH +# endif +# ifndef _GLIBCXX_USE_C99_COMPLEX +# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX +# endif +# ifndef _GLIBCXX_USE_C99_STDIO +# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO +# endif +# ifndef _GLIBCXX_USE_C99_STDLIB +# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB +# endif +# ifndef _GLIBCXX_USE_C99_WCHAR +# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR +# endif +#else +# ifndef _GLIBCXX_USE_C99_MATH +# define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH +# endif +# ifndef _GLIBCXX_USE_C99_COMPLEX +# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX +# endif +# ifndef _GLIBCXX_USE_C99_STDIO +# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO +# endif +# ifndef _GLIBCXX_USE_C99_STDLIB +# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB +# endif +# ifndef _GLIBCXX_USE_C99_WCHAR +# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR +# endif +#endif + +// Unless explicitly specified, enable char8_t extensions only if the core +// language char8_t feature macro is defined. +#ifndef _GLIBCXX_USE_CHAR8_T +# ifdef __cpp_char8_t +# define _GLIBCXX_USE_CHAR8_T 1 +# endif +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +# define __cpp_lib_char8_t 201907L +#endif + +/* Define if __float128 is supported on this host. */ +#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) +/* For powerpc64 don't use __float128 when it's the same type as long double. */ +# if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) +# define _GLIBCXX_USE_FLOAT128 1 +# endif +#endif + +// Define if float has the IEEE binary32 format. +#if __FLT_MANT_DIG__ == 24 \ + && __FLT_MIN_EXP__ == -125 \ + && __FLT_MAX_EXP__ == 128 +# define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 +#endif + +// Define if double has the IEEE binary64 format. +#if __DBL_MANT_DIG__ == 53 \ + && __DBL_MIN_EXP__ == -1021 \ + && __DBL_MAX_EXP__ == 1024 +# define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 +#endif + +#ifdef __has_builtin +# ifdef __is_identifier +// Intel and older Clang require !__is_identifier for some built-ins: +# define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) +# else +# define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) +# endif +#endif + +#if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) +# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__is_aggregate) +# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__is_same) +# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__builtin_launder) +# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 +#endif + +#undef _GLIBCXX_HAS_BUILTIN + +// PSTL configuration + +#if __cplusplus >= 201703L +// This header is not installed for freestanding: +#if __has_include() +// Preserved here so we have some idea which version of upstream we've pulled in +// #define PSTL_VERSION 9000 + +// For now this defaults to being based on the presence of Thread Building Blocks +# ifndef _GLIBCXX_USE_TBB_PAR_BACKEND +# define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include() +# endif +// This section will need some rework when a new (default) backend type is added +# if _GLIBCXX_USE_TBB_PAR_BACKEND +# define _PSTL_PAR_BACKEND_TBB +# else +# define _PSTL_PAR_BACKEND_SERIAL +# endif + +# define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) +# define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) + +#include +#endif // __has_include +#endif // C++17 + +// End of prewritten config; the settings discovered at configure time follow. +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `acosf' function. */ +#define _GLIBCXX_HAVE_ACOSF 1 + +/* Define to 1 if you have the `acosl' function. */ +#define _GLIBCXX_HAVE_ACOSL 1 + +/* Define to 1 if you have the `aligned_alloc' function. */ +#define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 + +/* Define if arc4random is available in . */ +/* #undef _GLIBCXX_HAVE_ARC4RANDOM */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `asinf' function. */ +#define _GLIBCXX_HAVE_ASINF 1 + +/* Define to 1 if you have the `asinl' function. */ +#define _GLIBCXX_HAVE_ASINL 1 + +/* Define to 1 if the target assembler supports .symver directive. */ +#define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 + +/* Define to 1 if you have the `atan2f' function. */ +#define _GLIBCXX_HAVE_ATAN2F 1 + +/* Define to 1 if you have the `atan2l' function. */ +#define _GLIBCXX_HAVE_ATAN2L 1 + +/* Define to 1 if you have the `atanf' function. */ +#define _GLIBCXX_HAVE_ATANF 1 + +/* Define to 1 if you have the `atanl' function. */ +#define _GLIBCXX_HAVE_ATANL 1 + +/* Defined if shared_ptr reference counting should use atomic operations. */ +#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1 + +/* Define to 1 if you have the `at_quick_exit' function. */ +#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 + +/* Define to 1 if the target assembler supports thread-local storage. */ +/* #undef _GLIBCXX_HAVE_CC_TLS */ + +/* Define to 1 if you have the `ceilf' function. */ +#define _GLIBCXX_HAVE_CEILF 1 + +/* Define to 1 if you have the `ceill' function. */ +#define _GLIBCXX_HAVE_CEILL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_COMPLEX_H 1 + +/* Define to 1 if you have the `cosf' function. */ +#define _GLIBCXX_HAVE_COSF 1 + +/* Define to 1 if you have the `coshf' function. */ +#define _GLIBCXX_HAVE_COSHF 1 + +/* Define to 1 if you have the `coshl' function. */ +#define _GLIBCXX_HAVE_COSHL 1 + +/* Define to 1 if you have the `cosl' function. */ +#define _GLIBCXX_HAVE_COSL 1 + +/* Define to 1 if you have the declaration of `strnlen', and to 0 if you + don't. */ +#define _GLIBCXX_HAVE_DECL_STRNLEN 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_DIRENT_H 1 + +/* Define if dirfd is available in . */ +#define _GLIBCXX_HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_ENDIAN_H 1 + +/* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ +#define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_EXECINFO_H 1 + +/* Define to 1 if you have the `expf' function. */ +#define _GLIBCXX_HAVE_EXPF 1 + +/* Define to 1 if you have the `expl' function. */ +#define _GLIBCXX_HAVE_EXPL 1 + +/* Define to 1 if you have the `fabsf' function. */ +#define _GLIBCXX_HAVE_FABSF 1 + +/* Define to 1 if you have the `fabsl' function. */ +#define _GLIBCXX_HAVE_FABSL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FCNTL_H 1 + +/* Define if fdopendir is available in . */ +#define _GLIBCXX_HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FENV_H 1 + +/* Define to 1 if you have the `finite' function. */ +#define _GLIBCXX_HAVE_FINITE 1 + +/* Define to 1 if you have the `finitef' function. */ +#define _GLIBCXX_HAVE_FINITEF 1 + +/* Define to 1 if you have the `finitel' function. */ +#define _GLIBCXX_HAVE_FINITEL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FLOAT_H 1 + +/* Define to 1 if you have the `floorf' function. */ +#define _GLIBCXX_HAVE_FLOORF 1 + +/* Define to 1 if you have the `floorl' function. */ +#define _GLIBCXX_HAVE_FLOORL 1 + +/* Define to 1 if you have the `fmodf' function. */ +#define _GLIBCXX_HAVE_FMODF 1 + +/* Define to 1 if you have the `fmodl' function. */ +#define _GLIBCXX_HAVE_FMODL 1 + +/* Define to 1 if you have the `fpclass' function. */ +/* #undef _GLIBCXX_HAVE_FPCLASS */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_FP_H */ + +/* Define to 1 if you have the `frexpf' function. */ +#define _GLIBCXX_HAVE_FREXPF 1 + +/* Define to 1 if you have the `frexpl' function. */ +#define _GLIBCXX_HAVE_FREXPL 1 + +/* Define if getentropy is available in . */ +#define _GLIBCXX_HAVE_GETENTROPY 1 + +/* Define if _Unwind_GetIPInfo is available. */ +#define _GLIBCXX_HAVE_GETIPINFO 1 + +/* Define if gets is available in before C++14. */ +#define _GLIBCXX_HAVE_GETS 1 + +/* Define to 1 if you have the `hypot' function. */ +#define _GLIBCXX_HAVE_HYPOT 1 + +/* Define to 1 if you have the `hypotf' function. */ +#define _GLIBCXX_HAVE_HYPOTF 1 + +/* Define to 1 if you have the `hypotl' function. */ +#define _GLIBCXX_HAVE_HYPOTL 1 + +/* Define if you have the iconv() function. */ +#define _GLIBCXX_HAVE_ICONV 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_IEEEFP_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isinf' function. */ +/* #undef _GLIBCXX_HAVE_ISINF */ + +/* Define to 1 if you have the `isinff' function. */ +#define _GLIBCXX_HAVE_ISINFF 1 + +/* Define to 1 if you have the `isinfl' function. */ +#define _GLIBCXX_HAVE_ISINFL 1 + +/* Define to 1 if you have the `isnan' function. */ +/* #undef _GLIBCXX_HAVE_ISNAN */ + +/* Define to 1 if you have the `isnanf' function. */ +#define _GLIBCXX_HAVE_ISNANF 1 + +/* Define to 1 if you have the `isnanl' function. */ +#define _GLIBCXX_HAVE_ISNANL 1 + +/* Defined if iswblank exists. */ +#define _GLIBCXX_HAVE_ISWBLANK 1 + +/* Define if LC_MESSAGES is available in . */ +#define _GLIBCXX_HAVE_LC_MESSAGES 1 + +/* Define to 1 if you have the `ldexpf' function. */ +#define _GLIBCXX_HAVE_LDEXPF 1 + +/* Define to 1 if you have the `ldexpl' function. */ +#define _GLIBCXX_HAVE_LDEXPL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LIBINTL_H 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_AS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_DATA 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_FSIZE 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_RSS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_VMEM 0 + +/* Define if link is available in . */ +#define _GLIBCXX_HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LINK_H 1 + +/* Define if futex syscall is available. */ +#define _GLIBCXX_HAVE_LINUX_FUTEX 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LINUX_RANDOM_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LINUX_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `log10f' function. */ +#define _GLIBCXX_HAVE_LOG10F 1 + +/* Define to 1 if you have the `log10l' function. */ +#define _GLIBCXX_HAVE_LOG10L 1 + +/* Define to 1 if you have the `logf' function. */ +#define _GLIBCXX_HAVE_LOGF 1 + +/* Define to 1 if you have the `logl' function. */ +#define _GLIBCXX_HAVE_LOGL 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ + +/* Define if mbstate_t exists in wchar.h. */ +#define _GLIBCXX_HAVE_MBSTATE_T 1 + +/* Define to 1 if you have the `memalign' function. */ +#define _GLIBCXX_HAVE_MEMALIGN 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `modf' function. */ +#define _GLIBCXX_HAVE_MODF 1 + +/* Define to 1 if you have the `modff' function. */ +#define _GLIBCXX_HAVE_MODFF 1 + +/* Define to 1 if you have the `modfl' function. */ +#define _GLIBCXX_HAVE_MODFL 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_NAN_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETINET_TCP_H 1 + +/* Define if defines obsolete isinf function. */ +/* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ + +/* Define if defines obsolete isnan function. */ +/* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ + +/* Define if openat is available in . */ +#define _GLIBCXX_HAVE_OPENAT 1 + +/* Define if poll is available in . */ +#define _GLIBCXX_HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_memalign' function. */ +#define _GLIBCXX_HAVE_POSIX_MEMALIGN 1 + +/* Define to 1 if POSIX Semaphores with sem_timedwait are available in + . */ +#define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 + +/* Define to 1 if you have the `powf' function. */ +#define _GLIBCXX_HAVE_POWF 1 + +/* Define to 1 if you have the `powl' function. */ +#define _GLIBCXX_HAVE_POWL 1 + +/* Define to 1 if you have the `qfpclass' function. */ +/* #undef _GLIBCXX_HAVE_QFPCLASS */ + +/* Define to 1 if you have the `quick_exit' function. */ +#define _GLIBCXX_HAVE_QUICK_EXIT 1 + +/* Define if readlink is available in . */ +#define _GLIBCXX_HAVE_READLINK 1 + +/* Define to 1 if you have the `secure_getenv' function. */ +#define _GLIBCXX_HAVE_SECURE_GETENV 1 + +/* Define to 1 if you have the `setenv' function. */ +#define _GLIBCXX_HAVE_SETENV 1 + +/* Define to 1 if you have the `sincos' function. */ +#define _GLIBCXX_HAVE_SINCOS 1 + +/* Define to 1 if you have the `sincosf' function. */ +#define _GLIBCXX_HAVE_SINCOSF 1 + +/* Define to 1 if you have the `sincosl' function. */ +#define _GLIBCXX_HAVE_SINCOSL 1 + +/* Define to 1 if you have the `sinf' function. */ +#define _GLIBCXX_HAVE_SINF 1 + +/* Define to 1 if you have the `sinhf' function. */ +#define _GLIBCXX_HAVE_SINHF 1 + +/* Define to 1 if you have the `sinhl' function. */ +#define _GLIBCXX_HAVE_SINHL 1 + +/* Define to 1 if you have the `sinl' function. */ +#define _GLIBCXX_HAVE_SINL 1 + +/* Defined if sleep exists. */ +/* #undef _GLIBCXX_HAVE_SLEEP */ + +/* Define to 1 if you have the `sockatmark' function. */ +#define _GLIBCXX_HAVE_SOCKATMARK 1 + +/* Define to 1 if you have the `sqrtf' function. */ +#define _GLIBCXX_HAVE_SQRTF 1 + +/* Define to 1 if you have the `sqrtl' function. */ +#define _GLIBCXX_HAVE_SQRTL 1 + +/* Define if the header is supported. */ +/* #undef _GLIBCXX_HAVE_STACKTRACE */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDALIGN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDLIB_H 1 + +/* Define if strerror_l is available in . */ +#define _GLIBCXX_HAVE_STRERROR_L 1 + +/* Define if strerror_r is available in . */ +#define _GLIBCXX_HAVE_STRERROR_R 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtof' function. */ +#define _GLIBCXX_HAVE_STRTOF 1 + +/* Define to 1 if you have the `strtold' function. */ +#define _GLIBCXX_HAVE_STRTOLD 1 + +/* Define to 1 if `d_type' is a member of `struct dirent'. */ +#define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1 + +/* Define if strxfrm_l is available in . */ +#define _GLIBCXX_HAVE_STRXFRM_L 1 + +/* Define if symlink is available in . */ +#define _GLIBCXX_HAVE_SYMLINK 1 + +/* Define to 1 if the target runtime linker supports binding the same symbol + to different versions. */ +#define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_IPC_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_MMAN_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have a suitable header file */ +/* #undef _GLIBCXX_HAVE_SYS_SDT_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SEM_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_UIO_H 1 + +/* Define if S_IFREG is available in . */ +/* #undef _GLIBCXX_HAVE_S_IFREG */ + +/* Define if S_ISREG is available in . */ +#define _GLIBCXX_HAVE_S_ISREG 1 + +/* Define to 1 if you have the `tanf' function. */ +#define _GLIBCXX_HAVE_TANF 1 + +/* Define to 1 if you have the `tanhf' function. */ +#define _GLIBCXX_HAVE_TANHF 1 + +/* Define to 1 if you have the `tanhl' function. */ +#define _GLIBCXX_HAVE_TANHL 1 + +/* Define to 1 if you have the `tanl' function. */ +#define _GLIBCXX_HAVE_TANL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_TGMATH_H 1 + +/* Define to 1 if you have the `timespec_get' function. */ +#define _GLIBCXX_HAVE_TIMESPEC_GET 1 + +/* Define to 1 if the target supports thread-local storage. */ +#define _GLIBCXX_HAVE_TLS 1 + +/* Define if truncate is available in . */ +#define _GLIBCXX_HAVE_TRUNCATE 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UCHAR_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UNISTD_H 1 + +/* Define if unlinkat is available in . */ +#define _GLIBCXX_HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `uselocale' function. */ +#define _GLIBCXX_HAVE_USELOCALE 1 + +/* Defined if usleep exists. */ +/* #undef _GLIBCXX_HAVE_USLEEP */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UTIME_H 1 + +/* Defined if vfwscanf exists. */ +#define _GLIBCXX_HAVE_VFWSCANF 1 + +/* Defined if vswscanf exists. */ +#define _GLIBCXX_HAVE_VSWSCANF 1 + +/* Defined if vwscanf exists. */ +#define _GLIBCXX_HAVE_VWSCANF 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_WCHAR_H 1 + +/* Defined if wcstof exists. */ +#define _GLIBCXX_HAVE_WCSTOF 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_WCTYPE_H 1 + +/* Defined if Sleep exists. */ +/* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ + +/* Define if writev is available in . */ +#define _GLIBCXX_HAVE_WRITEV 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_XLOCALE_H */ + +/* Define to 1 if you have the `_acosf' function. */ +/* #undef _GLIBCXX_HAVE__ACOSF */ + +/* Define to 1 if you have the `_acosl' function. */ +/* #undef _GLIBCXX_HAVE__ACOSL */ + +/* Define to 1 if you have the `_aligned_malloc' function. */ +/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ + +/* Define to 1 if you have the `_asinf' function. */ +/* #undef _GLIBCXX_HAVE__ASINF */ + +/* Define to 1 if you have the `_asinl' function. */ +/* #undef _GLIBCXX_HAVE__ASINL */ + +/* Define to 1 if you have the `_atan2f' function. */ +/* #undef _GLIBCXX_HAVE__ATAN2F */ + +/* Define to 1 if you have the `_atan2l' function. */ +/* #undef _GLIBCXX_HAVE__ATAN2L */ + +/* Define to 1 if you have the `_atanf' function. */ +/* #undef _GLIBCXX_HAVE__ATANF */ + +/* Define to 1 if you have the `_atanl' function. */ +/* #undef _GLIBCXX_HAVE__ATANL */ + +/* Define to 1 if you have the `_ceilf' function. */ +/* #undef _GLIBCXX_HAVE__CEILF */ + +/* Define to 1 if you have the `_ceill' function. */ +/* #undef _GLIBCXX_HAVE__CEILL */ + +/* Define to 1 if you have the `_cosf' function. */ +/* #undef _GLIBCXX_HAVE__COSF */ + +/* Define to 1 if you have the `_coshf' function. */ +/* #undef _GLIBCXX_HAVE__COSHF */ + +/* Define to 1 if you have the `_coshl' function. */ +/* #undef _GLIBCXX_HAVE__COSHL */ + +/* Define to 1 if you have the `_cosl' function. */ +/* #undef _GLIBCXX_HAVE__COSL */ + +/* Define to 1 if you have the `_expf' function. */ +/* #undef _GLIBCXX_HAVE__EXPF */ + +/* Define to 1 if you have the `_expl' function. */ +/* #undef _GLIBCXX_HAVE__EXPL */ + +/* Define to 1 if you have the `_fabsf' function. */ +/* #undef _GLIBCXX_HAVE__FABSF */ + +/* Define to 1 if you have the `_fabsl' function. */ +/* #undef _GLIBCXX_HAVE__FABSL */ + +/* Define to 1 if you have the `_finite' function. */ +/* #undef _GLIBCXX_HAVE__FINITE */ + +/* Define to 1 if you have the `_finitef' function. */ +/* #undef _GLIBCXX_HAVE__FINITEF */ + +/* Define to 1 if you have the `_finitel' function. */ +/* #undef _GLIBCXX_HAVE__FINITEL */ + +/* Define to 1 if you have the `_floorf' function. */ +/* #undef _GLIBCXX_HAVE__FLOORF */ + +/* Define to 1 if you have the `_floorl' function. */ +/* #undef _GLIBCXX_HAVE__FLOORL */ + +/* Define to 1 if you have the `_fmodf' function. */ +/* #undef _GLIBCXX_HAVE__FMODF */ + +/* Define to 1 if you have the `_fmodl' function. */ +/* #undef _GLIBCXX_HAVE__FMODL */ + +/* Define to 1 if you have the `_fpclass' function. */ +/* #undef _GLIBCXX_HAVE__FPCLASS */ + +/* Define to 1 if you have the `_frexpf' function. */ +/* #undef _GLIBCXX_HAVE__FREXPF */ + +/* Define to 1 if you have the `_frexpl' function. */ +/* #undef _GLIBCXX_HAVE__FREXPL */ + +/* Define to 1 if you have the `_hypot' function. */ +/* #undef _GLIBCXX_HAVE__HYPOT */ + +/* Define to 1 if you have the `_hypotf' function. */ +/* #undef _GLIBCXX_HAVE__HYPOTF */ + +/* Define to 1 if you have the `_hypotl' function. */ +/* #undef _GLIBCXX_HAVE__HYPOTL */ + +/* Define to 1 if you have the `_isinf' function. */ +/* #undef _GLIBCXX_HAVE__ISINF */ + +/* Define to 1 if you have the `_isinff' function. */ +/* #undef _GLIBCXX_HAVE__ISINFF */ + +/* Define to 1 if you have the `_isinfl' function. */ +/* #undef _GLIBCXX_HAVE__ISINFL */ + +/* Define to 1 if you have the `_isnan' function. */ +/* #undef _GLIBCXX_HAVE__ISNAN */ + +/* Define to 1 if you have the `_isnanf' function. */ +/* #undef _GLIBCXX_HAVE__ISNANF */ + +/* Define to 1 if you have the `_isnanl' function. */ +/* #undef _GLIBCXX_HAVE__ISNANL */ + +/* Define to 1 if you have the `_ldexpf' function. */ +/* #undef _GLIBCXX_HAVE__LDEXPF */ + +/* Define to 1 if you have the `_ldexpl' function. */ +/* #undef _GLIBCXX_HAVE__LDEXPL */ + +/* Define to 1 if you have the `_log10f' function. */ +/* #undef _GLIBCXX_HAVE__LOG10F */ + +/* Define to 1 if you have the `_log10l' function. */ +/* #undef _GLIBCXX_HAVE__LOG10L */ + +/* Define to 1 if you have the `_logf' function. */ +/* #undef _GLIBCXX_HAVE__LOGF */ + +/* Define to 1 if you have the `_logl' function. */ +/* #undef _GLIBCXX_HAVE__LOGL */ + +/* Define to 1 if you have the `_modf' function. */ +/* #undef _GLIBCXX_HAVE__MODF */ + +/* Define to 1 if you have the `_modff' function. */ +/* #undef _GLIBCXX_HAVE__MODFF */ + +/* Define to 1 if you have the `_modfl' function. */ +/* #undef _GLIBCXX_HAVE__MODFL */ + +/* Define to 1 if you have the `_powf' function. */ +/* #undef _GLIBCXX_HAVE__POWF */ + +/* Define to 1 if you have the `_powl' function. */ +/* #undef _GLIBCXX_HAVE__POWL */ + +/* Define to 1 if you have the `_qfpclass' function. */ +/* #undef _GLIBCXX_HAVE__QFPCLASS */ + +/* Define to 1 if you have the `_sincos' function. */ +/* #undef _GLIBCXX_HAVE__SINCOS */ + +/* Define to 1 if you have the `_sincosf' function. */ +/* #undef _GLIBCXX_HAVE__SINCOSF */ + +/* Define to 1 if you have the `_sincosl' function. */ +/* #undef _GLIBCXX_HAVE__SINCOSL */ + +/* Define to 1 if you have the `_sinf' function. */ +/* #undef _GLIBCXX_HAVE__SINF */ + +/* Define to 1 if you have the `_sinhf' function. */ +/* #undef _GLIBCXX_HAVE__SINHF */ + +/* Define to 1 if you have the `_sinhl' function. */ +/* #undef _GLIBCXX_HAVE__SINHL */ + +/* Define to 1 if you have the `_sinl' function. */ +/* #undef _GLIBCXX_HAVE__SINL */ + +/* Define to 1 if you have the `_sqrtf' function. */ +/* #undef _GLIBCXX_HAVE__SQRTF */ + +/* Define to 1 if you have the `_sqrtl' function. */ +/* #undef _GLIBCXX_HAVE__SQRTL */ + +/* Define to 1 if you have the `_tanf' function. */ +/* #undef _GLIBCXX_HAVE__TANF */ + +/* Define to 1 if you have the `_tanhf' function. */ +/* #undef _GLIBCXX_HAVE__TANHF */ + +/* Define to 1 if you have the `_tanhl' function. */ +/* #undef _GLIBCXX_HAVE__TANHL */ + +/* Define to 1 if you have the `_tanl' function. */ +/* #undef _GLIBCXX_HAVE__TANL */ + +/* Define to 1 if you have the `_wfopen' function. */ +/* #undef _GLIBCXX_HAVE__WFOPEN */ + +/* Define to 1 if you have the `__cxa_thread_atexit' function. */ +/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ + +/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ +#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1 + +/* Define as const if the declaration of iconv() needs const. */ +#define _GLIBCXX_ICONV_CONST + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define _GLIBCXX_LT_OBJDIR ".libs/" + +/* Name of package */ +/* #undef _GLIBCXX_PACKAGE */ + +/* Define to the address where bug reports for this package should be sent. */ +#define _GLIBCXX_PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define _GLIBCXX_PACKAGE_NAME "package-unused" + +/* Define to the full name and version of this package. */ +#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" + +/* Define to the one symbol short name of this package. */ +#define _GLIBCXX_PACKAGE_TARNAME "libstdc++" + +/* Define to the home page for this package. */ +#define _GLIBCXX_PACKAGE_URL "" + +/* Define to the version of this package. */ +#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" + +/* The size of `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* The size of `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of `void *', as computed by sizeof. */ +/* #undef SIZEOF_VOID_P */ + +/* Define to 1 if you have the ANSI C header files. */ +#define _GLIBCXX_STDC_HEADERS 1 + +/* Version number of package */ +/* #undef _GLIBCXX_VERSION */ + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _GLIBCXX_DARWIN_USE_64_BIT_INODE +# define _GLIBCXX_DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _GLIBCXX_FILE_OFFSET_BITS */ + +/* Define if C99 functions in should be used in for + C++11. Using compiler builtins for these functions requires corresponding + C99 library functions to be present. */ +#define _GLIBCXX11_USE_C99_COMPLEX 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_MATH 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_STDIO 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_STDLIB 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_WCHAR 1 + +/* Define if C99 functions in should be used in for + C++98. Using compiler builtins for these functions requires corresponding + C99 library functions to be present. */ +#define _GLIBCXX98_USE_C99_COMPLEX 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_MATH 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_STDIO 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_STDLIB 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_WCHAR 1 + +/* Define if the compiler supports C++11 atomics. */ +#define _GLIBCXX_ATOMIC_BUILTINS 1 + +/* Define to use concept checking code from the boost libraries. */ +/* #undef _GLIBCXX_CONCEPT_CHECKS */ + +/* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, + undefined for platform defaults */ +#define _GLIBCXX_FULLY_DYNAMIC_STRING 0 + +/* Define if gthreads library is available. */ +#define _GLIBCXX_HAS_GTHREADS 1 + +/* Define to 1 if a full hosted library is built, or 0 if freestanding. */ +#define _GLIBCXX_HOSTED 1 + +/* Define if compatibility should be provided for alternative 128-bit long + double formats. */ + +/* Define if compatibility should be provided for -mlong-double-64. */ + +/* Define to the letter to which size_t is mangled. */ +#define _GLIBCXX_MANGLE_SIZE_T m + +/* Define if C99 llrint and llround functions are missing from . */ +/* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ + +/* Defined if no way to sleep is available. */ +/* #undef _GLIBCXX_NO_SLEEP */ + +/* Define if ptrdiff_t is int. */ +/* #undef _GLIBCXX_PTRDIFF_T_IS_INT */ + +/* Define if using setrlimit to set resource limits during "make check" */ +#define _GLIBCXX_RES_LIMITS 1 + +/* Define if size_t is unsigned int. */ +/* #undef _GLIBCXX_SIZE_T_IS_UINT */ + +/* Define to the value of the EOF integer constant. */ +#define _GLIBCXX_STDIO_EOF -1 + +/* Define to the value of the SEEK_CUR integer constant. */ +#define _GLIBCXX_STDIO_SEEK_CUR 1 + +/* Define to the value of the SEEK_END integer constant. */ +#define _GLIBCXX_STDIO_SEEK_END 2 + +/* Define to use symbol versioning in the shared library. */ +#define _GLIBCXX_SYMVER 1 + +/* Define to use darwin versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_DARWIN */ + +/* Define to use GNU versioning in the shared library. */ +#define _GLIBCXX_SYMVER_GNU 1 + +/* Define to use GNU namespace versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ + +/* Define to use Sun versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_SUN */ + +/* Define if C11 functions in should be imported into namespace std + in . */ +#define _GLIBCXX_USE_C11_UCHAR_CXX11 1 + +/* Define if C99 functions or macros from , , , + , and can be used or exposed. */ +#define _GLIBCXX_USE_C99 1 + +/* Define if C99 functions in should be used in . + Using compiler builtins for these functions requires corresponding C99 + library functions to be present. */ +#define _GLIBCXX_USE_C99_COMPLEX_TR1 1 + +/* Define if C99 functions in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_CTYPE_TR1 1 + +/* Define if C99 functions in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_FENV_TR1 1 + +/* Define if C99 functions in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_INTTYPES_TR1 1 + +/* Define if wchar_t C99 functions in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_MATH_TR1 1 + +/* Define if C99 types in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_STDINT_TR1 1 + +/* Defined if clock_gettime syscall has monotonic and realtime clock support. + */ +/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ + +/* Defined if clock_gettime has monotonic clock support. */ +#define _GLIBCXX_USE_CLOCK_MONOTONIC 1 + +/* Defined if clock_gettime has realtime clock support. */ +#define _GLIBCXX_USE_CLOCK_REALTIME 1 + +/* Define if ISO/IEC TR 24733 decimal floating point types are supported on + this host. */ +#define _GLIBCXX_USE_DECIMAL_FLOAT 1 + +/* Define if /dev/random and /dev/urandom are available for + std::random_device. */ +#define _GLIBCXX_USE_DEV_RANDOM 1 + +/* Define if fchmod is available in . */ +#define _GLIBCXX_USE_FCHMOD 1 + +/* Define if fchmodat is available in . */ +#define _GLIBCXX_USE_FCHMODAT 1 + +/* Defined if gettimeofday is available. */ +#define _GLIBCXX_USE_GETTIMEOFDAY 1 + +/* Define if get_nprocs is available in . */ +#define _GLIBCXX_USE_GET_NPROCS 1 + +/* Define if LFS support is available. */ +#define _GLIBCXX_USE_LFS 1 + +/* Define if code specialized for long long should be used. */ +#define _GLIBCXX_USE_LONG_LONG 1 + +/* Define if lstat is available in . */ +#define _GLIBCXX_USE_LSTAT 1 + +/* Defined if nanosleep is available. */ +#define _GLIBCXX_USE_NANOSLEEP 1 + +/* Define if NLS translations are to be used. */ +#define _GLIBCXX_USE_NLS 1 + +/* Define if pthreads_num_processors_np is available in . */ +/* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ + +/* Define if pthread_cond_clockwait is available in . */ +#define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT 1 + +/* Define if pthread_mutex_clocklock is available in . */ +#define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1 + +/* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are + available in . */ +#define _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK 1 + +/* Define if POSIX read/write locks are available in . */ +#define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1 + +/* Define if /dev/random and /dev/urandom are available for the random_device + of TR1 (Chapter 5.1). */ +#define _GLIBCXX_USE_RANDOM_TR1 1 + +/* Define if usable realpath is available in . */ +#define _GLIBCXX_USE_REALPATH 1 + +/* Defined if sched_yield is available. */ +#define _GLIBCXX_USE_SCHED_YIELD 1 + +/* Define if _SC_NPROCESSORS_ONLN is available in . */ +#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 + +/* Define if _SC_NPROC_ONLN is available in . */ +/* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ + +/* Define if sendfile is available in . */ +#define _GLIBCXX_USE_SENDFILE 1 + +/* Define to restrict std::__basic_file<> to stdio APIs. */ +/* #undef _GLIBCXX_USE_STDIO_PURE */ + +/* Define if struct stat has timespec members. */ +#define _GLIBCXX_USE_ST_MTIM 1 + +/* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ +/* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ + +/* Define if obsolescent tmpnam is available in . */ +#define _GLIBCXX_USE_TMPNAM 1 + +/* Define if c8rtomb and mbrtoc8 functions in should be imported + into namespace std in for C++20. */ +/* #undef _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 */ + +/* Define if c8rtomb and mbrtoc8 functions in should be imported + into namespace std in for -fchar8_t. */ +/* #undef _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T */ + +/* Define if utime is available in . */ +#define _GLIBCXX_USE_UTIME 1 + +/* Define if utimensat and UTIME_OMIT are available in and + AT_FDCWD in . */ +#define _GLIBCXX_USE_UTIMENSAT 1 + +/* Define if code specialized for wchar_t should be used. */ +#define _GLIBCXX_USE_WCHAR_T 1 + +/* Define to 1 if a verbose library is built, or 0 otherwise. */ +#define _GLIBCXX_VERBOSE 1 + +/* Defined if as can handle rdrand. */ +#define _GLIBCXX_X86_RDRAND 1 + +/* Defined if as can handle rdseed. */ +#define _GLIBCXX_X86_RDSEED 1 + +/* Define to 1 if mutex_timedlock is available. */ +#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 + +/* Define for large files, on AIX-style hosts. */ +/* #undef _GLIBCXX_LARGE_FILES */ + +/* Define if all C++11 floating point overloads are available in . */ +#if __cplusplus >= 201103L +/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ +#endif + +/* Define if all C++11 integral type overloads are available in . */ +#if __cplusplus >= 201103L +/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ +#endif + +#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) +# define _GLIBCXX_HAVE_ACOSF 1 +# define acosf _acosf +#endif + +#if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) +# define _GLIBCXX_HAVE_ACOSL 1 +# define acosl _acosl +#endif + +#if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) +# define _GLIBCXX_HAVE_ASINF 1 +# define asinf _asinf +#endif + +#if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) +# define _GLIBCXX_HAVE_ASINL 1 +# define asinl _asinl +#endif + +#if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) +# define _GLIBCXX_HAVE_ATAN2F 1 +# define atan2f _atan2f +#endif + +#if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) +# define _GLIBCXX_HAVE_ATAN2L 1 +# define atan2l _atan2l +#endif + +#if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) +# define _GLIBCXX_HAVE_ATANF 1 +# define atanf _atanf +#endif + +#if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) +# define _GLIBCXX_HAVE_ATANL 1 +# define atanl _atanl +#endif + +#if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) +# define _GLIBCXX_HAVE_CEILF 1 +# define ceilf _ceilf +#endif + +#if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) +# define _GLIBCXX_HAVE_CEILL 1 +# define ceill _ceill +#endif + +#if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) +# define _GLIBCXX_HAVE_COSF 1 +# define cosf _cosf +#endif + +#if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) +# define _GLIBCXX_HAVE_COSHF 1 +# define coshf _coshf +#endif + +#if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) +# define _GLIBCXX_HAVE_COSHL 1 +# define coshl _coshl +#endif + +#if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) +# define _GLIBCXX_HAVE_COSL 1 +# define cosl _cosl +#endif + +#if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) +# define _GLIBCXX_HAVE_EXPF 1 +# define expf _expf +#endif + +#if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) +# define _GLIBCXX_HAVE_EXPL 1 +# define expl _expl +#endif + +#if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) +# define _GLIBCXX_HAVE_FABSF 1 +# define fabsf _fabsf +#endif + +#if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) +# define _GLIBCXX_HAVE_FABSL 1 +# define fabsl _fabsl +#endif + +#if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) +# define _GLIBCXX_HAVE_FINITE 1 +# define finite _finite +#endif + +#if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) +# define _GLIBCXX_HAVE_FINITEF 1 +# define finitef _finitef +#endif + +#if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) +# define _GLIBCXX_HAVE_FINITEL 1 +# define finitel _finitel +#endif + +#if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) +# define _GLIBCXX_HAVE_FLOORF 1 +# define floorf _floorf +#endif + +#if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) +# define _GLIBCXX_HAVE_FLOORL 1 +# define floorl _floorl +#endif + +#if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) +# define _GLIBCXX_HAVE_FMODF 1 +# define fmodf _fmodf +#endif + +#if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) +# define _GLIBCXX_HAVE_FMODL 1 +# define fmodl _fmodl +#endif + +#if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) +# define _GLIBCXX_HAVE_FPCLASS 1 +# define fpclass _fpclass +#endif + +#if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) +# define _GLIBCXX_HAVE_FREXPF 1 +# define frexpf _frexpf +#endif + +#if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) +# define _GLIBCXX_HAVE_FREXPL 1 +# define frexpl _frexpl +#endif + +#if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) +# define _GLIBCXX_HAVE_HYPOT 1 +# define hypot _hypot +#endif + +#if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) +# define _GLIBCXX_HAVE_HYPOTF 1 +# define hypotf _hypotf +#endif + +#if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) +# define _GLIBCXX_HAVE_HYPOTL 1 +# define hypotl _hypotl +#endif + +#if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) +# define _GLIBCXX_HAVE_ISINF 1 +# define isinf _isinf +#endif + +#if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) +# define _GLIBCXX_HAVE_ISINFF 1 +# define isinff _isinff +#endif + +#if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) +# define _GLIBCXX_HAVE_ISINFL 1 +# define isinfl _isinfl +#endif + +#if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) +# define _GLIBCXX_HAVE_ISNAN 1 +# define isnan _isnan +#endif + +#if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) +# define _GLIBCXX_HAVE_ISNANF 1 +# define isnanf _isnanf +#endif + +#if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) +# define _GLIBCXX_HAVE_ISNANL 1 +# define isnanl _isnanl +#endif + +#if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) +# define _GLIBCXX_HAVE_LDEXPF 1 +# define ldexpf _ldexpf +#endif + +#if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) +# define _GLIBCXX_HAVE_LDEXPL 1 +# define ldexpl _ldexpl +#endif + +#if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) +# define _GLIBCXX_HAVE_LOG10F 1 +# define log10f _log10f +#endif + +#if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) +# define _GLIBCXX_HAVE_LOG10L 1 +# define log10l _log10l +#endif + +#if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) +# define _GLIBCXX_HAVE_LOGF 1 +# define logf _logf +#endif + +#if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) +# define _GLIBCXX_HAVE_LOGL 1 +# define logl _logl +#endif + +#if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) +# define _GLIBCXX_HAVE_MODF 1 +# define modf _modf +#endif + +#if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) +# define _GLIBCXX_HAVE_MODFF 1 +# define modff _modff +#endif + +#if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) +# define _GLIBCXX_HAVE_MODFL 1 +# define modfl _modfl +#endif + +#if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) +# define _GLIBCXX_HAVE_POWF 1 +# define powf _powf +#endif + +#if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) +# define _GLIBCXX_HAVE_POWL 1 +# define powl _powl +#endif + +#if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) +# define _GLIBCXX_HAVE_QFPCLASS 1 +# define qfpclass _qfpclass +#endif + +#if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) +# define _GLIBCXX_HAVE_SINCOS 1 +# define sincos _sincos +#endif + +#if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) +# define _GLIBCXX_HAVE_SINCOSF 1 +# define sincosf _sincosf +#endif + +#if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) +# define _GLIBCXX_HAVE_SINCOSL 1 +# define sincosl _sincosl +#endif + +#if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) +# define _GLIBCXX_HAVE_SINF 1 +# define sinf _sinf +#endif + +#if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) +# define _GLIBCXX_HAVE_SINHF 1 +# define sinhf _sinhf +#endif + +#if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) +# define _GLIBCXX_HAVE_SINHL 1 +# define sinhl _sinhl +#endif + +#if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) +# define _GLIBCXX_HAVE_SINL 1 +# define sinl _sinl +#endif + +#if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) +# define _GLIBCXX_HAVE_SQRTF 1 +# define sqrtf _sqrtf +#endif + +#if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) +# define _GLIBCXX_HAVE_SQRTL 1 +# define sqrtl _sqrtl +#endif + +#if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) +# define _GLIBCXX_HAVE_STRTOF 1 +# define strtof _strtof +#endif + +#if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) +# define _GLIBCXX_HAVE_STRTOLD 1 +# define strtold _strtold +#endif + +#if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) +# define _GLIBCXX_HAVE_TANF 1 +# define tanf _tanf +#endif + +#if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) +# define _GLIBCXX_HAVE_TANHF 1 +# define tanhf _tanhf +#endif + +#if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) +# define _GLIBCXX_HAVE_TANHL 1 +# define tanhl _tanhl +#endif + +#if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) +# define _GLIBCXX_HAVE_TANL 1 +# define tanl _tanl +#endif + +#endif // _GLIBCXX_CXX_CONFIG_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5d8c61b00b9153b68073902f9dd1a710794df39b Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++config.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h new file mode 100644 index 0000000000000000000000000000000000000000..1a5e05a844a427c75c173e14b0f19954323f3feb --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h @@ -0,0 +1,50 @@ +// Underlying io library details -*- C++ -*- + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++io.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +// c_io_stdio.h - Defines for using "C" stdio.h + +#ifndef _GLIBCXX_CXX_IO_H +#define _GLIBCXX_CXX_IO_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef __gthread_mutex_t __c_lock; + + // for basic_file.h + typedef FILE __c_file; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..20d9b4bb3263d35d0e65527b0081825945bcffb5 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++io.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h new file mode 100644 index 0000000000000000000000000000000000000000..526b62215e120b7c1e4317402d2eff1d03c2e876 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h @@ -0,0 +1,124 @@ +// Wrapper for underlying C-language localization -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++locale.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.8 Standard locale categories. +// + +// Written by Benjamin Kosnik + +#ifndef _GLIBCXX_CXX_LOCALE_H +#define _GLIBCXX_CXX_LOCALE_H 1 + +#pragma GCC system_header + +#include + +#define _GLIBCXX_C_LOCALE_GNU 1 + +#define _GLIBCXX_NUM_CATEGORIES 6 + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + extern "C" __typeof(uselocale) __uselocale; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef __locale_t __c_locale; + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ +namespace __gnu_cxx_ieee128 { +#endif + + // Convert numeric value of type double and long double to string and + // return length of string. If vsnprintf is available use it, otherwise + // fall back to the unsafe vsprintf which, in general, can be dangerous + // and should be avoided. + inline int + __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), + char* __out, + const int __size __attribute__ ((__unused__)), + const char* __fmt, ...) + { +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __gnu_cxx::__uselocale(__cloc); +#else + char* __old = std::setlocale(LC_NUMERIC, 0); + char* __sav = 0; + if (__builtin_strcmp(__old, "C")) + { + const size_t __len = __builtin_strlen(__old) + 1; + __sav = new char[__len]; + __builtin_memcpy(__sav, __old, __len); + std::setlocale(LC_NUMERIC, "C"); + } +#endif + + __builtin_va_list __args; + __builtin_va_start(__args, __fmt); + +#if _GLIBCXX_USE_C99_STDIO + const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); +#else + const int __ret = __builtin_vsprintf(__out, __fmt, __args); +#endif + + __builtin_va_end(__args); + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __gnu_cxx::__uselocale(__old); +#else + if (__sav) + { + std::setlocale(LC_NUMERIC, __sav); + delete [] __sav; + } +#endif + return __ret; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ +} // namespace __gnu_cxx_ieee128 +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5cc1629c611f4af33819d575876cf7c1def1baac Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@c++locale.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..31cfe23eefc49f5fbb0ca6c4bf6b94ce02adb3ed --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h @@ -0,0 +1,33 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2005-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6bfae8494001b35fe2d94af404c59265cfd5a886 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@cpu_defines.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h new file mode 100644 index 0000000000000000000000000000000000000000..955146543db60062f7578c148211ac0911bfd4a9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h @@ -0,0 +1,66 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ctype_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from /usr/include/ctype.h + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @brief Base class for ctype. + struct ctype_base + { + // Non-standard typedefs. + typedef const int* __to_type; + + // NB: Offsets into ctype::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef unsigned short mask; + static const mask upper = _ISupper; + static const mask lower = _ISlower; + static const mask alpha = _ISalpha; + static const mask digit = _ISdigit; + static const mask xdigit = _ISxdigit; + static const mask space = _ISspace; + static const mask print = _ISprint; + static const mask graph = _ISalpha | _ISdigit | _ISpunct; + static const mask cntrl = _IScntrl; + static const mask punct = _ISpunct; + static const mask alnum = _ISalpha | _ISdigit; +#if __cplusplus >= 201103L + static const mask blank = _ISblank; +#endif + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..325e372009923c28179ff7da4c30761e4bc85cf2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_base.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h new file mode 100644 index 0000000000000000000000000000000000000000..af60239382f445367dde02d2ff2f532989c30e1f --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h @@ -0,0 +1,76 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ctype_inline.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + bool + ctype:: + is(mask __m, char __c) const + { return _M_table[static_cast(__c)] & __m; } + + const char* + ctype:: + is(const char* __low, const char* __high, mask* __vec) const + { + while (__low < __high) + *__vec++ = _M_table[static_cast(*__low++)]; + return __high; + } + + const char* + ctype:: + scan_is(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && !(_M_table[static_cast(*__low)] & __m)) + ++__low; + return __low; + } + + const char* + ctype:: + scan_not(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && (_M_table[static_cast(*__low)] & __m) != 0) + ++__low; + return __low; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..1f90e383d492d383f6ad394a34767378c4d52080 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@ctype_inline.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h new file mode 100644 index 0000000000000000000000000000000000000000..8e22cf7c9178fbcfd78a7721a3e3202b229d8ff9 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h @@ -0,0 +1,178 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2007-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/error_constants.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{system_error} + */ + +#ifndef _GLIBCXX_ERROR_CONSTANTS +#define _GLIBCXX_ERROR_CONSTANTS 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum class errc + { + address_family_not_supported = EAFNOSUPPORT, + address_in_use = EADDRINUSE, + address_not_available = EADDRNOTAVAIL, + already_connected = EISCONN, + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, + bad_file_descriptor = EBADF, + +#ifdef EBADMSG + bad_message = EBADMSG, +#endif + + broken_pipe = EPIPE, + connection_aborted = ECONNABORTED, + connection_already_in_progress = EALREADY, + connection_refused = ECONNREFUSED, + connection_reset = ECONNRESET, + cross_device_link = EXDEV, + destination_address_required = EDESTADDRREQ, + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, + file_exists = EEXIST, + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, + host_unreachable = EHOSTUNREACH, + +#ifdef EIDRM + identifier_removed = EIDRM, +#endif + + illegal_byte_sequence = EILSEQ, + inappropriate_io_control_operation = ENOTTY, + interrupted = EINTR, + invalid_argument = EINVAL, + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, + message_size = EMSGSIZE, + network_down = ENETDOWN, + network_reset = ENETRESET, + network_unreachable = ENETUNREACH, + no_buffer_space = ENOBUFS, + no_child_process = ECHILD, + +#ifdef ENOLINK + no_link = ENOLINK, +#endif + + no_lock_available = ENOLCK, + +#ifdef ENODATA + no_message_available = ENODATA, +#endif + + no_message = ENOMSG, + no_protocol_option = ENOPROTOOPT, + no_space_on_device = ENOSPC, + +#ifdef ENOSR + no_stream_resources = ENOSR, +#endif + + no_such_device_or_address = ENXIO, + no_such_device = ENODEV, + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, + not_a_socket = ENOTSOCK, + +#ifdef ENOSTR + not_a_stream = ENOSTR, +#endif + + not_connected = ENOTCONN, + not_enough_memory = ENOMEM, + +#ifdef ENOTSUP + not_supported = ENOTSUP, +#endif + +#ifdef ECANCELED + operation_canceled = ECANCELED, +#endif + + operation_in_progress = EINPROGRESS, + operation_not_permitted = EPERM, + operation_not_supported = EOPNOTSUPP, + operation_would_block = EWOULDBLOCK, + +#ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +#endif + + permission_denied = EACCES, + +#ifdef EPROTO + protocol_error = EPROTO, +#endif + + protocol_not_supported = EPROTONOSUPPORT, + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, + result_out_of_range = ERANGE, + +#ifdef ENOTRECOVERABLE + state_not_recoverable = ENOTRECOVERABLE, +#endif + +#ifdef ETIME + stream_timeout = ETIME, +#endif + +#ifdef ETXTBSY + text_file_busy = ETXTBSY, +#endif + + timed_out = ETIMEDOUT, + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, + too_many_symbolic_link_levels = ELOOP, + +#ifdef EOVERFLOW + value_too_large = EOVERFLOW, +#endif + + wrong_protocol_type = EPROTOTYPE + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..6a06b049a1307dc1d85a7b62ddb439d5ec851426 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@error_constants.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h new file mode 100644 index 0000000000000000000000000000000000000000..dbfbf6067e2c703abba3a379b499263fd5343597 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h @@ -0,0 +1,890 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_POSIX_H +#define _GLIBCXX_GCC_GTHR_POSIX_H + +/* POSIX threads specific definitions. + Easy, since the interface is just one-to-one mapping. */ + +#define __GTHREADS 1 +#define __GTHREADS_CXX0X 1 + +#include + +#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ + || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) +# include +# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 +# else +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 +# endif +#endif + +typedef pthread_t __gthread_t; +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; +typedef pthread_cond_t __gthread_cond_t; +typedef struct timespec __gthread_time_t; + +/* POSIX like conditional variables are supported. Please look at comments + in gthr.h for details. */ +#define __GTHREAD_HAS_COND 1 + +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#else +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER +#define __GTHREAD_TIME_INIT {0,0} + +#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC +# undef __GTHREAD_MUTEX_INIT +#endif +#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC +# undef __GTHREAD_RECURSIVE_MUTEX_INIT +# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION +# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#ifdef _GTHREAD_USE_COND_INIT_FUNC +# undef __GTHREAD_COND_INIT +# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function +#endif + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK +# ifndef __gthrw_pragma +# define __gthrw_pragma(pragma) +# endif +# define __gthrw2(name,name2,type) \ + static __typeof(type) name \ + __attribute__ ((__weakref__(#name2), __copy__ (type))); \ + __gthrw_pragma(weak type) +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw2(name,name2,type) +# define __gthrw_(name) name +#endif + +/* Typically, __gthrw_foo is a weak reference to symbol foo. */ +#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) + +__gthrw(pthread_once) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) + +__gthrw(pthread_create) +__gthrw(pthread_join) +__gthrw(pthread_equal) +__gthrw(pthread_self) +__gthrw(pthread_detach) +#ifndef __BIONIC__ +__gthrw(pthread_cancel) +#endif +__gthrw(sched_yield) + +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +__gthrw(pthread_mutex_timedlock) +#endif +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) + +__gthrw(pthread_cond_init) +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_cond_timedwait) +__gthrw(pthread_cond_destroy) + +__gthrw(pthread_key_create) +__gthrw(pthread_key_delete) +__gthrw(pthread_mutexattr_init) +__gthrw(pthread_mutexattr_settype) +__gthrw(pthread_mutexattr_destroy) + + +#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) +/* Objective-C. */ +__gthrw(pthread_exit) +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(sched_get_priority_max) +__gthrw(sched_get_priority_min) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ +__gthrw(pthread_attr_destroy) +__gthrw(pthread_attr_init) +__gthrw(pthread_attr_setdetachstate) +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(pthread_getschedparam) +__gthrw(pthread_setschedparam) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _LIBOBJC || _LIBOBJC_WEAK */ + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK + +/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if + -pthreads is not specified. The functions are dummies and most return an + error value. However pthread_once returns 0 without invoking the routine + it is passed so we cannot pretend that the interface is active if -pthreads + is not specified. On Solaris 2.5.1, the interface is not exposed at all so + we need to play the usual game with weak symbols. On Solaris 10 and up, a + working interface is always exposed. On FreeBSD 6 and later, libc also + exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up + to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, + which means the alternate __gthread_active_p below cannot be used there. */ + +#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) + +static volatile int __gthread_active = -1; + +static void +__gthread_trigger (void) +{ + __gthread_active = 1; +} + +static inline int +__gthread_active_p (void) +{ + static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; + static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; + + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + + /* This test is not protected to avoid taking a lock on the main code + path so every update of __gthread_active in a threaded program must + be atomic with regard to the result of the test. */ + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + if (__gthrw_(pthread_once)) + { + /* If this really is a threaded program, then we must ensure that + __gthread_active has been set to 1 before exiting this block. */ + __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); + __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); + __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); + } + + /* Make sure we'll never enter this block again. */ + if (__gthread_active < 0) + __gthread_active = 0; + + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* neither FreeBSD nor Solaris */ + +/* For a program to be multi-threaded the only thing that it certainly must + be using is pthread_create. However, there may be other libraries that + intercept pthread_create with their own definitions to wrap pthreads + functionality for some purpose. In those cases, pthread_create being + defined might not necessarily mean that libpthread is actually linked + in. + + For the GNU C library, we can use a known internal name. This is always + available in the ABI, but no other library would define it. That is + ideal, since any public pthread function might be intercepted just as + pthread_create might be. __pthread_key_create is an "internal" + implementation symbol, but it is part of the public exported ABI. Also, + it's among the symbols that the static libpthread.a always links in + whenever pthread_create is used, so there is no danger of a false + negative result in any statically-linked, multi-threaded program. + + For others, we choose pthread_cancel as a function that seems unlikely + to be redefined by an interceptor library. The bionic (Android) C + library does not provide pthread_cancel, so we do use pthread_create + there (and interceptor libraries lose). */ + +#ifdef __GLIBC__ +__gthrw2(__gthrw_(__pthread_key_create), + __pthread_key_create, + pthread_key_create) +# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) +#elif defined (__BIONIC__) +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) +#else +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) +#endif + +static inline int +__gthread_active_p (void) +{ + static void *const __gthread_active_ptr + = __extension__ (void *) >HR_ACTIVE_PROXY; + return __gthread_active_ptr != 0; +} + +#endif /* FreeBSD or Solaris */ + +#else /* not __GXX_WEAK__ */ + +/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread + calls in shared flavors of the HP-UX C library. Most of the stubs + have no functionality. The details are described in the "libc cumulative + patch" for each subversion of HP-UX 11. There are two special interfaces + provided for checking whether an application is linked to a shared pthread + library or not. However, these interfaces aren't available in early + libpthread libraries. We also need a test that works for archive + libraries. We can't use pthread_once as some libc versions call the + init function. We also can't use pthread_create or pthread_attr_init + as these create a thread and thereby prevent changing the default stack + size. The function pthread_default_stacksize_np is available in both + the archive and shared versions of libpthread. It can be used to + determine the default pthread stack size. There is a stub in some + shared libc versions which returns a zero size if pthreads are not + active. We provide an equivalent stub to handle cases where libc + doesn't provide one. */ + +#if defined(__hppa__) && defined(__hpux__) + +static volatile int __gthread_active = -1; + +static inline int +__gthread_active_p (void) +{ + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + size_t __s; + + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + pthread_default_stacksize_np (0, &__s); + __gthread_active = __s ? 1 : 0; + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* not hppa-hpux */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* hppa-hpux */ + +#endif /* __GXX_WEAK__ */ + +#ifdef _LIBOBJC + +/* This is the config.h file in libobjc/ */ +#include + +#ifdef HAVE_SCHED_H +# include +#endif + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; +static pthread_attr_t _objc_thread_attribs; + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + if (__gthread_active_p ()) + { + /* Initialize the thread storage key. */ + if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) + { + /* The normal default detach state for threads is + * PTHREAD_CREATE_JOINABLE which causes threads to not die + * when you think they should. */ + if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 + && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, + PTHREAD_CREATE_DETACHED) == 0) + return 0; + } + } + + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_active_p () + && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 + && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) + return 0; + + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!__gthread_active_p ()) + return NULL; + + if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, + (void *) func, arg))) + thread_id = (objc_thread_t) new_thread_handle; + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority) +{ + if (!__gthread_active_p ()) + return -1; + else + { +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + pthread_t thread_id = __gthrw_(pthread_self) (); + int policy; + struct sched_param params; + int priority_min, priority_max; + + if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) + { + if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) + return -1; + + if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) + return -1; + + if (priority > priority_max) + priority = priority_max; + else if (priority < priority_min) + priority = priority_min; + params.sched_priority = priority; + + /* + * The solaris 7 and several other man pages incorrectly state that + * this should be a pointer to policy but pthread.h is universally + * at odds with this. + */ + if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) + return 0; + } +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return -1; + } +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + if (__gthread_active_p ()) + { + int policy; + struct sched_param params; + + if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) + return params.sched_priority; + else + return -1; + } + else +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + if (__gthread_active_p ()) + __gthrw_(sched_yield) (); +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + if (__gthread_active_p ()) + /* exit the thread */ + __gthrw_(pthread_exit) (&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + if (__gthread_active_p ()) + return (objc_thread_t) __gthrw_(pthread_self) (); + else + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); + else + { + thread_local_storage = value; + return 0; + } +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_getspecific) (_objc_thread_storage); + else + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); + + if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) + { + objc_free (mutex->backend); + mutex->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + int count; + + /* + * Posix Threads specifically require that the thread be unlocked + * for __gthrw_(pthread_mutex_destroy) to work. + */ + + do + { + count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); + if (count < 0) + return -1; + } + while (count); + + if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) + return -1; + + objc_free (mutex->backend); + mutex->backend = NULL; + } + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + condition->backend = objc_malloc (sizeof (pthread_cond_t)); + + if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) + { + objc_free (condition->backend); + condition->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) + return -1; + + objc_free (condition->backend); + condition->backend = NULL; + } + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, + (pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), + void *__args) +{ + return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); +} + +static inline int +__gthread_join (__gthread_t __threadid, void **__value_ptr) +{ + return __gthrw_(pthread_join) (__threadid, __value_ptr); +} + +static inline int +__gthread_detach (__gthread_t __threadid) +{ + return __gthrw_(pthread_detach) (__threadid); +} + +static inline int +__gthread_equal (__gthread_t __t1, __gthread_t __t2) +{ + return __gthrw_(pthread_equal) (__t1, __t2); +} + +static inline __gthread_t +__gthread_self (void) +{ + return __gthrw_(pthread_self) (); +} + +static inline int +__gthread_yield (void) +{ + return __gthrw_(sched_yield) (); +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_key_create) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthrw_(pthread_key_delete) (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthrw_(pthread_getspecific) (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(pthread_setspecific) (__key, __ptr); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_mutex_init) (__mutex, NULL); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); + else + return 0; +} +#endif + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ + || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; + } + return 0; +} +#endif + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_mutex_timedlock (__mutex, __abs_timeout); +} +#endif + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +static inline int +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_destroy (__mutex); +} + +#ifdef _GTHREAD_USE_COND_INIT_FUNC +static inline void +__gthread_cond_init_function (__gthread_cond_t *__cond) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_cond_init) (__cond, NULL); +} +#endif + +static inline int +__gthread_cond_broadcast (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_broadcast) (__cond); +} + +static inline int +__gthread_cond_signal (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_signal) (__cond); +} + +static inline int +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) +{ + return __gthrw_(pthread_cond_wait) (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_wait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex) +{ + return __gthread_cond_wait (__cond, __mutex); +} + +static inline int +__gthread_cond_destroy (__gthread_cond_t* __cond) +{ + return __gthrw_(pthread_cond_destroy) (__cond); +} + +#endif /* _LIBOBJC */ + +#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c6668eee82f890cdf45db4fdf22d085d0952ad59 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr-default.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h new file mode 100644 index 0000000000000000000000000000000000000000..51fabc3c7ded6a2f54ac6a35be30fed09ef1c393 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h @@ -0,0 +1,154 @@ +/* Threads compatibility routines for libgcc2. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_H +#define _GLIBCXX_GCC_GTHR_H + +#ifndef _GLIBCXX_HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +/* If this file is compiled with threads support, it must + #define __GTHREADS 1 + to indicate that threads support is present. Also it has define + function + int __gthread_active_p () + that returns 1 if thread system is active, 0 if not. + + The threads interface must define the following types: + __gthread_key_t + __gthread_once_t + __gthread_mutex_t + __gthread_recursive_mutex_t + + The threads interface must define the following macros: + + __GTHREAD_ONCE_INIT + to initialize __gthread_once_t + __GTHREAD_MUTEX_INIT + to initialize __gthread_mutex_t to get a fast + non-recursive mutex. + __GTHREAD_MUTEX_INIT_FUNCTION + to initialize __gthread_mutex_t to get a fast + non-recursive mutex. + Define this to a function which looks like this: + void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) + Some systems can't initialize a mutex without a + function call. Don't define __GTHREAD_MUTEX_INIT in this case. + __GTHREAD_RECURSIVE_MUTEX_INIT + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION + as above, but for a recursive mutex. + + The threads interface must define the following static functions: + + int __gthread_once (__gthread_once_t *once, void (*func) ()) + + int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) + int __gthread_key_delete (__gthread_key_t key) + + void *__gthread_getspecific (__gthread_key_t key) + int __gthread_setspecific (__gthread_key_t key, const void *ptr) + + int __gthread_mutex_destroy (__gthread_mutex_t *mutex); + int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); + + int __gthread_mutex_lock (__gthread_mutex_t *mutex); + int __gthread_mutex_trylock (__gthread_mutex_t *mutex); + int __gthread_mutex_unlock (__gthread_mutex_t *mutex); + + int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); + + The following are supported in POSIX threads only. They are required to + fix a deadlock in static initialization inside libsupc++. The header file + gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra + features are supported. + + Types: + __gthread_cond_t + + Macros: + __GTHREAD_COND_INIT + __GTHREAD_COND_INIT_FUNCTION + + Interface: + int __gthread_cond_broadcast (__gthread_cond_t *cond); + int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); + int __gthread_cond_wait_recursive (__gthread_cond_t *cond, + __gthread_recursive_mutex_t *mutex); + + All functions returning int should return zero on success or the error + number. If the operation is not supported, -1 is returned. + + If the following are also defined, you should + #define __GTHREADS_CXX0X 1 + to enable the c++0x thread library. + + Types: + __gthread_t + __gthread_time_t + + Interface: + int __gthread_create (__gthread_t *thread, void *(*func) (void*), + void *args); + int __gthread_join (__gthread_t thread, void **value_ptr); + int __gthread_detach (__gthread_t thread); + int __gthread_equal (__gthread_t t1, __gthread_t t2); + __gthread_t __gthread_self (void); + int __gthread_yield (void); + + int __gthread_mutex_timedlock (__gthread_mutex_t *m, + const __gthread_time_t *abs_timeout); + int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, + const __gthread_time_t *abs_time); + + int __gthread_cond_signal (__gthread_cond_t *cond); + int __gthread_cond_timedwait (__gthread_cond_t *cond, + __gthread_mutex_t *mutex, + const __gthread_time_t *abs_timeout); + +*/ + +#if __GXX_WEAK__ +/* The pe-coff weak support isn't fully compatible to ELF's weak. + For static libraries it might would work, but as we need to deal + with shared versions too, we disable it for mingw-targets. */ +#ifdef __MINGW32__ +#undef _GLIBCXX_GTHREAD_USE_WEAK +#define _GLIBCXX_GTHREAD_USE_WEAK 0 +#endif + +#ifndef _GLIBCXX_GTHREAD_USE_WEAK +#define _GLIBCXX_GTHREAD_USE_WEAK 1 +#endif +#endif +#include + +#ifndef _GLIBCXX_HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +#endif /* ! _GLIBCXX_GCC_GTHR_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..62d9895ab0578fce1ae62488fbb032dddc981ec1 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@gthr.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h new file mode 100644 index 0000000000000000000000000000000000000000..13323a0f90e3b1275c33e2ea6bada1f15c7094b7 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h @@ -0,0 +1,151 @@ +// std::messages implementation details, GNU version -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/messages_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.7.1.2 messages functions +// + +// Written by Benjamin Kosnik + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Non-virtual member functions. + template + messages<_CharT>::messages(size_t __refs) + : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), + _M_name_messages(_S_get_c_name()) + { } + + template + messages<_CharT>::messages(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0) + { + if (__builtin_strcmp(__s, _S_get_c_name()) != 0) + { + const size_t __len = __builtin_strlen(__s) + 1; + char* __tmp = new char[__len]; + __builtin_memcpy(__tmp, __s, __len); + _M_name_messages = __tmp; + } + else + _M_name_messages = _S_get_c_name(); + + // Last to avoid leaking memory if new throws. + _M_c_locale_messages = _S_clone_c_locale(__cloc); + } + + template + typename messages<_CharT>::catalog + messages<_CharT>::open(const basic_string& __s, const locale& __loc, + const char* __dir) const + { + bindtextdomain(__s.c_str(), __dir); + return this->do_open(__s, __loc); + } + + // Virtual member functions. + template + messages<_CharT>::~messages() + { + if (_M_name_messages != _S_get_c_name()) + delete [] _M_name_messages; + _S_destroy_c_locale(_M_c_locale_messages); + } + + template + typename messages<_CharT>::catalog + messages<_CharT>::do_open(const basic_string& __s, + const locale&) const + { + // No error checking is done, assume the catalog exists and can + // be used. + textdomain(__s.c_str()); + return 0; + } + + template + void + messages<_CharT>::do_close(catalog) const + { } + + // messages_byname + template + messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) + : messages<_CharT>(__refs) + { + if (this->_M_name_messages != locale::facet::_S_get_c_name()) + { + delete [] this->_M_name_messages; + if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0) + { + const size_t __len = __builtin_strlen(__s) + 1; + char* __tmp = new char[__len]; + __builtin_memcpy(__tmp, __s, __len); + this->_M_name_messages = __tmp; + } + else + this->_M_name_messages = locale::facet::_S_get_c_name(); + } + + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_messages); + this->_S_create_c_locale(this->_M_c_locale_messages, __s); + } + } + + //Specializations. + template<> + typename messages::catalog + messages::do_open(const basic_string&, + const locale&) const; + + template<> + void + messages::do_close(catalog) const; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + typename messages::catalog + messages::do_open(const basic_string&, + const locale&) const; + + template<> + void + messages::do_close(catalog) const; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c5f26703edc4f299791facf73bdfdf1b603efcc2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@messages_members.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h new file mode 100644 index 0000000000000000000000000000000000000000..c1bf86fed63bbda87de0919f171f40f2049cd0b8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h @@ -0,0 +1,221 @@ +// Optimizations for random number functions, x86 version -*- C++ -*- + +// Copyright (C) 2012-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _BITS_OPT_RANDOM_H +#define _BITS_OPT_RANDOM_H 1 + +#ifdef __SSE3__ +#include +#endif + + +#pragma GCC system_header + + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __SSE3__ + template<> + template + void + normal_distribution:: + __generate(typename normal_distribution::result_type* __f, + typename normal_distribution::result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + typedef uint64_t __uctype; + + if (__f == __t) + return; + + if (_M_saved_available) + { + _M_saved_available = false; + *__f++ = _M_saved * __param.stddev() + __param.mean(); + + if (__f == __t) + return; + } + + constexpr uint64_t __maskval = 0xfffffffffffffull; + static const __m128i __mask = _mm_set1_epi64x(__maskval); + static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); + static const __m128d __three = _mm_set1_pd(3.0); + const __m128d __av = _mm_set1_pd(__param.mean()); + + const __uctype __urngmin = __urng.min(); + const __uctype __urngmax = __urng.max(); + const __uctype __urngrange = __urngmax - __urngmin; + const __uctype __uerngrange = __urngrange + 1; + + while (__f + 1 < __t) + { + double __le; + __m128d __x; + do + { + union + { + __m128i __i; + __m128d __d; + } __v; + + if (__urngrange > __maskval) + { + if (__detail::_Power_of_2(__uerngrange)) + __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), + __urng()), + __mask); + else + { + const __uctype __uerange = __maskval + 1; + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + uint64_t __v1; + do + __v1 = __uctype(__urng()) - __urngmin; + while (__v1 >= __past); + __v1 /= __scaling; + uint64_t __v2; + do + __v2 = __uctype(__urng()) - __urngmin; + while (__v2 >= __past); + __v2 /= __scaling; + + __v.__i = _mm_set_epi64x(__v1, __v2); + } + } + else if (__urngrange == __maskval) + __v.__i = _mm_set_epi64x(__urng(), __urng()); + else if ((__urngrange + 2) * __urngrange >= __maskval + && __detail::_Power_of_2(__uerngrange)) + { + uint64_t __v1 = __urng() * __uerngrange + __urng(); + uint64_t __v2 = __urng() * __uerngrange + __urng(); + + __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), + __mask); + } + else + { + size_t __nrng = 2; + __uctype __high = __maskval / __uerngrange / __uerngrange; + while (__high > __uerngrange) + { + ++__nrng; + __high /= __uerngrange; + } + const __uctype __highrange = __high + 1; + const __uctype __scaling = __urngrange / __highrange; + const __uctype __past = __highrange * __scaling; + __uctype __tmp; + + uint64_t __v1; + do + { + do + __tmp = __uctype(__urng()) - __urngmin; + while (__tmp >= __past); + __v1 = __tmp / __scaling; + for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) + { + __tmp = __v1; + __v1 *= __uerngrange; + __v1 += __uctype(__urng()) - __urngmin; + } + } + while (__v1 > __maskval || __v1 < __tmp); + + uint64_t __v2; + do + { + do + __tmp = __uctype(__urng()) - __urngmin; + while (__tmp >= __past); + __v2 = __tmp / __scaling; + for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) + { + __tmp = __v2; + __v2 *= __uerngrange; + __v2 += __uctype(__urng()) - __urngmin; + } + } + while (__v2 > __maskval || __v2 < __tmp); + + __v.__i = _mm_set_epi64x(__v1, __v2); + } + + __v.__i = _mm_or_si128(__v.__i, __two); + __x = _mm_sub_pd(__v.__d, __three); + __m128d __m = _mm_mul_pd(__x, __x); + __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); + } + while (__le == 0.0 || __le >= 1.0); + + double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) + * __param.stddev()); + + __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); + + _mm_storeu_pd(__f, __x); + __f += 2; + } + + if (__f != __t) + { + result_type __x, __y, __r2; + + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + *__f = __y * __mult * __param.stddev() + __param.mean(); + } + } +#endif + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + + +#endif // _BITS_OPT_RANDOM_H diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..8eaeadf0f8ef29b5f34a7288a6cb3ede16ca91e9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@opt_random.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..c0caa21a0136a174b7d6b6759ef544cd47b6a7b8 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h @@ -0,0 +1,70 @@ +// Specific definitions for GNU/Linux -*- C++ -*- + +// Copyright (C) 2000-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/os_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. + +// This keeps isalnum, et al from being propagated as macros. +#define __NO_CTYPE 1 + +#include + +// Provide a declaration for the possibly deprecated gets function, as +// glibc 2.15 and later does not declare gets for ISO C11 when +// __GNU_SOURCE is defined. +#if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) +# undef _GLIBCXX_HAVE_GETS +#endif + +// Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the +// version dynamically in case it has changed since libstdc++ was configured. +#define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23) + +#if __GLIBC_PREREQ(2, 27) +// Since glibc 2.27 pthread_self() is usable without linking to libpthread. +# define _GLIBCXX_NATIVE_THREAD_ID pthread_self() +#else +// Before then it was in libc.so.6 but not libc.a, and always returns 0, +// which breaks the invariant this_thread::get_id() != thread::id{}. +// So only use it if we know the libpthread version is available. +// Otherwise use (__gthread_t)1 as the ID of the main (and only) thread. +# define _GLIBCXX_NATIVE_THREAD_ID \ + (__gthread_active_p() ? __gthread_self() : (__gthread_t)1) +#endif + +#if __GLIBC_PREREQ(2, 34) +// Since glibc 2.34 all pthreads functions are usable without linking to +// libpthread. +# define _GLIBCXX_GTHREAD_USE_WEAK 0 +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..5362086dc4c69cf1033374ec0a5570a7c0494833 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@os_defines.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h new file mode 100644 index 0000000000000000000000000000000000000000..5ee1244dc22a49e1ebaf478fee2baad3b51ddad5 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h @@ -0,0 +1,162 @@ +// C++ includes used for precompiling -*- C++ -*- + +// Copyright (C) 2003-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file stdc++.h + * This is an implementation file for a precompiled header. + */ + +// 17.4.1.2 Headers + +// C +#ifndef _GLIBCXX_NO_ASSERT +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +// C++ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if __cplusplus >= 201402L +#include +#endif + +#if __cplusplus >= 201703L +#include +#include +// #include +#include +#include +#include +#include +#include +#endif + +#if __cplusplus >= 202002L +#include +#include +#include +#include +#if __cpp_impl_coroutine +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if __cplusplus > 202002L +#include +#include +#if __has_include() +# include +#endif +#include +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..610e61d8eb7c3e49ee82bd9d7d85637f9c70bb90 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@stdc++.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h new file mode 100644 index 0000000000000000000000000000000000000000..78265a1e019eef72f457e16b1c66d23899aff0f6 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h @@ -0,0 +1,89 @@ +// std::time_get, std::time_put implementation, GNU version -*- C++ -*- + +// Copyright (C) 2001-2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/time_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.5.1.2 - time_get functions +// ISO C++ 14882: 22.2.5.3.2 - time_put functions +// + +// Written by Benjamin Kosnik + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + __timepunct<_CharT>::__timepunct(size_t __refs) + : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } + + template + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } + + template + __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), + _M_name_timepunct(0) + { + if (__builtin_strcmp(__s, _S_get_c_name()) != 0) + { + const size_t __len = __builtin_strlen(__s) + 1; + char* __tmp = new char[__len]; + __builtin_memcpy(__tmp, __s, __len); + _M_name_timepunct = __tmp; + } + else + _M_name_timepunct = _S_get_c_name(); + + __try + { _M_initialize_timepunct(__cloc); } + __catch(...) + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + __throw_exception_again; + } + } + + template + __timepunct<_CharT>::~__timepunct() + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + delete _M_data; + _S_destroy_c_locale(_M_c_locale_timepunct); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..057e4d395c1a4a4db84d53da26142c92971fb0f9 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0@include@c++@12.2.0@x86_64-unknown-linux-gnu@bits@time_members.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h new file mode 100644 index 0000000000000000000000000000000000000000..e3b439285d0fd085d80b5c245171945fb78a87ed --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h @@ -0,0 +1,27 @@ +/*===---- __stddef_max_align_t.h - Definition of max_align_t for modules ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_MAX_ALIGN_T_DEFINED +#define __CLANG_MAX_ALIGN_T_DEFINED + +#if defined(_MSC_VER) +typedef double max_align_t; +#elif defined(__APPLE__) +typedef long double max_align_t; +#else +// Define 'max_align_t' to match the GCC definition. +typedef struct { + long long __clang_max_align_nonce1 + __attribute__((__aligned__(__alignof__(long long)))); + long double __clang_max_align_nonce2 + __attribute__((__aligned__(__alignof__(long double)))); +} max_align_t; +#endif + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..953317f76f1480481fe565ce1ae28f7e912f0b87 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@__stddef_max_align_t.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h new file mode 100644 index 0000000000000000000000000000000000000000..c6a6cc08462daa97ffe67d45af72a52a3e4afe2b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h @@ -0,0 +1,161 @@ +/*===---- float.h - Characteristics of floating point types ----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_FLOAT_H +#define __CLANG_FLOAT_H + +/* If we're on MinGW, fall back to the system's float.h, which might have + * additional definitions provided for Windows. + * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx + * + * Also fall back on Darwin and AIX to allow additional definitions and + * implementation-defined values. + */ +#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) || \ + defined(_AIX)) && \ + __STDC_HOSTED__ && __has_include_next() + +/* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level + * of #include_next to keep Metrowerks compilers happy. Avoid this + * extra indirection. + */ +#ifdef __APPLE__ +#define _FLOAT_H_ +#endif + +# include_next + +/* Undefine anything that we'll be redefining below. */ +# undef FLT_EVAL_METHOD +# undef FLT_ROUNDS +# undef FLT_RADIX +# undef FLT_MANT_DIG +# undef DBL_MANT_DIG +# undef LDBL_MANT_DIG +# if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef DECIMAL_DIG +# endif +# undef FLT_DIG +# undef DBL_DIG +# undef LDBL_DIG +# undef FLT_MIN_EXP +# undef DBL_MIN_EXP +# undef LDBL_MIN_EXP +# undef FLT_MIN_10_EXP +# undef DBL_MIN_10_EXP +# undef LDBL_MIN_10_EXP +# undef FLT_MAX_EXP +# undef DBL_MAX_EXP +# undef LDBL_MAX_EXP +# undef FLT_MAX_10_EXP +# undef DBL_MAX_10_EXP +# undef LDBL_MAX_10_EXP +# undef FLT_MAX +# undef DBL_MAX +# undef LDBL_MAX +# undef FLT_EPSILON +# undef DBL_EPSILON +# undef LDBL_EPSILON +# undef FLT_MIN +# undef DBL_MIN +# undef LDBL_MIN +# if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef FLT_TRUE_MIN +# undef DBL_TRUE_MIN +# undef LDBL_TRUE_MIN +# undef FLT_DECIMAL_DIG +# undef DBL_DECIMAL_DIG +# undef LDBL_DECIMAL_DIG +# undef FLT_HAS_SUBNORM +# undef DBL_HAS_SUBNORM +# undef LDBL_HAS_SUBNORM +# endif +#endif + +/* Characteristics of floating point types, C99 5.2.4.2.2 */ + +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#define FLT_ROUNDS (__builtin_flt_rounds()) +#define FLT_RADIX __FLT_RADIX__ + +#define FLT_MANT_DIG __FLT_MANT_DIG__ +#define DBL_MANT_DIG __DBL_MANT_DIG__ +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ + +#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#define FLT_DIG __FLT_DIG__ +#define DBL_DIG __DBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ + +#define FLT_MIN_EXP __FLT_MIN_EXP__ +#define DBL_MIN_EXP __DBL_MIN_EXP__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ + +#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ +#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ + +#define FLT_MAX_EXP __FLT_MAX_EXP__ +#define DBL_MAX_EXP __DBL_MAX_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ + +#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ + +#define FLT_MAX __FLT_MAX__ +#define DBL_MAX __DBL_MAX__ +#define LDBL_MAX __LDBL_MAX__ + +#define FLT_EPSILON __FLT_EPSILON__ +#define DBL_EPSILON __DBL_EPSILON__ +#define LDBL_EPSILON __LDBL_EPSILON__ + +#define FLT_MIN __FLT_MIN__ +#define DBL_MIN __DBL_MIN__ +#define LDBL_MIN __LDBL_MIN__ + +#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define FLT_TRUE_MIN __FLT_DENORM_MIN__ +# define DBL_TRUE_MIN __DBL_DENORM_MIN__ +# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ +# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ +# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ +# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ +# define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ +# define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ +# define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ +#endif + +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ +# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ +# define FLT16_DIG __FLT16_DIG__ +# define FLT16_MIN_EXP __FLT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ +# define FLT16_MAX_EXP __FLT16_MAX_EXP__ +# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ +# define FLT16_MAX __FLT16_MAX__ +# define FLT16_EPSILON __FLT16_EPSILON__ +# define FLT16_MIN __FLT16_MIN__ +# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__ +#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ + +#endif /* __CLANG_FLOAT_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..31020b3bf9cbc05b19e50ec6c75e745f1166076e Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@float.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h new file mode 100644 index 0000000000000000000000000000000000000000..1c894c4aca4975d7439ed3abda221818dbc57e94 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h @@ -0,0 +1,97 @@ +/*===---- inttypes.h - Standard header for integer printf macros ----------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_INTTYPES_H +// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. +#if !defined(_AIX) || !defined(_STD_TYPES_T) +#define __CLANG_INTTYPES_H +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1800 +#error MSVC does not have inttypes.h prior to Visual Studio 2013 +#endif + +#include_next + +#if defined(_MSC_VER) && _MSC_VER < 1900 +/* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x". + * This triggers format warnings, so fix it up here. */ +#undef PRId32 +#undef PRIdLEAST32 +#undef PRIdFAST32 +#undef PRIi32 +#undef PRIiLEAST32 +#undef PRIiFAST32 +#undef PRIo32 +#undef PRIoLEAST32 +#undef PRIoFAST32 +#undef PRIu32 +#undef PRIuLEAST32 +#undef PRIuFAST32 +#undef PRIx32 +#undef PRIxLEAST32 +#undef PRIxFAST32 +#undef PRIX32 +#undef PRIXLEAST32 +#undef PRIXFAST32 + +#undef SCNd32 +#undef SCNdLEAST32 +#undef SCNdFAST32 +#undef SCNi32 +#undef SCNiLEAST32 +#undef SCNiFAST32 +#undef SCNo32 +#undef SCNoLEAST32 +#undef SCNoFAST32 +#undef SCNu32 +#undef SCNuLEAST32 +#undef SCNuFAST32 +#undef SCNx32 +#undef SCNxLEAST32 +#undef SCNxFAST32 + +#define PRId32 "d" +#define PRIdLEAST32 "d" +#define PRIdFAST32 "d" +#define PRIi32 "i" +#define PRIiLEAST32 "i" +#define PRIiFAST32 "i" +#define PRIo32 "o" +#define PRIoLEAST32 "o" +#define PRIoFAST32 "o" +#define PRIu32 "u" +#define PRIuLEAST32 "u" +#define PRIuFAST32 "u" +#define PRIx32 "x" +#define PRIxLEAST32 "x" +#define PRIxFAST32 "x" +#define PRIX32 "X" +#define PRIXLEAST32 "X" +#define PRIXFAST32 "X" + +#define SCNd32 "d" +#define SCNdLEAST32 "d" +#define SCNdFAST32 "d" +#define SCNi32 "i" +#define SCNiLEAST32 "i" +#define SCNiFAST32 "i" +#define SCNo32 "o" +#define SCNoLEAST32 "o" +#define SCNoFAST32 "o" +#define SCNu32 "u" +#define SCNuLEAST32 "u" +#define SCNuFAST32 "u" +#define SCNx32 "x" +#define SCNxLEAST32 "x" +#define SCNxFAST32 "x" +#endif + +#endif /* __CLANG_INTTYPES_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..bbff09507123d4f901a9cce5685fe38c681b5181 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@inttypes.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h new file mode 100644 index 0000000000000000000000000000000000000000..cfd23a219ee553a868a03f3363d5d32c1662375a --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h @@ -0,0 +1,122 @@ +/*===---- limits.h - Standard header for integer sizes --------------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_LIMITS_H +#define __CLANG_LIMITS_H + +/* The system's limits.h may, in turn, try to #include_next GCC's limits.h. + Avert this #include_next madness. */ +#if defined __GNUC__ && !defined _GCC_LIMITS_H_ +#define _GCC_LIMITS_H_ +#endif + +/* System headers include a number of constants from POSIX in . + Include it if we're hosted. */ +#if __STDC_HOSTED__ && __has_include_next() +#include_next +#endif + +/* Many system headers try to "help us out" by defining these. No really, we + know how big each datatype is. */ +#undef SCHAR_MIN +#undef SCHAR_MAX +#undef UCHAR_MAX +#undef SHRT_MIN +#undef SHRT_MAX +#undef USHRT_MAX +#undef INT_MIN +#undef INT_MAX +#undef UINT_MAX +#undef LONG_MIN +#undef LONG_MAX +#undef ULONG_MAX + +#undef CHAR_BIT +#undef CHAR_MIN +#undef CHAR_MAX + +/* C90/99 5.2.4.2.1 */ +#define SCHAR_MAX __SCHAR_MAX__ +#define SHRT_MAX __SHRT_MAX__ +#define INT_MAX __INT_MAX__ +#define LONG_MAX __LONG_MAX__ + +#define SCHAR_MIN (-__SCHAR_MAX__-1) +#define SHRT_MIN (-__SHRT_MAX__ -1) +#define INT_MIN (-__INT_MAX__ -1) +#define LONG_MIN (-__LONG_MAX__ -1L) + +#define UCHAR_MAX (__SCHAR_MAX__*2 +1) +#define USHRT_MAX (__SHRT_MAX__ *2 +1) +#define UINT_MAX (__INT_MAX__ *2U +1U) +#define ULONG_MAX (__LONG_MAX__ *2UL+1UL) + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 1 +#endif + +#define CHAR_BIT __CHAR_BIT__ + +/* C2x 5.2.4.2.1 */ +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +#define BOOL_WIDTH __BOOL_WIDTH__ +#define CHAR_WIDTH CHAR_BIT +#define SCHAR_WIDTH CHAR_BIT +#define UCHAR_WIDTH CHAR_BIT +#define USHRT_WIDTH __SHRT_WIDTH__ +#define SHRT_WIDTH __SHRT_WIDTH__ +#define UINT_WIDTH __INT_WIDTH__ +#define INT_WIDTH __INT_WIDTH__ +#define ULONG_WIDTH __LONG_WIDTH__ +#define LONG_WIDTH __LONG_WIDTH__ +#define ULLONG_WIDTH __LLONG_WIDTH__ +#define LLONG_WIDTH __LLONG_WIDTH__ + +#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__ +#endif + +#ifdef __CHAR_UNSIGNED__ /* -funsigned-char */ +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#else +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX __SCHAR_MAX__ +#endif + +/* C99 5.2.4.2.1: Added long long. + C++11 18.3.3.2: same contents as the Standard C Library header . + */ +#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L + +#undef LLONG_MIN +#undef LLONG_MAX +#undef ULLONG_MAX + +#define LLONG_MAX __LONG_LONG_MAX__ +#define LLONG_MIN (-__LONG_LONG_MAX__-1LL) +#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) +#endif + +/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad + that we don't have something like #pragma poison that could be used to + deprecate a macro - the code should just use LLONG_MAX and friends. + */ +#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__) + +#undef LONG_LONG_MIN +#undef LONG_LONG_MAX +#undef ULONG_LONG_MAX + +#define LONG_LONG_MAX __LONG_LONG_MAX__ +#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1LL) +#define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) +#endif + +#endif /* __CLANG_LIMITS_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..3d740c45bde3e85dd623949a33d1c5bda9aed7cb Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@limits.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h new file mode 100644 index 0000000000000000000000000000000000000000..6ad25db4539a1359146a428b3f2b8e646bdeae7b --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h @@ -0,0 +1,21 @@ +/*===---- stdalign.h - Standard header for alignment ------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDALIGN_H +#define __STDALIGN_H + +#ifndef __cplusplus +#define alignas _Alignas +#define alignof _Alignof +#endif + +#define __alignas_is_defined 1 +#define __alignof_is_defined 1 + +#endif /* __STDALIGN_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..c68b7846ac21c8d388ec758a5aeb497da064c77d Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdalign.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h new file mode 100644 index 0000000000000000000000000000000000000000..0bc39408c1e5feaadd6f0420d14324b477420b93 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h @@ -0,0 +1,35 @@ +/*===---- stdarg.h - Variable argument handling ----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDARG_H +#define __STDARG_H + +#ifndef _VA_LIST +typedef __builtin_va_list va_list; +#define _VA_LIST +#endif +#define va_start(ap, param) __builtin_va_start(ap, param) +#define va_end(ap) __builtin_va_end(ap) +#define va_arg(ap, type) __builtin_va_arg(ap, type) + +/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode + * or -ansi is not specified, since it was not part of C90. + */ +#define __va_copy(d,s) __builtin_va_copy(d,s) + +#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) +#define va_copy(dest, src) __builtin_va_copy(dest, src) +#endif + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST 1 +typedef __builtin_va_list __gnuc_va_list; +#endif + +#endif /* __STDARG_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..fb892635fc1a7049fbfa994b4a38f6f88421dff2 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdarg.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h new file mode 100644 index 0000000000000000000000000000000000000000..2525363dd02a57dd5cf4cbb7a19b93bb408a8707 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h @@ -0,0 +1,31 @@ +/*===---- stdbool.h - Standard header for booleans -------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDBOOL_H +#define __STDBOOL_H + +/* Don't define bool, true, and false in C++, except as a GNU extension. */ +#ifndef __cplusplus +#define bool _Bool +#define true 1 +#define false 0 +#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* Define _Bool as a GNU extension. */ +#define _Bool bool +#if __cplusplus < 201103L +/* For C++98, define bool, false, true as a GNU extension. */ +#define bool bool +#define false false +#define true true +#endif +#endif + +#define __bool_true_false_are_defined 1 + +#endif /* __STDBOOL_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..d48e6f7a79d74c0861306d2a651a601012f0d640 Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdbool.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..15acd4427ca14000111aad5071563bc7f2dc09f4 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h @@ -0,0 +1,121 @@ +/*===---- stddef.h - Basic type definitions --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined(__STDDEF_H) || defined(__need_ptrdiff_t) || \ + defined(__need_size_t) || defined(__need_wchar_t) || \ + defined(__need_NULL) || defined(__need_wint_t) + +#if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \ + !defined(__need_wchar_t) && !defined(__need_NULL) && \ + !defined(__need_wint_t) +/* Always define miscellaneous pieces when modules are available. */ +#if !__has_feature(modules) +#define __STDDEF_H +#endif +#define __need_ptrdiff_t +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#define __need_STDDEF_H_misc +/* __need_wint_t is intentionally not defined here. */ +#endif + +#if defined(__need_ptrdiff_t) +#if !defined(_PTRDIFF_T) || __has_feature(modules) +/* Always define ptrdiff_t when modules are available. */ +#if !__has_feature(modules) +#define _PTRDIFF_T +#endif +typedef __PTRDIFF_TYPE__ ptrdiff_t; +#endif +#undef __need_ptrdiff_t +#endif /* defined(__need_ptrdiff_t) */ + +#if defined(__need_size_t) +#if !defined(_SIZE_T) || __has_feature(modules) +/* Always define size_t when modules are available. */ +#if !__has_feature(modules) +#define _SIZE_T +#endif +typedef __SIZE_TYPE__ size_t; +#endif +#undef __need_size_t +#endif /*defined(__need_size_t) */ + +#if defined(__need_STDDEF_H_misc) +/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is + * enabled. */ +#if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \ + !defined(_RSIZE_T)) || __has_feature(modules) +/* Always define rsize_t when modules are available. */ +#if !__has_feature(modules) +#define _RSIZE_T +#endif +typedef __SIZE_TYPE__ rsize_t; +#endif +#endif /* defined(__need_STDDEF_H_misc) */ + +#if defined(__need_wchar_t) +#ifndef __cplusplus +/* Always define wchar_t when modules are available. */ +#if !defined(_WCHAR_T) || __has_feature(modules) +#if !__has_feature(modules) +#define _WCHAR_T +#if defined(_MSC_EXTENSIONS) +#define _WCHAR_T_DEFINED +#endif +#endif +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif +#undef __need_wchar_t +#endif /* defined(__need_wchar_t) */ + +#if defined(__need_NULL) +#undef NULL +#ifdef __cplusplus +# if !defined(__MINGW32__) && !defined(_MSC_VER) +# define NULL __null +# else +# define NULL 0 +# endif +#else +# define NULL ((void*)0) +#endif +#ifdef __cplusplus +#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED) +namespace std { typedef decltype(nullptr) nullptr_t; } +using ::std::nullptr_t; +#endif +#endif +#undef __need_NULL +#endif /* defined(__need_NULL) */ + +#if defined(__need_STDDEF_H_misc) +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +#include "__stddef_max_align_t.h" +#endif +#define offsetof(t, d) __builtin_offsetof(t, d) +#undef __need_STDDEF_H_misc +#endif /* defined(__need_STDDEF_H_misc) */ + +/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use +__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ +#if defined(__need_wint_t) +/* Always define wint_t when modules are available. */ +#if !defined(_WINT_T) || __has_feature(modules) +#if !__has_feature(modules) +#define _WINT_T +#endif +typedef __WINT_TYPE__ wint_t; +#endif +#undef __need_wint_t +#endif /* __need_wint_t */ + +#endif diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..030fa99cdc69cf00131f3c830a5edcb660030dca Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stddef.h.blob differ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h new file mode 100644 index 0000000000000000000000000000000000000000..4790c25a2774bad0d5928c1c94aa10768912bb50 --- /dev/null +++ b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h @@ -0,0 +1,861 @@ +/*===---- stdint.h - Standard header for sized integer types --------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_STDINT_H +// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. +#if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__) +#define __CLANG_STDINT_H +#endif + +/* If we're hosted, fall back to the system's stdint.h, which might have + * additional definitions. + */ +#if __STDC_HOSTED__ && __has_include_next() + +// C99 7.18.3 Limits of other integer types +// +// Footnote 219, 220: C++ implementations should define these macros only when +// __STDC_LIMIT_MACROS is defined before is included. +// +// Footnote 222: C++ implementations should define these macros only when +// __STDC_CONSTANT_MACROS is defined before is included. +// +// C++11 [cstdint.syn]p2: +// +// The macros defined by are provided unconditionally. In particular, +// the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in +// footnotes 219, 220, and 222 in the C standard) play no role in C++. +// +// C11 removed the problematic footnotes. +// +// Work around this inconsistency by always defining those macros in C++ mode, +// so that a C library implementation which follows the C99 standard can be +// used in C++. +# ifdef __cplusplus +# if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# endif +# if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# endif +# endif + +# include_next + +# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# undef __STDC_LIMIT_MACROS +# undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# endif +# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# undef __STDC_CONSTANT_MACROS +# undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# endif + +#else + +/* C99 7.18.1.1 Exact-width integer types. + * C99 7.18.1.2 Minimum-width integer types. + * C99 7.18.1.3 Fastest minimum-width integer types. + * + * The standard requires that exact-width type be defined for 8-, 16-, 32-, and + * 64-bit types if they are implemented. Other exact width types are optional. + * This implementation defines an exact-width types for every integer width + * that is represented in the standard integer types. + * + * The standard also requires minimum-width types be defined for 8-, 16-, 32-, + * and 64-bit widths regardless of whether there are corresponding exact-width + * types. + * + * To accommodate targets that are missing types that are exactly 8, 16, 32, or + * 64 bits wide, this implementation takes an approach of cascading + * redefinitions, redefining __int_leastN_t to successively smaller exact-width + * types. It is therefore important that the types are defined in order of + * descending widths. + * + * We currently assume that the minimum-width types and the fastest + * minimum-width types are the same. This is allowed by the standard, but is + * suboptimal. + * + * In violation of the standard, some targets do not implement a type that is + * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). + * To accommodate these targets, a required minimum-width type is only + * defined if there exists an exact-width type of equal or greater width. + */ + +#ifdef __INT64_TYPE__ +# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/ +typedef __INT64_TYPE__ int64_t; +# endif /* __int8_t_defined */ +typedef __UINT64_TYPE__ uint64_t; +# define __int_least64_t int64_t +# define __uint_least64_t uint64_t +# define __int_least32_t int64_t +# define __uint_least32_t uint64_t +# define __int_least16_t int64_t +# define __uint_least16_t uint64_t +# define __int_least8_t int64_t +# define __uint_least8_t uint64_t +#endif /* __INT64_TYPE__ */ + +#ifdef __int_least64_t +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +typedef __int_least64_t int_fast64_t; +typedef __uint_least64_t uint_fast64_t; +#endif /* __int_least64_t */ + +#ifdef __INT56_TYPE__ +typedef __INT56_TYPE__ int56_t; +typedef __UINT56_TYPE__ uint56_t; +typedef int56_t int_least56_t; +typedef uint56_t uint_least56_t; +typedef int56_t int_fast56_t; +typedef uint56_t uint_fast56_t; +# define __int_least32_t int56_t +# define __uint_least32_t uint56_t +# define __int_least16_t int56_t +# define __uint_least16_t uint56_t +# define __int_least8_t int56_t +# define __uint_least8_t uint56_t +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +typedef __INT48_TYPE__ int48_t; +typedef __UINT48_TYPE__ uint48_t; +typedef int48_t int_least48_t; +typedef uint48_t uint_least48_t; +typedef int48_t int_fast48_t; +typedef uint48_t uint_fast48_t; +# define __int_least32_t int48_t +# define __uint_least32_t uint48_t +# define __int_least16_t int48_t +# define __uint_least16_t uint48_t +# define __int_least8_t int48_t +# define __uint_least8_t uint48_t +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +typedef __INT40_TYPE__ int40_t; +typedef __UINT40_TYPE__ uint40_t; +typedef int40_t int_least40_t; +typedef uint40_t uint_least40_t; +typedef int40_t int_fast40_t; +typedef uint40_t uint_fast40_t; +# define __int_least32_t int40_t +# define __uint_least32_t uint40_t +# define __int_least16_t int40_t +# define __uint_least16_t uint40_t +# define __int_least8_t int40_t +# define __uint_least8_t uint40_t +#endif /* __INT40_TYPE__ */ + + +#ifdef __INT32_TYPE__ + +# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/ +typedef __INT32_TYPE__ int32_t; +# endif /* __int8_t_defined */ + +# ifndef __uint32_t_defined /* more glibc compatibility */ +# define __uint32_t_defined +typedef __UINT32_TYPE__ uint32_t; +# endif /* __uint32_t_defined */ + +# define __int_least32_t int32_t +# define __uint_least32_t uint32_t +# define __int_least16_t int32_t +# define __uint_least16_t uint32_t +# define __int_least8_t int32_t +# define __uint_least8_t uint32_t +#endif /* __INT32_TYPE__ */ + +#ifdef __int_least32_t +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; +typedef __int_least32_t int_fast32_t; +typedef __uint_least32_t uint_fast32_t; +#endif /* __int_least32_t */ + +#ifdef __INT24_TYPE__ +typedef __INT24_TYPE__ int24_t; +typedef __UINT24_TYPE__ uint24_t; +typedef int24_t int_least24_t; +typedef uint24_t uint_least24_t; +typedef int24_t int_fast24_t; +typedef uint24_t uint_fast24_t; +# define __int_least16_t int24_t +# define __uint_least16_t uint24_t +# define __int_least8_t int24_t +# define __uint_least8_t uint24_t +#endif /* __INT24_TYPE__ */ + +#ifdef __INT16_TYPE__ +#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/ +typedef __INT16_TYPE__ int16_t; +#endif /* __int8_t_defined */ +typedef __UINT16_TYPE__ uint16_t; +# define __int_least16_t int16_t +# define __uint_least16_t uint16_t +# define __int_least8_t int16_t +# define __uint_least8_t uint16_t +#endif /* __INT16_TYPE__ */ + +#ifdef __int_least16_t +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; +typedef __int_least16_t int_fast16_t; +typedef __uint_least16_t uint_fast16_t; +#endif /* __int_least16_t */ + + +#ifdef __INT8_TYPE__ +#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/ +typedef __INT8_TYPE__ int8_t; +#endif /* __int8_t_defined */ +typedef __UINT8_TYPE__ uint8_t; +# define __int_least8_t int8_t +# define __uint_least8_t uint8_t +#endif /* __INT8_TYPE__ */ + +#ifdef __int_least8_t +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; +typedef __int_least8_t int_fast8_t; +typedef __uint_least8_t uint_fast8_t; +#endif /* __int_least8_t */ + +/* prevent glibc sys/types.h from defining conflicting types */ +#ifndef __int8_t_defined +# define __int8_t_defined +#endif /* __int8_t_defined */ + +/* C99 7.18.1.4 Integer types capable of holding object pointers. + */ +#define __stdint_join3(a,b,c) a ## b ## c + +#ifndef _INTPTR_T +#ifndef __intptr_t_defined +typedef __INTPTR_TYPE__ intptr_t; +#define __intptr_t_defined +#define _INTPTR_T +#endif +#endif + +#ifndef _UINTPTR_T +typedef __UINTPTR_TYPE__ uintptr_t; +#define _UINTPTR_T +#endif + +/* C99 7.18.1.5 Greatest-width integer types. + */ +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; + +/* C99 7.18.4 Macros for minimum-width integer constants. + * + * The standard requires that integer constant macros be defined for all the + * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width + * types are required, the corresponding integer constant macros are defined + * here. This implementation also defines minimum-width types for every other + * integer width that the target implements, so corresponding macros are + * defined below, too. + * + * These macros are defined using the same successive-shrinking approach as + * the type definitions above. It is likewise important that macros are defined + * in order of decending width. + * + * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +#define __int_c_join(a, b) a ## b +#define __int_c(v, suffix) __int_c_join(v, suffix) +#define __uint_c(v, suffix) __int_c_join(v##U, suffix) + + +#ifdef __INT64_TYPE__ +# ifdef __INT64_C_SUFFIX__ +# define __int64_c_suffix __INT64_C_SUFFIX__ +# define __int32_c_suffix __INT64_C_SUFFIX__ +# define __int16_c_suffix __INT64_C_SUFFIX__ +# define __int8_c_suffix __INT64_C_SUFFIX__ +# else +# undef __int64_c_suffix +# undef __int32_c_suffix +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT64_C_SUFFIX__ */ +#endif /* __INT64_TYPE__ */ + +#ifdef __int_least64_t +# ifdef __int64_c_suffix +# define INT64_C(v) __int_c(v, __int64_c_suffix) +# define UINT64_C(v) __uint_c(v, __int64_c_suffix) +# else +# define INT64_C(v) v +# define UINT64_C(v) v ## U +# endif /* __int64_c_suffix */ +#endif /* __int_least64_t */ + + +#ifdef __INT56_TYPE__ +# ifdef __INT56_C_SUFFIX__ +# define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__) +# define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__) +# define __int32_c_suffix __INT56_C_SUFFIX__ +# define __int16_c_suffix __INT56_C_SUFFIX__ +# define __int8_c_suffix __INT56_C_SUFFIX__ +# else +# define INT56_C(v) v +# define UINT56_C(v) v ## U +# undef __int32_c_suffix +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT56_C_SUFFIX__ */ +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +# ifdef __INT48_C_SUFFIX__ +# define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__) +# define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__) +# define __int32_c_suffix __INT48_C_SUFFIX__ +# define __int16_c_suffix __INT48_C_SUFFIX__ +# define __int8_c_suffix __INT48_C_SUFFIX__ +# else +# define INT48_C(v) v +# define UINT48_C(v) v ## U +# undef __int32_c_suffix +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT48_C_SUFFIX__ */ +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +# ifdef __INT40_C_SUFFIX__ +# define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__) +# define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__) +# define __int32_c_suffix __INT40_C_SUFFIX__ +# define __int16_c_suffix __INT40_C_SUFFIX__ +# define __int8_c_suffix __INT40_C_SUFFIX__ +# else +# define INT40_C(v) v +# define UINT40_C(v) v ## U +# undef __int32_c_suffix +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT40_C_SUFFIX__ */ +#endif /* __INT40_TYPE__ */ + + +#ifdef __INT32_TYPE__ +# ifdef __INT32_C_SUFFIX__ +# define __int32_c_suffix __INT32_C_SUFFIX__ +# define __int16_c_suffix __INT32_C_SUFFIX__ +# define __int8_c_suffix __INT32_C_SUFFIX__ +#else +# undef __int32_c_suffix +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT32_C_SUFFIX__ */ +#endif /* __INT32_TYPE__ */ + +#ifdef __int_least32_t +# ifdef __int32_c_suffix +# define INT32_C(v) __int_c(v, __int32_c_suffix) +# define UINT32_C(v) __uint_c(v, __int32_c_suffix) +# else +# define INT32_C(v) v +# define UINT32_C(v) v ## U +# endif /* __int32_c_suffix */ +#endif /* __int_least32_t */ + + +#ifdef __INT24_TYPE__ +# ifdef __INT24_C_SUFFIX__ +# define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__) +# define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__) +# define __int16_c_suffix __INT24_C_SUFFIX__ +# define __int8_c_suffix __INT24_C_SUFFIX__ +# else +# define INT24_C(v) v +# define UINT24_C(v) v ## U +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT24_C_SUFFIX__ */ +#endif /* __INT24_TYPE__ */ + + +#ifdef __INT16_TYPE__ +# ifdef __INT16_C_SUFFIX__ +# define __int16_c_suffix __INT16_C_SUFFIX__ +# define __int8_c_suffix __INT16_C_SUFFIX__ +#else +# undef __int16_c_suffix +# undef __int8_c_suffix +# endif /* __INT16_C_SUFFIX__ */ +#endif /* __INT16_TYPE__ */ + +#ifdef __int_least16_t +# ifdef __int16_c_suffix +# define INT16_C(v) __int_c(v, __int16_c_suffix) +# define UINT16_C(v) __uint_c(v, __int16_c_suffix) +# else +# define INT16_C(v) v +# define UINT16_C(v) v ## U +# endif /* __int16_c_suffix */ +#endif /* __int_least16_t */ + + +#ifdef __INT8_TYPE__ +# ifdef __INT8_C_SUFFIX__ +# define __int8_c_suffix __INT8_C_SUFFIX__ +#else +# undef __int8_c_suffix +# endif /* __INT8_C_SUFFIX__ */ +#endif /* __INT8_TYPE__ */ + +#ifdef __int_least8_t +# ifdef __int8_c_suffix +# define INT8_C(v) __int_c(v, __int8_c_suffix) +# define UINT8_C(v) __uint_c(v, __int8_c_suffix) +# else +# define INT8_C(v) v +# define UINT8_C(v) v ## U +# endif /* __int8_c_suffix */ +#endif /* __int_least8_t */ + + +/* C99 7.18.2.1 Limits of exact-width integer types. + * C99 7.18.2.2 Limits of minimum-width integer types. + * C99 7.18.2.3 Limits of fastest minimum-width integer types. + * + * The presence of limit macros are completely optional in C99. This + * implementation defines limits for all of the types (exact- and + * minimum-width) that it defines above, using the limits of the minimum-width + * type for any types that do not have exact-width representations. + * + * As in the type definitions, this section takes an approach of + * successive-shrinking to determine which limits to use for the standard (8, + * 16, 32, 64) bit widths when they don't have exact representations. It is + * therefore important that the definitions be kept in order of decending + * widths. + * + * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +#ifdef __INT64_TYPE__ +# define INT64_MAX INT64_C( 9223372036854775807) +# define INT64_MIN (-INT64_C( 9223372036854775807)-1) +# define UINT64_MAX UINT64_C(18446744073709551615) +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT64_WIDTH 64 +# define INT64_WIDTH UINT64_WIDTH + +# define __UINT_LEAST64_WIDTH UINT64_WIDTH +# define __UINT_LEAST32_WIDTH UINT64_WIDTH +# define __UINT_LEAST16_WIDTH UINT64_WIDTH +# define __UINT_LEAST8_MAX UINT64_MAX +#endif /* __STDC_VERSION__ */ + +# define __INT_LEAST64_MIN INT64_MIN +# define __INT_LEAST64_MAX INT64_MAX +# define __UINT_LEAST64_MAX UINT64_MAX +# define __INT_LEAST32_MIN INT64_MIN +# define __INT_LEAST32_MAX INT64_MAX +# define __UINT_LEAST32_MAX UINT64_MAX +# define __INT_LEAST16_MIN INT64_MIN +# define __INT_LEAST16_MAX INT64_MAX +# define __UINT_LEAST16_MAX UINT64_MAX +# define __INT_LEAST8_MIN INT64_MIN +# define __INT_LEAST8_MAX INT64_MAX +# define __UINT_LEAST8_MAX UINT64_MAX +#endif /* __INT64_TYPE__ */ + +#ifdef __INT_LEAST64_MIN +# define INT_LEAST64_MIN __INT_LEAST64_MIN +# define INT_LEAST64_MAX __INT_LEAST64_MAX +# define UINT_LEAST64_MAX __UINT_LEAST64_MAX +# define INT_FAST64_MIN __INT_LEAST64_MIN +# define INT_FAST64_MAX __INT_LEAST64_MAX +# define UINT_FAST64_MAX __UINT_LEAST64_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH +# define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH +# define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH +# define INT_FAST64_WIDTH UINT_FAST64_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST64_MIN */ + + +#ifdef __INT56_TYPE__ +# define INT56_MAX INT56_C(36028797018963967) +# define INT56_MIN (-INT56_C(36028797018963967)-1) +# define UINT56_MAX UINT56_C(72057594037927935) +# define INT_LEAST56_MIN INT56_MIN +# define INT_LEAST56_MAX INT56_MAX +# define UINT_LEAST56_MAX UINT56_MAX +# define INT_FAST56_MIN INT56_MIN +# define INT_FAST56_MAX INT56_MAX +# define UINT_FAST56_MAX UINT56_MAX + +# define __INT_LEAST32_MIN INT56_MIN +# define __INT_LEAST32_MAX INT56_MAX +# define __UINT_LEAST32_MAX UINT56_MAX +# define __INT_LEAST16_MIN INT56_MIN +# define __INT_LEAST16_MAX INT56_MAX +# define __UINT_LEAST16_MAX UINT56_MAX +# define __INT_LEAST8_MIN INT56_MIN +# define __INT_LEAST8_MAX INT56_MAX +# define __UINT_LEAST8_MAX UINT56_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT56_WIDTH 56 +# define INT56_WIDTH UINT56_WIDTH +# define UINT_LEAST56_WIDTH UINT56_WIDTH +# define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH +# define UINT_FAST56_WIDTH UINT56_WIDTH +# define INT_FAST56_WIDTH UINT_FAST56_WIDTH +# define __UINT_LEAST32_WIDTH UINT56_WIDTH +# define __UINT_LEAST16_WIDTH UINT56_WIDTH +# define __UINT_LEAST8_WIDTH UINT56_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +# define INT48_MAX INT48_C(140737488355327) +# define INT48_MIN (-INT48_C(140737488355327)-1) +# define UINT48_MAX UINT48_C(281474976710655) +# define INT_LEAST48_MIN INT48_MIN +# define INT_LEAST48_MAX INT48_MAX +# define UINT_LEAST48_MAX UINT48_MAX +# define INT_FAST48_MIN INT48_MIN +# define INT_FAST48_MAX INT48_MAX +# define UINT_FAST48_MAX UINT48_MAX + +# define __INT_LEAST32_MIN INT48_MIN +# define __INT_LEAST32_MAX INT48_MAX +# define __UINT_LEAST32_MAX UINT48_MAX +# define __INT_LEAST16_MIN INT48_MIN +# define __INT_LEAST16_MAX INT48_MAX +# define __UINT_LEAST16_MAX UINT48_MAX +# define __INT_LEAST8_MIN INT48_MIN +# define __INT_LEAST8_MAX INT48_MAX +# define __UINT_LEAST8_MAX UINT48_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +#define UINT48_WIDTH 48 +#define INT48_WIDTH UINT48_WIDTH +#define UINT_LEAST48_WIDTH UINT48_WIDTH +#define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH +#define UINT_FAST48_WIDTH UINT48_WIDTH +#define INT_FAST48_WIDTH UINT_FAST48_WIDTH +#define __UINT_LEAST32_WIDTH UINT48_WIDTH +#define __UINT_LEAST16_WIDTH UINT48_WIDTH +#define __UINT_LEAST8_WIDTH UINT48_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +# define INT40_MAX INT40_C(549755813887) +# define INT40_MIN (-INT40_C(549755813887)-1) +# define UINT40_MAX UINT40_C(1099511627775) +# define INT_LEAST40_MIN INT40_MIN +# define INT_LEAST40_MAX INT40_MAX +# define UINT_LEAST40_MAX UINT40_MAX +# define INT_FAST40_MIN INT40_MIN +# define INT_FAST40_MAX INT40_MAX +# define UINT_FAST40_MAX UINT40_MAX + +# define __INT_LEAST32_MIN INT40_MIN +# define __INT_LEAST32_MAX INT40_MAX +# define __UINT_LEAST32_MAX UINT40_MAX +# define __INT_LEAST16_MIN INT40_MIN +# define __INT_LEAST16_MAX INT40_MAX +# define __UINT_LEAST16_MAX UINT40_MAX +# define __INT_LEAST8_MIN INT40_MIN +# define __INT_LEAST8_MAX INT40_MAX +# define __UINT_LEAST8_MAX UINT40_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT40_WIDTH 40 +# define INT40_WIDTH UINT40_WIDTH +# define UINT_LEAST40_WIDTH UINT40_WIDTH +# define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH +# define UINT_FAST40_WIDTH UINT40_WIDTH +# define INT_FAST40_WIDTH UINT_FAST40_WIDTH +# define __UINT_LEAST32_WIDTH UINT40_WIDTH +# define __UINT_LEAST16_WIDTH UINT40_WIDTH +# define __UINT_LEAST8_WIDTH UINT40_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT40_TYPE__ */ + + +#ifdef __INT32_TYPE__ +# define INT32_MAX INT32_C(2147483647) +# define INT32_MIN (-INT32_C(2147483647)-1) +# define UINT32_MAX UINT32_C(4294967295) + +# define __INT_LEAST32_MIN INT32_MIN +# define __INT_LEAST32_MAX INT32_MAX +# define __UINT_LEAST32_MAX UINT32_MAX +# define __INT_LEAST16_MIN INT32_MIN +# define __INT_LEAST16_MAX INT32_MAX +# define __UINT_LEAST16_MAX UINT32_MAX +# define __INT_LEAST8_MIN INT32_MIN +# define __INT_LEAST8_MAX INT32_MAX +# define __UINT_LEAST8_MAX UINT32_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT32_WIDTH 32 +# define INT32_WIDTH UINT32_WIDTH +# define __UINT_LEAST32_WIDTH UINT32_WIDTH +# define __UINT_LEAST16_WIDTH UINT32_WIDTH +# define __UINT_LEAST8_WIDTH UINT32_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT32_TYPE__ */ + +#ifdef __INT_LEAST32_MIN +# define INT_LEAST32_MIN __INT_LEAST32_MIN +# define INT_LEAST32_MAX __INT_LEAST32_MAX +# define UINT_LEAST32_MAX __UINT_LEAST32_MAX +# define INT_FAST32_MIN __INT_LEAST32_MIN +# define INT_FAST32_MAX __INT_LEAST32_MAX +# define UINT_FAST32_MAX __UINT_LEAST32_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH +# define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH +# define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH +# define INT_FAST32_WIDTH UINT_FAST32_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST32_MIN */ + + +#ifdef __INT24_TYPE__ +# define INT24_MAX INT24_C(8388607) +# define INT24_MIN (-INT24_C(8388607)-1) +# define UINT24_MAX UINT24_C(16777215) +# define INT_LEAST24_MIN INT24_MIN +# define INT_LEAST24_MAX INT24_MAX +# define UINT_LEAST24_MAX UINT24_MAX +# define INT_FAST24_MIN INT24_MIN +# define INT_FAST24_MAX INT24_MAX +# define UINT_FAST24_MAX UINT24_MAX + +# define __INT_LEAST16_MIN INT24_MIN +# define __INT_LEAST16_MAX INT24_MAX +# define __UINT_LEAST16_MAX UINT24_MAX +# define __INT_LEAST8_MIN INT24_MIN +# define __INT_LEAST8_MAX INT24_MAX +# define __UINT_LEAST8_MAX UINT24_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT24_WIDTH 24 +# define INT24_WIDTH UINT24_WIDTH +# define UINT_LEAST24_WIDTH UINT24_WIDTH +# define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH +# define UINT_FAST24_WIDTH UINT24_WIDTH +# define INT_FAST24_WIDTH UINT_FAST24_WIDTH +# define __UINT_LEAST16_WIDTH UINT24_WIDTH +# define __UINT_LEAST8_WIDTH UINT24_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT24_TYPE__ */ + + +#ifdef __INT16_TYPE__ +#define INT16_MAX INT16_C(32767) +#define INT16_MIN (-INT16_C(32767)-1) +#define UINT16_MAX UINT16_C(65535) + +# define __INT_LEAST16_MIN INT16_MIN +# define __INT_LEAST16_MAX INT16_MAX +# define __UINT_LEAST16_MAX UINT16_MAX +# define __INT_LEAST8_MIN INT16_MIN +# define __INT_LEAST8_MAX INT16_MAX +# define __UINT_LEAST8_MAX UINT16_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT16_WIDTH 16 +# define INT16_WIDTH UINT16_WIDTH +# define __UINT_LEAST16_WIDTH UINT16_WIDTH +# define __UINT_LEAST8_WIDTH UINT16_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT16_TYPE__ */ + +#ifdef __INT_LEAST16_MIN +# define INT_LEAST16_MIN __INT_LEAST16_MIN +# define INT_LEAST16_MAX __INT_LEAST16_MAX +# define UINT_LEAST16_MAX __UINT_LEAST16_MAX +# define INT_FAST16_MIN __INT_LEAST16_MIN +# define INT_FAST16_MAX __INT_LEAST16_MAX +# define UINT_FAST16_MAX __UINT_LEAST16_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH +# define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH +# define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH +# define INT_FAST16_WIDTH UINT_FAST16_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST16_MIN */ + + +#ifdef __INT8_TYPE__ +# define INT8_MAX INT8_C(127) +# define INT8_MIN (-INT8_C(127)-1) +# define UINT8_MAX UINT8_C(255) + +# define __INT_LEAST8_MIN INT8_MIN +# define __INT_LEAST8_MAX INT8_MAX +# define __UINT_LEAST8_MAX UINT8_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT8_WIDTH 8 +# define INT8_WIDTH UINT8_WIDTH +# define __UINT_LEAST8_WIDTH UINT8_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT8_TYPE__ */ + +#ifdef __INT_LEAST8_MIN +# define INT_LEAST8_MIN __INT_LEAST8_MIN +# define INT_LEAST8_MAX __INT_LEAST8_MAX +# define UINT_LEAST8_MAX __UINT_LEAST8_MAX +# define INT_FAST8_MIN __INT_LEAST8_MIN +# define INT_FAST8_MAX __INT_LEAST8_MAX +# define UINT_FAST8_MAX __UINT_LEAST8_MAX + +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +# define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH +# define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH +# define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH +# define INT_FAST8_WIDTH UINT_FAST8_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST8_MIN */ + +/* Some utility macros */ +#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN) +#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX) +#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX) +#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v)) +#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v)) + +/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ +/* C99 7.18.3 Limits of other integer types. */ + +#define INTPTR_MIN (-__INTPTR_MAX__-1) +#define INTPTR_MAX __INTPTR_MAX__ +#define UINTPTR_MAX __UINTPTR_MAX__ +#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1) +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +/* C2x 7.20.2.4 Width of integer types capable of holding object pointers. */ +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +/* NB: The C standard requires that these be the same value, but the compiler + exposes separate internal width macros. */ +#define INTPTR_WIDTH __INTPTR_WIDTH__ +#define UINTPTR_WIDTH __UINTPTR_WIDTH__ +#endif + +/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ + * is enabled. */ +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#define RSIZE_MAX (SIZE_MAX >> 1) +#endif + +/* C99 7.18.2.5 Limits of greatest-width integer types. */ +#define INTMAX_MIN (-__INTMAX_MAX__-1) +#define INTMAX_MAX __INTMAX_MAX__ +#define UINTMAX_MAX __UINTMAX_MAX__ + +/* C2x 7.20.2.5 Width of greatest-width integer types. */ +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +/* NB: The C standard requires that these be the same value, but the compiler + exposes separate internal width macros. */ +#define INTMAX_WIDTH __INTMAX_WIDTH__ +#define UINTMAX_WIDTH __UINTMAX_WIDTH__ +#endif + +/* C99 7.18.3 Limits of other integer types. */ +#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) +#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__) +#ifdef __WINT_UNSIGNED__ +# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0) +# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__) +#else +# define WINT_MIN __INTN_MIN(__WINT_WIDTH__) +# define WINT_MAX __INTN_MAX(__WINT_WIDTH__) +#endif + +#ifndef WCHAR_MAX +# define WCHAR_MAX __WCHAR_MAX__ +#endif +#ifndef WCHAR_MIN +# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__) +# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__) +# else +# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0) +# endif +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants. */ +#define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__) +#define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__) + +/* C2x 7.20.3.x Width of other integer types. */ +/* FIXME: This is using the placeholder dates Clang produces for these macros + in C2x mode; switch to the correct values once they've been published. */ +#if __STDC_VERSION__ >= 202000L +#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__ +#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__ +#define SIZE_WIDTH __SIZE_WIDTH__ +#define WCHAR_WIDTH __WCHAR_WIDTH__ +#define WINT_WIDTH __WINT_WIDTH__ +#endif + +#endif /* __STDC_HOSTED__ */ +#endif /* __CLANG_STDINT_H */ diff --git a/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h.blob b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h.blob new file mode 100644 index 0000000000000000000000000000000000000000..f8c6119049dabde2f19139fdff51b5b8031634ab Binary files /dev/null and b/.ccls-cache/@@root@gpt-vue/@nix@store@rf7mgm3kn47ifbkyvvd87m8jkf4yc14p-clang-14.0.6-lib@lib@clang@14.0.6@include@stdint.h.blob differ diff --git a/.ccls-cache/@root@gpt-vue/ddd.cpp b/.ccls-cache/@root@gpt-vue/ddd.cpp new file mode 100644 index 0000000000000000000000000000000000000000..95143ab633d5061b49cd33fd83bac0e59db5086e --- /dev/null +++ b/.ccls-cache/@root@gpt-vue/ddd.cpp @@ -0,0 +1,172 @@ +#include +using namespace std; +#define maxk_of_vector 1000000000 +#define my (*this) +class big { + std::dequev; + /*00 00 22 55*/ + /* 表示 2255*/ + inline void ZERO_CLEAR__alg(dequev = v) { + /*去0*/ + while (!v[0])v.pop_front(); + } + inline void ZERO_ON_INT__alg(unsigned x, dequev = v) { + /*加0*/ + while (v.size() < x)v.push_front(0); + } + inline void REMOVE_ARR__alg(dequev = v) { + /*反转*/ + stackx; + while (v.size())x.push(v.front()); + while (x.size()) { + v.push_front(x.top()); + x.pop(); + } + } + inline void EQAUL_STRING__alg(string x) { + v.clear(); + stackc; + while (x.size()) { + c.push(x.back() ^ 48); + x.pop_back(); + } + unsigned long long d = 0; + while (c.size()) { + if (d * 10 >= maxk_of_vector)v.push_back(d), d = 0; + d = d << 3 + d << 1 + c.top(); + } + } + deque mul(deque &a, deque &b) { + deque ans(a.size() + b.size() + 1, 0); // 初始化结果数组 + REMOVE_ARR__alg(a); + REMOVE_ARR__alg(b); + // 标准竖式乘法 + for (int i = 0; i < a.size(); i++) { + unsigned long long carry = 0; + for (int j = 0; j < b.size(); j++) { + unsigned long long tmp = a[i] b[j] carry; + ans[i + j] += tmp; + carry = ans[i + j] / maxk_of_vector; + ans[i + j] %= maxk_of_vector; + } + if (carry) ans[i + b.size()] += carry; + } + REMOVE_ARR__alg(ans); + ZERO_CLEAR__alg(ans); + return ans; + } + + public : + big(std::string x) { + EQAUL_STRING__alg(x); + } + big(unsigned long long x) { + v.clear(); + v.push_back(x); + } + big(long long x) { + v.clear(); + v.push_back(x); + } + big(unsigned long x) { + v.clear(); + v.push_back(x); + } + big(short x) { + v.clear(); + v.push_back(x); + } + big(unsigned short x) { + v.clear(); + v.push_back(x); + } + big(char x) { + v.clear(); + v.push_back(x); + } + big(unsigned char x) { + v.clear(); + v.push_back(x); + } + big(big x) { + v = x.v; + } + ~big() { + v.clear(); + } + inline void operator = (unsigned long long x) { + v.clear(); + v.push_back(x); + } + inline void operator = (long long x) { + v.clear(); + v.push_back(x); + } + inline void operator = (unsigned long x) { + v.clear(); + v.push_back(x); + } + inline void operator = (long x) { + v.clear(); + v.push_back(x); + } + inline void operator = (unsigned short x) { + v.clear(); + v.push_back(x); + } + inline void operator = (short x) { + v.clear(); + v.push_back(x); + } + inline void operator = (big x) { + v = x.v; + } + inline void operator >>=(unsigned long long wei); + inline void operator <<=(unsigned long long wei); + inline big operator >>(unsigned long long wei); + inline big operator <<(unsigned long long wei); + inline big operator +(big x); + inline big operator -(big x); + inline big operator *(big x); + inline big operator /(big x); + inline big operator %(big x); + inline void operator +=(big x); + inline void operator -=(big x); + inline void operator *=(big x); + inline void operator /=(big x); + inline void operator %=(big x); + inline bool operator ==(big x) { + auto i = v.begin(); + auto j = x.v.begin(); + if (x.v.size() == v.size())while (i != v.end()) { + if (*i ^ *j)return false; + ++i; + ++j; + } else return false; + return true; + } + inline bool operator >=(big x) { + auto i = v.begin(); + auto j = x.v.begin(); + if (x.v.size() == v.size())while (i != v.end()) { + if (*i < *j)return false; + ++i; + ++j; + } else return v.size() >= x.v.size(); + return true; + + } + inline bool operator <=(big x) { + return !(my == x || my < x); + } + inline bool operator !=(big x) { + return !(my == x); + } + inline bool operator >(big x) { + return !(my <= x); + } + inline bool operator <(big x) { + return !(my >= x); + } +}; +/*高精度*/ \ No newline at end of file diff --git a/.ccls-cache/@root@gpt-vue/ddd.cpp.blob b/.ccls-cache/@root@gpt-vue/ddd.cpp.blob new file mode 100644 index 0000000000000000000000000000000000000000..1f3f491b245a795cf3c4444b1ff1390e6ba69956 Binary files /dev/null and b/.ccls-cache/@root@gpt-vue/ddd.cpp.blob differ